1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
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 .
23 * lexer for parsing cfg source files
26 #include <sal/config.h>
28 /* enlarge token buffer to tokenize whole strings */
32 /* to enable debug output define LEXDEBUG */
35 #define OUTPUT fprintf
37 #define OUTPUT(Par1,Par2);
40 /* table of possible token ids */
49 #define YY_NO_UNISTD_H
51 static int yycolumn = 1;
52 #define YY_USER_ACTION yycolumn += yyleng;
59 %option never-interactive
67 \<[^\>]*"xml:lang="\""x-no-translate"\"[^\<]*\/\> {
69 workOnTokenSet( CFG_TOKEN_NO_TRANSLATE, yytext );
74 workOnTokenSet( ANYTOKEN, yytext );
77 \<[^\>]*"xml:lang="\".*\"[^\<]*\> {
79 workOnTokenSet( CFG_TEXT_START, yytext );
85 workOnTokenSet( CFG_TAG, yytext );
90 workOnTokenSet( CFG_TAG, yytext );
101 workOnTokenSet( COMMENT, yytext );
102 workOnTokenSet( COMMENT, pChar );
107 if ( c1 == '-' && c2 == '-' && c3 == '>' )
114 workOnTokenSet( COMMENT, pChar );
120 workOnTokenSet( CFG_CLOSETAG, yytext );
125 if ( yytext[ 1 ] == '!' && yytext[ 2 ] == '-' && yytext[ 3 ] == '-' )
126 workOnTokenSet( COMMENT, yytext );
128 workOnTokenSet( CFG_UNKNOWNTAG, yytext );
134 workOnTokenSet( CFG_TEXTCHAR, yytext );
136 workOnTokenSet( UNKNOWNCHAR, yytext );
142 /*****************************************************************************/
144 /*****************************************************************************/
149 /*****************************************************************************/
150 void yyerror ( const char *s )
151 /*****************************************************************************/
153 /* write error to stderr */
155 "Error: \"%s\" in line %d, column %d: \"%s\"\n", s, yylineno, yycolumn, yytext );
159 SAL_IMPLEMENT_MAIN_WITH_ARGS(argc, argv) {
160 yyin = init(argc, argv);
165 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */