0031740: Configuration - recover support of Yacc and Lex generation
[occt.git] / src / StepFile / step.lex
CommitLineData
b311480e 1/*
973c2be1 2 Copyright (c) 1999-2014 OPEN CASCADE SAS
b311480e 3
973c2be1 4 This file is part of Open CASCADE Technology software library.
b311480e 5
d5f74e42 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
973c2be1 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.
b311480e 11
973c2be1 12 Alternatively, this file may be used under the terms of Open CASCADE
13 commercial license or contractual agreement.
b311480e 14*/
15
7fd59977 16%{
17#include "step.tab.h"
18#include "recfile.ph"
19#include "stdio.h"
20#include <StepFile_CallFailure.hxx>
21
22/* skl 31.01.2002 for OCC133(OCC96,97) - uncorrect
23long string in files Henri.stp and 401.stp*/
24#define YY_FATAL_ERROR(msg) StepFile_CallFailure( msg )
25
26/* abv 07.06.02: force inclusion of stdlib.h on WNT to avoid warnings */
fba34cf8 27#ifdef _MSC_VER
28// add includes for flex 2.91 (Linux version)
7fd59977 29#include <stdlib.h>
fba34cf8 30#include <io.h>
31
32// Avoid includion of unistd.h if parser is generated on Linux (flex 2.5.35)
33#ifndef YY_NO_UNISTD_H
34#define YY_NO_UNISTD_H
35#endif
36
37// disable MSVC warnings in flex 2.89 and 2.5.35 code
38// Note that Intel compiler also defines _MSC_VER but has different warning ids
39#if defined(__INTEL_COMPILER)
40#pragma warning(disable:177 1786 1736)
41#elif defined(__clang__)
42#pragma GCC diagnostic ignored "-Wunused-function"
43#pragma GCC diagnostic ignored "-Winconsistent-dllimport"
44#pragma GCC diagnostic ignored "-Wunneeded-internal-declaration"
45#else
46#pragma warning(disable:4131 4244 4273 4127 4267)
47#endif
48
49#endif /* MSC_VER */
7fd59977 50
51/*
52void steperror ( FILE *input_file );
53void steprestart ( FILE *input_file );
54*/
55void rec_restext(char *newtext, int lentext);
56void rec_typarg(int argtype);
57
58 int steplineno; /* Comptage de ligne (ben oui, fait tout faire) */
59
60 int modcom = 0; /* Commentaires type C */
61 int modend = 0; /* Flag for finishing of the STEP file */
62 void resultat () /* Resultat alloue dynamiquement, "jete" une fois lu */
63 { if (modcom == 0) rec_restext(yytext,yyleng); }
64
566f8441 65// disable GCC warnings in flex code
66#ifdef __GNUC__
67#pragma GCC diagnostic ignored "-Wunused-function"
68#endif
69
7fd59977 70%}
71%%
72" " {;}
73" " {;}
74[\n] { steplineno ++; }
75[\r] {;} /* abv 30.06.00: for reading DOS files */
76[\0]+ {;} /* fix from C21. for test load e3i file with line 15 with null symbols */
77
78#[0-9]+/= { resultat(); if (modcom == 0) return(ENTITY); }
79#[0-9]+/[ ]*= { resultat(); if (modcom == 0) return(ENTITY); }
80#[0-9]+ { resultat(); if (modcom == 0) return(IDENT); }
81[-+0-9][0-9]* { resultat(); if (modcom == 0) { rec_typarg(rec_argInteger); return(QUID); } }
82[-+\.0-9][\.0-9]+ { resultat(); if (modcom == 0) { rec_typarg(rec_argFloat); return(QUID); } }
83[-+\.0-9][\.0-9]+E[-+0-9][0-9]* { resultat(); if (modcom == 0) { rec_typarg(rec_argFloat); return(QUID); } }
84[\']([\n]|[\000\011-\046\050-\176\201-\237\240-\777]|[\047][\047])*[\'] { resultat(); if (modcom == 0) { rec_typarg(rec_argText); return(QUID); } }
85["][0-9A-F]+["] { resultat(); if (modcom == 0) { rec_typarg(rec_argHexa); return(QUID); } }
86[.][A-Z0-9_]+[.] { resultat(); if (modcom == 0) { rec_typarg(rec_argEnum); return(QUID); } }
87[(] { if (modcom == 0) return ('('); }
88[)] { if (modcom == 0) return (')'); }
89[,] { if (modcom == 0) return (','); }
90[$] { resultat(); if (modcom == 0) { rec_typarg(rec_argNondef); return(QUID); } }
91[=] { if (modcom == 0) return ('='); }
92[;] { if (modcom == 0) return (';'); }
93"/*" { modcom = 1; }
94"*/" { if (modend == 0) modcom = 0; }
95
96STEP; { if (modcom == 0) return(STEP); }
97HEADER; { if (modcom == 0) return(HEADER); }
98ENDSEC; { if (modcom == 0) return(ENDSEC); }
99DATA; { if (modcom == 0) return(DATA); }
100ENDSTEP; { if (modend == 0) {modcom = 0; return(ENDSTEP);} }
101"ENDSTEP;".* { if (modend == 0) {modcom = 0; return(ENDSTEP);} }
102END-ISO[0-9\-]*; { modcom = 1; modend = 1; return(ENDSTEP); }
103ISO[0-9\-]*; { if (modend == 0) {modcom = 0; return(STEP); } }
104
105[/] { if (modcom == 0) return ('/'); }
106&SCOPE { if (modcom == 0) return(SCOPE); }
107ENDSCOPE { if (modcom == 0) return(ENDSCOPE); }
108[a-zA-Z0-9_]+ { resultat(); if (modcom == 0) return(TYPE); }
109![a-zA-Z0-9_]+ { resultat(); if (modcom == 0) return(TYPE); }
110[^)] { resultat(); if (modcom == 0) { rec_typarg(rec_argMisc); return(QUID); } }