2 Copyright (c) 1999-2014 OPEN CASCADE SAS
4 This file is part of Open CASCADE Technology software library.
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.
12 Alternatively, this file may be used under the terms of Open CASCADE
13 commercial license or contractual agreement.
17 c++ generate C++ parser class
18 8bit don't fail on 8-bit input characters
19 warn warn about inconsistencies
20 nodefault don't create default echo-all rule
21 noyywrap don't use yywrap() function
22 yyclass define name of the scanner class
25 %option 8bit warn nodefault
27 %option yyclass="step::scanner"
30 // This file is part of Open CASCADE Technology software library.
31 // This file is generated, do not modify it directly; edit source file step.lex instead.
33 // Pre-include stdlib.h to avoid redefinition of integer type macros (INT8_MIN and similar in generated code)
34 #if !defined(_MSC_VER) || (_MSC_VER >= 1600) // Visual Studio 2010+
40 #include <step.tab.hxx>
43 // Tell flex which function to define
47 #define YY_DECL int step::scanner::lex (step::parser::semantic_type* /*yylval*/, step::parser::location_type* /*yylloc*/)
49 typedef step::parser::token token;
51 /* skl 31.01.2002 for OCC133(OCC96,97) - uncorrect
52 long string in files Henri.stp and 401.stp*/
53 #include <Standard_Failure.hxx>
54 #define YY_FATAL_ERROR(msg) Standard_Failure::Raise(msg);
56 /* abv 07.06.02: force inclusion of stdlib.h on WNT to avoid warnings */
58 // add includes for flex 2.91 (Linux version)
62 // Avoid includion of unistd.h if parser is generated on Linux (flex 2.5.35)
63 #ifndef YY_NO_UNISTD_H
64 #define YY_NO_UNISTD_H
67 // disable MSVC warnings in flex 2.89 and 2.5.35 code
68 // Note that Intel compiler also defines _MSC_VER but has different warning ids
69 #if defined(__INTEL_COMPILER)
70 #pragma warning(disable:177 1786 1736)
71 #elif defined(__clang__)
72 #pragma GCC diagnostic ignored "-Wunused-function"
73 #pragma GCC diagnostic ignored "-Winconsistent-dllimport"
74 #pragma GCC diagnostic ignored "-Wunneeded-internal-declaration"
76 #pragma warning(disable:4131 4244 4273 4127 4267)
81 #define CreateNewText myDataModel->CreateNewText
82 #define SetTypeArg myDataModel->SetTypeArg
84 // disable GCC warnings in flex code
86 #pragma GCC diagnostic ignored "-Wunused-function"
88 #pragma GCC diagnostic ignored "-Wmisleading-indentation"
94 "/*" { BEGIN(Com); } /* start of comment - put the scanner in the "Com" state */
95 <Com>[^*\n]* {;} /* in comment, skip any characters except asterisk (and newline, handled by its own rule) */
96 <Com>[*]+[^*/\n]* {;} /* in comment, skip any sequence of asterisks followed by other symbols (except slash or newline) */
97 <Com>[*]+[/] { BEGIN(INITIAL); } /* end of comment - reset the scanner to initial state */
99 ['] { BEGIN(Text); yymore(); } /* start of quoted text string - put the scanner in the "Text" state, but keep ' as part of yytext */
100 <Text>[\n] { yymore(); yylineno ++; } /* newline in text string - increment line counter and keep collecting yytext */
101 <Text>['] { yymore(); } /* single ' inside text string - keep collecting yytext*/
102 <Text>[^\n']+ { yymore(); } /* a sequence of any characters except ' and \n - keep collecting yytext */
103 <Text>[']/[" "\n\r]*[\)\,] { BEGIN(INITIAL); CreateNewText(YYText(),YYLeng()); SetTypeArg(ArgumentType_Text); return(token::QUID); } /* end of string (apostrophe followed by comma or closing parenthesis) - reset the scanner to initial state, record the value of all yytext collected */
107 <*>[\n] { yylineno ++; } /* count lines (one rule for all start conditions) */
108 [\r] {;} /* abv 30.06.00: for reading DOS files */
109 [\0]+ {;} /* fix from C21. for test load e3i file with line 15 with null symbols */
111 #[0-9]+/= { CreateNewText(YYText(),YYLeng()); return(token::ENTITY); }
112 #[0-9]+/[ ]*= { CreateNewText(YYText(),YYLeng()); return(token::ENTITY); }
113 #[0-9]+ { CreateNewText(YYText(),YYLeng()); return(token::IDENT); }
114 [-+0-9][0-9]* { CreateNewText(YYText(),YYLeng()); SetTypeArg(ArgumentType_Integer); return(token::QUID); }
115 [-+\.0-9][\.0-9]+ { CreateNewText(YYText(),YYLeng()); SetTypeArg(ArgumentType_Float); return(token::QUID); }
116 [-+\.0-9][\.0-9]+E[-+0-9][0-9]* { CreateNewText(YYText(),YYLeng()); SetTypeArg(ArgumentType_Float); return(token::QUID); }
117 ["][0-9A-F]+["] { CreateNewText(YYText(),YYLeng()); SetTypeArg(ArgumentType_Hexa); return(token::QUID); }
118 [.]*[A-Z0-9_]+[.] { CreateNewText(YYText(),YYLeng()); SetTypeArg(ArgumentType_Enum); return(token::QUID); }
119 [(] { return ('('); }
120 [)] { return (')'); }
121 [,] { myDataModel->PrepareNewArg(); return (','); }
122 [$] { CreateNewText(YYText(),YYLeng()); SetTypeArg(ArgumentType_Nondef); return(token::QUID); }
123 [=] { return ('='); }
124 [;] { return (';'); }
126 (?i:STEP); { return(token::STEP); }
127 (?i:HEADER); { return(token::HEADER); }
128 (?i:ENDSEC); { return(token::ENDSEC); }
129 (?i:DATA); { return(token::DATA); }
130 (?i:ENDSTEP); { return(token::ENDSTEP);}
131 (?i:ENDSTEP);.* { return(token::ENDSTEP);}
132 (?i:END-ISO)[0-9\-]*; { BEGIN(End); return(token::ENDSTEP); } /* at the end of the STEP data, enter dedicated start condition "End" to skip everything that follows */
133 (?i:ISO)[0-9\-]*; { return(token::STEP); }
135 [/] { return ('/'); }
136 &(?i:SCOPE) { return(token::SCOPE); }
137 (?i:ENDSCOPE) { return(token::ENDSCOPE); }
138 [a-zA-Z0-9_]+ { CreateNewText(YYText(),YYLeng()); return(token::TYPE); }
139 ![a-zA-Z0-9_]+ { CreateNewText(YYText(),YYLeng()); return(token::TYPE); }
140 [^)] { CreateNewText(YYText(),YYLeng()); SetTypeArg(ArgumentType_Misc); return(token::QUID); }
142 <End>[^\n] {;} /* skip any characters (except newlines) */
146 step::scanner::scanner(StepFile_ReadData* theDataModel, std::istream* in, std::ostream* out)
147 : stepFlexLexer(in, out), myDataModel(theDataModel)