3 * lexer for parsing xml-property source files (*.xml)
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)
38 /* external functions (C++ code, declared as extern "C" */
39 extern "C" int WorkOnTokenSet( int, char* );
40 extern "C" int Argument( char * );
41 extern "C" int InitXrmExport( char * , char * );
42 extern "C" int EndXrmExport();
43 extern "C" int GetError();
44 extern "C" int SetError();
45 extern "C" char *GetOutputFile( int argc, char* argv[]);
46 extern "C" FILE *GetXrmFile();
47 extern "C" int isQuiet();
48 extern "C" char* getFilename();
57 %option never-interactive
65 "<p "[^\>]*xml:lang[^\>]*\> {
66 WorkOnTokenSet( XRM_TEXT_START , yytext );
70 WorkOnTokenSet( XRM_TEXT_END, yytext );
73 "<h1 "[^\>]*xml:lang[^\>]*\> {
74 WorkOnTokenSet( XRM_TEXT_START , yytext );
78 WorkOnTokenSet( XRM_TEXT_END, yytext );
80 "<h2 "[^\>]*xml:lang[^\>]*\> {
81 WorkOnTokenSet( XRM_TEXT_START , yytext );
85 WorkOnTokenSet( XRM_TEXT_END, yytext );
87 "<h3 "[^\>]*xml:lang[^\>]*\> {
88 WorkOnTokenSet( XRM_TEXT_START , yytext );
92 WorkOnTokenSet( XRM_TEXT_END, yytext );
94 "<h4 "[^\>]*xml:lang[^\>]*\> {
95 WorkOnTokenSet( XRM_TEXT_START , yytext );
99 WorkOnTokenSet( XRM_TEXT_END, yytext );
101 "<h5 "[^\>]*xml:lang[^\>]*\> {
102 WorkOnTokenSet( XRM_TEXT_START , yytext );
106 WorkOnTokenSet( XRM_TEXT_END, yytext );
110 WorkOnTokenSet( DESC_DISPLAY_NAME_START , yytext );
114 WorkOnTokenSet( DESC_DISPLAY_NAME_END, yytext );
117 "<name "[^\>]*lang[^\>]*\> {
118 WorkOnTokenSet( DESC_TEXT_START , yytext );
122 WorkOnTokenSet( DESC_TEXT_END, yytext );
125 "<extension-description>" {
126 WorkOnTokenSet( DESC_EXTENSION_DESCRIPTION_START , yytext );
129 "</extension-description>" {
130 WorkOnTokenSet( DESC_EXTENSION_DESCRIPTION_END , yytext );
133 "<src "[^\>]*lang[^\>]*\> {
134 WorkOnTokenSet( DESC_EXTENSION_DESCRIPTION_SRC , yytext );
140 char c1 = 0, c2 = 0, c3 = yyinput();
145 WorkOnTokenSet( COMMEND, yytext );
146 WorkOnTokenSet( COMMEND, pChar );
151 if ( c1 == '-' && c2 == '-' && c3 == '>' )
157 WorkOnTokenSet( COMMEND, pChar );
163 WorkOnTokenSet( XML_TEXTCHAR, yytext );
165 WorkOnTokenSet( UNKNOWNCHAR, yytext );
171 /*****************************************************************************/
173 /*****************************************************************************/
178 /*****************************************************************************/
179 void YYWarning( const char *s )
180 /*****************************************************************************/
182 /* write warning to stderr */
184 "Warning: \"%s\" in line %d: \"%s\"\n", s, yylineno, yytext );
187 /*****************************************************************************/
188 void yyerror ( const char *s )
189 /*****************************************************************************/
191 /* write error to stderr */
193 "Error: \"%s\" in line %d: \"%s\"\n", s, yylineno, yytext );
197 SAL_IMPLEMENT_MAIN_WITH_ARGS(argc, argv) {
203 pOutput = GetOutputFile( argc, argv );
206 fprintf( stdout, "Syntax: XRMEX[-p Prj][-r PrjRoot]-i FileIn [-o FileOut][-m DataBase][-e][-b][-u][-NOUTF8][-L l1,l2,...]\n" );
207 fprintf( stdout, " Prj: Project\n" );
208 fprintf( stdout, " PrjRoot: Path to project root (..\\.. etc.)\n" );
209 fprintf( stdout, " FileIn: Source files (*.src)\n" );
210 fprintf( stdout, " FileOut: Destination file (*.*)\n" );
211 fprintf( stdout, " DataBase: Mergedata (*.sdf)\n" );
212 fprintf( stdout, " -e: Disable writing errorlog\n" );
213 fprintf( stdout, " -b: Break when Token \"HelpText\" found in source\n" );
214 fprintf( stdout, " -u: [english] and [german] are allowed, Id is Taken from DataBase \n" );
215 fprintf( stdout, " -NOUTF8: disable UTF8 as language independent encoding\n" );
216 fprintf( stdout, " -L: Restrict the handled languages. l1,l2,... are elements of (de,en-US,es...)\n" );
219 pFile = GetXrmFile();
220 InitXrmExport( pOutput , getFilename() );
227 /* create global instance of class XmlExport */
228 //InitXrmExport( pOutput );
233 /* get error info. and end export */
234 nRetValue = GetError();
237 /* return error level */