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 */
47 #pragma GCC diagnostic ignored "-Wunused-function"
48 #pragma GCC diagnostic ignored "-Wunused-label"
49 #pragma GCC diagnostic ignored "-Wunused-but-set-variable"
50 #elif defined _MSC_VER
51 #pragma warning(push, 1)
53 #define YY_NO_UNISTD_H
62 %option never-interactive
70 "<p "[^\>]*xml:lang[^\>]*\> {
71 WorkOnTokenSet( XRM_TEXT_START , yytext );
75 WorkOnTokenSet( XRM_TEXT_END, yytext );
78 "<h1 "[^\>]*xml:lang[^\>]*\> {
79 WorkOnTokenSet( XRM_TEXT_START , yytext );
83 WorkOnTokenSet( XRM_TEXT_END, yytext );
85 "<h2 "[^\>]*xml:lang[^\>]*\> {
86 WorkOnTokenSet( XRM_TEXT_START , yytext );
90 WorkOnTokenSet( XRM_TEXT_END, yytext );
92 "<h3 "[^\>]*xml:lang[^\>]*\> {
93 WorkOnTokenSet( XRM_TEXT_START , yytext );
97 WorkOnTokenSet( XRM_TEXT_END, yytext );
99 "<h4 "[^\>]*xml:lang[^\>]*\> {
100 WorkOnTokenSet( XRM_TEXT_START , yytext );
104 WorkOnTokenSet( XRM_TEXT_END, yytext );
106 "<h5 "[^\>]*xml:lang[^\>]*\> {
107 WorkOnTokenSet( XRM_TEXT_START , yytext );
111 WorkOnTokenSet( XRM_TEXT_END, yytext );
115 WorkOnTokenSet( DESC_DISPLAY_NAME_START , yytext );
119 WorkOnTokenSet( DESC_DISPLAY_NAME_END, yytext );
122 "<name "[^\>]*lang[^\>]*\> {
123 WorkOnTokenSet( DESC_TEXT_START , yytext );
127 WorkOnTokenSet( DESC_TEXT_END, yytext );
130 "<extension-description>" {
131 WorkOnTokenSet( DESC_EXTENSION_DESCRIPTION_START , yytext );
134 "</extension-description>" {
135 WorkOnTokenSet( DESC_EXTENSION_DESCRIPTION_END , yytext );
138 "<src "[^\>]*lang[^\>]*\> {
139 WorkOnTokenSet( DESC_EXTENSION_DESCRIPTION_SRC , yytext );
151 WorkOnTokenSet( COMMENT, yytext );
152 WorkOnTokenSet( COMMENT, pChar );
157 if ( c1 == '-' && c2 == '-' && c3 == '>' )
163 WorkOnTokenSet( COMMENT, pChar );
169 WorkOnTokenSet( XML_TEXTCHAR, yytext );
171 WorkOnTokenSet( UNKNOWNCHAR, yytext );
177 /*****************************************************************************/
179 /*****************************************************************************/
184 /*****************************************************************************/
185 void YYWarning( const char *s )
186 /*****************************************************************************/
188 /* write warning to stderr */
190 "Warning: \"%s\" in line %d: \"%s\"\n", s, yylineno, yytext );
193 /*****************************************************************************/
194 void yyerror ( const char *s )
195 /*****************************************************************************/
197 /* write error to stderr */
199 "Error: \"%s\" in line %d: \"%s\"\n", s, yylineno, yytext );
203 SAL_IMPLEMENT_MAIN_WITH_ARGS(argc, argv) {
208 if ( !GetOutputFile( argc, argv ) )
212 pFile = GetXrmFile();
213 InitXrmExport( getFilename() );
220 /* create global instance of class XmlExport */
221 //InitXrmExport( pOutput );
226 /* get error info. and end export */
227 nRetValue = GetError();
230 /* return error level */