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 xml-property source files (*.xml)
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 */
48 #define YY_NO_UNISTD_H
55 %option never-interactive
63 "<p "[^\>]*xml:lang[^\>]*\> {
64 WorkOnTokenSet( XRM_TEXT_START , yytext );
68 WorkOnTokenSet( XRM_TEXT_END, yytext );
71 "<h1 "[^\>]*xml:lang[^\>]*\> {
72 WorkOnTokenSet( XRM_TEXT_START , yytext );
76 WorkOnTokenSet( XRM_TEXT_END, yytext );
78 "<h2 "[^\>]*xml:lang[^\>]*\> {
79 WorkOnTokenSet( XRM_TEXT_START , yytext );
83 WorkOnTokenSet( XRM_TEXT_END, yytext );
85 "<h3 "[^\>]*xml:lang[^\>]*\> {
86 WorkOnTokenSet( XRM_TEXT_START , yytext );
90 WorkOnTokenSet( XRM_TEXT_END, yytext );
92 "<h4 "[^\>]*xml:lang[^\>]*\> {
93 WorkOnTokenSet( XRM_TEXT_START , yytext );
97 WorkOnTokenSet( XRM_TEXT_END, yytext );
99 "<h5 "[^\>]*xml:lang[^\>]*\> {
100 WorkOnTokenSet( XRM_TEXT_START , yytext );
104 WorkOnTokenSet( XRM_TEXT_END, yytext );
108 WorkOnTokenSet( DESC_DISPLAY_NAME_START , yytext );
112 WorkOnTokenSet( DESC_DISPLAY_NAME_END, yytext );
115 "<name "[^\>]*lang[^\>]*\> {
116 WorkOnTokenSet( DESC_TEXT_START , yytext );
120 WorkOnTokenSet( DESC_TEXT_END, yytext );
123 "<extension-description>" {
124 WorkOnTokenSet( DESC_EXTENSION_DESCRIPTION_START , yytext );
127 "</extension-description>" {
128 WorkOnTokenSet( DESC_EXTENSION_DESCRIPTION_END , yytext );
131 "<src "[^\>]*lang[^\>]*\> {
132 WorkOnTokenSet( DESC_EXTENSION_DESCRIPTION_SRC , yytext );
144 WorkOnTokenSet( COMMENT, yytext );
145 WorkOnTokenSet( COMMENT, pChar );
150 if ( c1 == '-' && c2 == '-' && c3 == '>' )
156 WorkOnTokenSet( COMMENT, pChar );
162 WorkOnTokenSet( XML_TEXTCHAR, yytext );
164 WorkOnTokenSet( UNKNOWNCHAR, yytext );
170 /*****************************************************************************/
172 /*****************************************************************************/
177 /*****************************************************************************/
178 void yyerror ( const char *s )
179 /*****************************************************************************/
181 /* write error to stderr */
183 "Error: \"%s\" in line %d: \"%s\"\n", s, yylineno, yytext );
187 SAL_IMPLEMENT_MAIN_WITH_ARGS(argc, argv) {
192 if ( !GetOutputFile( argc, argv ) )
196 pFile = GetXrmFile();
197 InitXrmExport( getFilename() );
204 /* create global instance of class XmlExport */
205 //InitXrmExport( pOutput );
210 /* get error info. and end export */
211 nRetValue = GetError();
214 /* return error level */
218 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */