162e357622fcf3f7d134890bf0d5740b977742d0
[occt.git] / src / StepFile / step.yacc
1 /* 
2  Copyright (c) 1999-2014 OPEN CASCADE SAS
3
4  This file is part of Open CASCADE Technology software library.
5
6  This library is free software; you can redistribute it and/or modify it under
7  the terms of the GNU Lesser General Public License version 2.1 as published
8  by the Free Software Foundation, with special exception defined in the file
9  OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
10  distribution for complete text of the license and disclaimer of any warranty.
11
12  Alternatively, this file may be used under the terms of Open CASCADE
13  commercial license or contractual agreement.
14 */ 
15
16 %token STEP HEADER ENDSEC DATA ENDSTEP SCOPE ENDSCOPE ENTITY TYPE INTEGER FLOAT IDENT TEXT NONDEF ENUM HEXA QUID
17 %start stepf
18 %{
19 #include "recfile.ph"           /* definitions des types d'arguments */
20 #include "recfile.pc"           /* la-dedans, tout y est */
21 /*
22 #define stepparse STEPparse
23 #define steplex STEPlex
24 #define stepwrap STEPwrap
25 #define steprestart STEPrestart
26 #define steplex STEPlex
27 #define steplval STEPlval
28 #define stepval STEPval
29 #define stepchar STEPchar
30 #define stepdebug STEPdebug
31 #define stepnerrs STEPnerrs
32 #define steperror STEPerror
33 */
34 #define stepclearin yychar = -1
35 #define steperrok yyerrflag = 0
36
37 /*
38 #define stepin STEPin
39 #define yyerrflag STEPerrflag
40 #define yyerrstatus STEPerrflag
41 */
42
43 /* ABV 19.12.00: merging porting modifications by POP (for WNT, AIX) */
44 #if defined(WNT) && !defined(MSDOS)
45 #define MSDOS WNT
46 #endif
47 #if defined(_AIX)
48 #include <malloc.h>
49 #define alloca malloc
50 #endif
51
52
53 // disable MSVC warnings in bison code
54 #ifdef _MSC_VER
55 #pragma warning(disable:4244 4131 4127 4702)
56 #endif
57
58 %}
59 %%
60 /*  N.B. : les commentaires sont filtres par LEX  */
61 /*  La fin vide (selon systeme emetteur) est filtree ici  */
62 finvide : ' '
63         | finvide ' ' ;
64 finstep : ENDSTEP
65         | ENDSTEP finvide ;
66 stepf1  : STEP HEADER headl ENDSEC endhead model ENDSEC finstep ;
67 stepf2  : STEP HEADER ENDSEC endhead model ENDSEC ENDSTEP ;
68 stepf3  : STEP HEADER ENDSEC endhead model error ;
69 stepf   : stepf1 | stepf2 | stepf3
70                 {  rec_finfile();  return(0);  /*  fini pour celui-la  */  }
71         ;
72 headl   : headent
73         | headl headent
74         ;
75 headent : enttype listarg ';'
76         | error                         /*  Erreur sur Entite : la sauter  */
77         ;
78 endhead : DATA
79         {  rec_finhead();  }
80         ;
81 unarg   : IDENT         {  rec_typarg(rec_argIdent);     rec_newarg();  }
82         | QUID          {  /* deja fait par lex*/        rec_newarg();  }
83         | listarg       /*  rec_newent lors du ')' */ {  rec_newarg();  }
84         | listype listarg  /*  liste typee  */        {  rec_newarg();  }
85         | error         {  rec_typarg(rec_argMisc);      rec_newarg();
86                            yyerrstatus = 1; yyclearin;  }
87 /*  Erreur sur Parametre : tacher de le noter sans jeter l'Entite  */
88         ;
89 listype : TYPE
90         {  rec_listype();  }
91         ;
92 deblist : '('
93         {  rec_deblist();  }
94         ;
95 finlist : ')'
96         {  if (modeprint > 0)
97                 {  printf("Record no : %d -- ",nbrec+1);  rec_print(currec);  }
98            rec_newent ();  yyerrstatus = 0; }
99         ;
100 listarg : deblist finlist               /* liste vide (peut y en avoir) */
101         | deblist arglist finlist       /* liste normale, non vide */
102         | deblist error
103         ;
104 arglist : unarg
105         | arglist ',' unarg
106         | arglist error
107         ;
108 model   : bloc
109         | model bloc
110         ;
111 bloc    : entlab '=' unent ';'
112         | entlab '=' debscop model finscop unent ';'
113         | entlab '=' debscop finscop unent ';'
114         | error                         /*  Erreur sur Entite : la sauter  */
115         ;
116 plex    : enttype listarg
117         | plex enttype listarg          /*    sert a ce qui suit :     */
118         ;
119 unent   : enttype listarg               /*    Entite de Type Simple    */
120         | '(' plex ')'                  /*    Entite de Type Complexe  */
121         ;
122 debscop : SCOPE
123         {  scope_debut();  }
124         ;
125 unid    : IDENT
126         {  rec_typarg(rec_argIdent);    rec_newarg();  }
127         ;
128 export  : unid
129         | export ',' unid
130         ;
131 debexp  : '/'
132         {  rec_deblist();  }
133         ;
134 finscop : ENDSCOPE
135         {  scope_fin();  }
136         | ENDSCOPE debexp export '/'
137         {  printf("***  Warning : Export List not yet processed\n");
138            rec_newent();  scope_fin() ; }
139                 /*  La liste Export est prise comme ARGUMENT du EndScope  */
140         ;
141 entlab  : ENTITY
142         {  rec_ident();  }
143         ;
144 enttype : TYPE
145         {  rec_type ();  }
146         ;