3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
21 * lexer for parsing xml-property source files (*.xml)
24 #include "sal/config.h"
26 /* enlarge token buffer to tokenize whole strings */
30 /* to enable debug output define LEXDEBUG */
33 #define OUTPUT fprintf
35 #define OUTPUT(Par1,Par2);
38 /* table of possible token ids */
45 #if HAVE_GCC_PRAGMA_DIAGNOSTIC_MODIFY
46 #pragma GCC diagnostic ignored "-Wunused-function"
47 #pragma GCC diagnostic ignored "-Wunused-label"
48 #if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6))
49 #pragma GCC diagnostic ignored "-Wunused-but-set-variable"
51 #elif defined __SUNPRO_CC
53 #elif defined _MSC_VER
54 #pragma warning(push, 1)
56 #define YY_NO_UNISTD_H
58 /* external functions (C++ code, declared as extern "C" */
59 extern "C" int WorkOnTokenSet( int, char* );
60 extern "C" int Argument( char * );
61 extern "C" int InitXrmExport( char * , char * );
62 extern "C" int EndXrmExport();
63 extern "C" int GetError();
64 extern "C" int SetError();
65 extern "C" char *GetOutputFile( int argc, char* argv[]);
66 extern "C" FILE *GetXrmFile();
67 extern "C" int isQuiet();
68 extern "C" char* getFilename();
77 %option never-interactive
85 "<p "[^\>]*xml:lang[^\>]*\> {
86 WorkOnTokenSet( XRM_TEXT_START , yytext );
90 WorkOnTokenSet( XRM_TEXT_END, yytext );
93 "<h1 "[^\>]*xml:lang[^\>]*\> {
94 WorkOnTokenSet( XRM_TEXT_START , yytext );
98 WorkOnTokenSet( XRM_TEXT_END, yytext );
100 "<h2 "[^\>]*xml:lang[^\>]*\> {
101 WorkOnTokenSet( XRM_TEXT_START , yytext );
105 WorkOnTokenSet( XRM_TEXT_END, yytext );
107 "<h3 "[^\>]*xml:lang[^\>]*\> {
108 WorkOnTokenSet( XRM_TEXT_START , yytext );
112 WorkOnTokenSet( XRM_TEXT_END, yytext );
114 "<h4 "[^\>]*xml:lang[^\>]*\> {
115 WorkOnTokenSet( XRM_TEXT_START , yytext );
119 WorkOnTokenSet( XRM_TEXT_END, yytext );
121 "<h5 "[^\>]*xml:lang[^\>]*\> {
122 WorkOnTokenSet( XRM_TEXT_START , yytext );
126 WorkOnTokenSet( XRM_TEXT_END, yytext );
130 WorkOnTokenSet( DESC_DISPLAY_NAME_START , yytext );
134 WorkOnTokenSet( DESC_DISPLAY_NAME_END, yytext );
137 "<name "[^\>]*lang[^\>]*\> {
138 WorkOnTokenSet( DESC_TEXT_START , yytext );
142 WorkOnTokenSet( DESC_TEXT_END, yytext );
145 "<extension-description>" {
146 WorkOnTokenSet( DESC_EXTENSION_DESCRIPTION_START , yytext );
149 "</extension-description>" {
150 WorkOnTokenSet( DESC_EXTENSION_DESCRIPTION_END , yytext );
153 "<src "[^\>]*lang[^\>]*\> {
154 WorkOnTokenSet( DESC_EXTENSION_DESCRIPTION_SRC , yytext );
166 WorkOnTokenSet( COMMENT, yytext );
167 WorkOnTokenSet( COMMENT, pChar );
172 if ( c1 == '-' && c2 == '-' && c3 == '>' )
178 WorkOnTokenSet( COMMENT, pChar );
184 WorkOnTokenSet( XML_TEXTCHAR, yytext );
186 WorkOnTokenSet( UNKNOWNCHAR, yytext );
192 /*****************************************************************************/
194 /*****************************************************************************/
199 /*****************************************************************************/
200 void YYWarning( const char *s )
201 /*****************************************************************************/
203 /* write warning to stderr */
205 "Warning: \"%s\" in line %d: \"%s\"\n", s, yylineno, yytext );
208 /*****************************************************************************/
209 void yyerror ( const char *s )
210 /*****************************************************************************/
212 /* write error to stderr */
214 "Error: \"%s\" in line %d: \"%s\"\n", s, yylineno, yytext );
218 SAL_IMPLEMENT_MAIN_WITH_ARGS(argc, argv) {
224 pOutput = GetOutputFile( argc, argv );
230 pFile = GetXrmFile();
231 InitXrmExport( pOutput , getFilename() );
238 /* create global instance of class XmlExport */
239 //InitXrmExport( pOutput );
244 /* get error info. and end export */
245 nRetValue = GetError();
248 /* return error level */