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 cfg source files
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
59 #define YY_USER_ACTION yycolumn += yyleng;
61 /* external functions (C++ code, declared as extern "C" */
62 extern "C" void workOnTokenSet( int, char* );
63 extern "C" FILE * init(int, char **);
69 %option never-interactive
77 \<[^\>]*"xml:lang="\""x-no-translate"\"[^\<]*\/\> {
79 workOnTokenSet( CFG_TOKEN_NO_TRANSLATE, yytext );
84 workOnTokenSet( ANYTOKEN, yytext );
87 \<[^\>]*"xml:lang="\".*\"[^\<]*\> {
89 workOnTokenSet( CFG_TEXT_START, yytext );
95 workOnTokenSet( CFG_TAG, yytext );
100 workOnTokenSet( CFG_TAG, yytext );
111 workOnTokenSet( COMMENT, yytext );
112 workOnTokenSet( COMMENT, pChar );
117 if ( c1 == '-' && c2 == '-' && c3 == '>' )
124 workOnTokenSet( COMMENT, pChar );
130 workOnTokenSet( CFG_CLOSETAG, yytext );
135 if ( yytext[ 1 ] == '!' && yytext[ 2 ] == '-' && yytext[ 3 ] == '-' )
136 workOnTokenSet( COMMENT, yytext );
138 workOnTokenSet( CFG_UNKNOWNTAG, yytext );
144 workOnTokenSet( CFG_TEXTCHAR, yytext );
146 workOnTokenSet( UNKNOWNCHAR, yytext );
152 /*****************************************************************************/
154 /*****************************************************************************/
159 /*****************************************************************************/
160 void YYWarning( const char *s )
161 /*****************************************************************************/
163 /* write warning to stderr */
165 "Warning: \"%s\" in line %d, column %d: \"%s\"\n", s, yylineno, yycolumn, yytext );
168 /*****************************************************************************/
169 void yyerror ( const char *s )
170 /*****************************************************************************/
172 /* write error to stderr */
174 "Error: \"%s\" in line %d, column %d: \"%s\"\n", s, yylineno, yycolumn, yytext );
178 SAL_IMPLEMENT_MAIN_WITH_ARGS(argc, argv) {
179 yyin = init(argc, argv);