3 * lexer for parsing cfg source files
8 /* enlarge token buffer to tokenize whole strings */
12 /* to enable debug output define LEXDEBUG */
15 #define OUTPUT fprintf
17 #define OUTPUT(Par1,Par2);
20 /* table of possible token ids */
26 #pragma GCC system_header
27 #elif defined __SINPRO_CC
29 #elif defined _MSC_VER
30 #pragma warning(push, 1)
33 /* external functions (C++ code, declared as extren "C" */
34 extern int WorkOnTokenSet( int, char* );
35 extern int InitCfgExport( char * , char *);
36 extern int EndCfgExport();
37 extern int GetError();
38 extern int SetError();
39 extern char *GetOutputFile( int argc, char* argv[]);
40 extern FILE *GetCfgFile();
42 extern void removeTempFile();
43 extern char* getFilename();
56 \<[^\>]*"xml:lang="\""x-no-translate"\"[^\<]*\/\> {
58 WorkOnTokenSet( CFG_TOKEN_NO_TRANSLATE, yytext );
63 WorkOnTokenSet( ANYTOKEN, yytext );
66 \<[^\>]*"xml:lang="\".*\"[^\<]*\> {
68 WorkOnTokenSet( CFG_TEXT_START, yytext );
74 WorkOnTokenSet( CFG_TAG, yytext );
79 WorkOnTokenSet( CFG_TAG, yytext );
84 char c1 = 0, c2 = 0, c3 = input();
89 WorkOnTokenSet( COMMEND, yytext );
90 WorkOnTokenSet( COMMEND, pChar );
95 if ( c1 == '-' && c2 == '-' && c3 == '>' )
101 WorkOnTokenSet( COMMEND, pChar );
107 WorkOnTokenSet( CFG_CLOSETAG, yytext );
112 if ( yytext[ 1 ] == '!' && yytext[ 2 ] == '-' && yytext[ 3 ] == '-' )
113 WorkOnTokenSet( COMMEND, yytext );
115 WorkOnTokenSet( CFG_UNKNOWNTAG, yytext );
120 WorkOnTokenSet( CFG_TEXTCHAR, yytext );
122 WorkOnTokenSet( UNKNOWNCHAR, yytext );
128 /*****************************************************************************/
130 /*****************************************************************************/
135 /*****************************************************************************/
136 void YYWarning( char *s )
137 /*****************************************************************************/
139 /* write warning to stderr */
141 "Warning: \"%s\" in line %d: \"%s\"\n", s, yylineno, yytext );
144 /*****************************************************************************/
146 void yyerror ( char *s, ... )
148 void yyerror ( char *s )
150 /*****************************************************************************/
152 /* write error to stderr */
154 "Error: \"%s\" in line %d: \"%s\"\n", s, yylineno, yytext );
158 /*****************************************************************************/
163 main( int argc, char* argv[])
164 /*****************************************************************************/
171 pOutput = GetOutputFile( argc, argv );
173 fprintf( stdout, "\nCfgEx 0.9 Copyright 2000 Sun Microsystems, Inc. All Rights Reserved.\n" );
174 fprintf( stdout, "======================================================================\n" );
178 fprintf( stdout, "Syntax: CFGEX[-p Prj][-r PrjRoot]-i FileIn [-o FileOut][-m DataBase][-e][-b][-u][-f][-d DoneFile][-g[:dtd] ][-L l1,l2,...]\n" );
179 fprintf( stdout, " Prj: Project\n" );
180 fprintf( stdout, " PrjRoot: Path to project root (..\\.. etc.)\n" );
181 fprintf( stdout, " FileIn: Source files (*.src)\n" );
182 fprintf( stdout, " FileOut: Destination file (*.*)\n" );
183 fprintf( stdout, " DataBase: Mergedata (*.sdf)\n" );
184 fprintf( stdout, " -QQ: quiet output\n" );
185 fprintf( stdout, " -e: Disable writing errorlog\n" );
186 fprintf( stdout, " -b: Break when Token \"HelpText\" found in source\n" );
187 fprintf( stdout, " -u: [english] and [german] are allowed, Id is Taken from DataBase \n" );
188 fprintf( stdout, " -f: force extraction and merge even if only one language is existent\n" );
189 fprintf( stdout, " -g[:dtd]: enables generation of properties (dtds if :dtd is set) - in this case FileOut is the output path\n" );
190 fprintf( stdout, " -d: enables generation of *.don if work is done\n" );
191 fprintf( stdout, " -L: Restrict the handled languages. l1,l2,... are elements of (de,en-US...)\n" );
192 fprintf( stdout, " A fallback language can be defined like this: l1=f1.\n" );
193 fprintf( stdout, " f1, f2,... are also elements of (de,en-US...)\n" );
194 fprintf( stdout, " Example: -L de,es=en-US\n" );
195 fprintf( stdout, " Restriction to de and es, en-US will be fallback for es\n" );
199 pFile = GetCfgFile();
200 InitCfgExport( pOutput , getFilename() );
206 /* create global instance of class CfgExport */
207 //InitCfgExport( pOutput );
212 /* get error info. and end export */
213 nRetValue = GetError();
217 fprintf( stdout, "\n===================================\n\n" );
221 /* return error level */
225 /*"<!--"[^"-->"]*"-->" {
227 WorkOnTokenSet( COMMEND, yytext );
231 WorkOnTokenSet( CFG_TAG, yytext );