89d6b670836f952ee1e3e29c24c4e2289343d042
[occt.git] / src / StepFile / step.lex
1 /* 
2  Copyright (c) 1999-2012 OPEN CASCADE SAS
3
4  The content of this file is subject to the Open CASCADE Technology Public
5  License Version 6.5 (the "License"). You may not use the content of this file
6  except in compliance with the License. Please obtain a copy of the License
7  at http://www.opencascade.org and read it completely before using this file.
8
9  The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
10  main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
11
12  The Original Code and all software distributed under the License is
13  distributed on an "AS IS" basis, without warranty of any kind, and the
14  Initial Developer hereby disclaims all such warranties, including without
15  limitation, any warranties of merchantability, fitness for a particular
16  purpose or non-infringement. Please see the License for the specific terms
17  and conditions governing the rights and limitations under the License.
18
19 */ 
20
21 %{
22 #include "step.tab.h"
23 #include "recfile.ph"
24 #include "stdio.h"
25 #include <StepFile_CallFailure.hxx>
26
27 /* skl 31.01.2002 for OCC133(OCC96,97) - uncorrect
28 long string in files Henri.stp and 401.stp*/
29 #define YY_FATAL_ERROR(msg) StepFile_CallFailure( msg )
30
31 /* abv 07.06.02: force inclusion of stdlib.h on WNT to avoid warnings */
32 #include <stdlib.h>
33
34 /*
35 void steperror ( FILE *input_file );
36 void steprestart ( FILE *input_file );
37 */
38 void rec_restext(char *newtext, int lentext);
39 void rec_typarg(int argtype);
40  
41   int  steplineno;      /* Comptage de ligne (ben oui, fait tout faire)  */
42
43   int  modcom = 0;      /* Commentaires type C */
44   int  modend = 0;      /* Flag for finishing of the STEP file */
45   void resultat ()           /* Resultat alloue dynamiquement, "jete" une fois lu */
46       { if (modcom == 0) rec_restext(yytext,yyleng); }
47
48 // disable MSVC warnings in flex code
49 #ifdef _MSC_VER
50 #pragma warning(disable:4131 4244 4273 4267 4127)
51 #endif
52
53 %}
54 %%
55 "       "       {;}
56 " "             {;}
57 [\n]            { steplineno ++; }
58 [\r]            {;} /* abv 30.06.00: for reading DOS files */
59 [\0]+           {;} /* fix from C21. for test load e3i file with line 15 with null symbols */
60
61 #[0-9]+/=               { resultat();  if (modcom == 0) return(ENTITY); }
62 #[0-9]+/[       ]*=     { resultat();  if (modcom == 0) return(ENTITY); }
63 #[0-9]+         { resultat();  if (modcom == 0) return(IDENT); }
64 [-+0-9][0-9]*   { resultat();  if (modcom == 0) { rec_typarg(rec_argInteger); return(QUID); } }
65 [-+\.0-9][\.0-9]+       { resultat();  if (modcom == 0) { rec_typarg(rec_argFloat); return(QUID); } }
66 [-+\.0-9][\.0-9]+E[-+0-9][0-9]* { resultat(); if (modcom == 0) { rec_typarg(rec_argFloat); return(QUID); } }
67 [\']([\n]|[\000\011-\046\050-\176\201-\237\240-\777]|[\047][\047])*[\'] { resultat(); if (modcom == 0) { rec_typarg(rec_argText); return(QUID); } }
68 ["][0-9A-F]+["]         { resultat();  if (modcom == 0) { rec_typarg(rec_argHexa); return(QUID); } }
69 [.][A-Z0-9_]+[.]        { resultat();  if (modcom == 0) { rec_typarg(rec_argEnum); return(QUID); } }
70 [(]             { if (modcom == 0) return ('('); }
71 [)]             { if (modcom == 0) return (')'); }
72 [,]             { if (modcom == 0) return (','); }
73 [$]             { resultat();  if (modcom == 0) { rec_typarg(rec_argNondef); return(QUID); } }
74 [=]             { if (modcom == 0) return ('='); }
75 [;]             { if (modcom == 0) return (';'); }
76 "/*"            { modcom = 1;  }
77 "*/"            { if (modend == 0) modcom = 0;  }
78
79 STEP;           { if (modcom == 0) return(STEP); }
80 HEADER;         { if (modcom == 0) return(HEADER); }
81 ENDSEC;         { if (modcom == 0) return(ENDSEC); }
82 DATA;           { if (modcom == 0) return(DATA); }
83 ENDSTEP;        { if (modend == 0) {modcom = 0;  return(ENDSTEP);} }
84 "ENDSTEP;".*    { if (modend == 0) {modcom = 0;  return(ENDSTEP);} }
85 END-ISO[0-9\-]*; { modcom = 1; modend = 1; return(ENDSTEP); }
86 ISO[0-9\-]*;    { if (modend == 0) {modcom = 0;  return(STEP); } }
87
88 [/]             { if (modcom == 0) return ('/'); }
89 &SCOPE          { if (modcom == 0) return(SCOPE); }
90 ENDSCOPE        { if (modcom == 0) return(ENDSCOPE); }
91 [a-zA-Z0-9_]+   { resultat();  if (modcom == 0) return(TYPE); }
92 ![a-zA-Z0-9_]+  { resultat();  if (modcom == 0) return(TYPE); }
93 [^)]            { resultat();  if (modcom == 0) { rec_typarg(rec_argMisc); return(QUID); } }