3 * lexer for parsing cfg source files
7 /* enlarge token buffer to tokenize whole strings */
11 /* to enable debug output define LEXDEBUG */
14 #define OUTPUT fprintf
16 #define OUTPUT(Par1,Par2);
19 /* table of possible token ids */
27 #if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 2))
28 #pragma GCC diagnostic ignored "-Wunused-function"
29 #pragma GCC diagnostic ignored "-Wunused-label"
30 #pragma GCC diagnostic ignored "-Wunused-but-set-variable"
32 #elif defined __SINPRO_CC
34 #elif defined _MSC_VER
35 #pragma warning(push, 1)
39 #define YY_USER_ACTION yycolumn += yyleng;
41 /* external functions (C++ code, declared as extern "C" */
42 extern "C" void workOnTokenSet( int, char* );
43 extern "C" FILE * init(int, char **);
49 %option never-interactive
57 \<[^\>]*"xml:lang="\""x-no-translate"\"[^\<]*\/\> {
59 workOnTokenSet( CFG_TOKEN_NO_TRANSLATE, yytext );
64 workOnTokenSet( ANYTOKEN, yytext );
67 \<[^\>]*"xml:lang="\".*\"[^\<]*\> {
69 workOnTokenSet( CFG_TEXT_START, yytext );
75 workOnTokenSet( CFG_TAG, yytext );
80 workOnTokenSet( CFG_TAG, yytext );
85 char c1 = 0, c2 = 0, c3 = yyinput();
90 workOnTokenSet( COMMEND, yytext );
91 workOnTokenSet( COMMEND, pChar );
96 if ( c1 == '-' && c2 == '-' && c3 == '>' )
103 workOnTokenSet( COMMEND, pChar );
109 workOnTokenSet( CFG_CLOSETAG, yytext );
114 if ( yytext[ 1 ] == '!' && yytext[ 2 ] == '-' && yytext[ 3 ] == '-' )
115 workOnTokenSet( COMMEND, yytext );
117 workOnTokenSet( CFG_UNKNOWNTAG, yytext );
123 workOnTokenSet( CFG_TEXTCHAR, yytext );
125 workOnTokenSet( UNKNOWNCHAR, yytext );
131 /*****************************************************************************/
133 /*****************************************************************************/
138 /*****************************************************************************/
139 void YYWarning( const char *s )
140 /*****************************************************************************/
142 /* write warning to stderr */
144 "Warning: \"%s\" in line %d, column %d: \"%s\"\n", s, yylineno, yycolumn, yytext );
147 /*****************************************************************************/
148 void yyerror ( const char *s )
149 /*****************************************************************************/
151 /* write error to stderr */
153 "Error: \"%s\" in line %d, column %d: \"%s\"\n", s, yylineno, yycolumn, yytext );
157 SAL_IMPLEMENT_MAIN_WITH_ARGS(argc, argv) {
158 yyin = init(argc, argv);