l10ntools: remove unused srclex
[LibreOffice.git] / l10ntools / source / xrmlex.l
blob4bd17ec5a3acce4db45f6723034ed5943233ff99
1 %{
2 /*
3  * This file is part of the LibreOffice project.
4  *
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/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
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 .
18  */
21  * lexer for parsing xml-property source files (*.xml)
22  */
24 #include "sal/config.h"
26 /* enlarge token buffer to tokenize whole strings */
27 #undef YYLMAX
28 #define YYLMAX 64000
30 /* to enable debug output define LEXDEBUG */
31 #define LEXDEBUG                1
32 #ifdef LEXDEBUG
33 #define OUTPUT  fprintf
34 #else
35 #define OUTPUT(Par1,Par2);
36 #endif
38 /* table of possible token ids */
39 #include "tokens.h"
40 #include "xrmlex.hxx"
41 #include <stdlib.h>
42 #include <stdio.h>
44 #include "sal/main.h"
46 #define YY_NO_UNISTD_H
48 /* forwards */
49 void YYWarning();
51 int bText=0;
54 %option yylineno
55 %option never-interactive
57 %p 24000
58 %e 1200
59 %n 500
63 "<p "[^\>]*xml:lang[^\>]*\> {
64         WorkOnTokenSet( XRM_TEXT_START , yytext );
67 "</p>" {
68         WorkOnTokenSet( XRM_TEXT_END, yytext );
71 "<h1 "[^\>]*xml:lang[^\>]*\> {
72         WorkOnTokenSet( XRM_TEXT_START , yytext );
75 "</h1>" {
76         WorkOnTokenSet( XRM_TEXT_END, yytext );
78 "<h2 "[^\>]*xml:lang[^\>]*\> {
79         WorkOnTokenSet( XRM_TEXT_START , yytext );
82 "</h2>" {
83         WorkOnTokenSet( XRM_TEXT_END, yytext );
85 "<h3 "[^\>]*xml:lang[^\>]*\> {
86         WorkOnTokenSet( XRM_TEXT_START , yytext );
89 "</h3>" {
90         WorkOnTokenSet( XRM_TEXT_END, yytext );
92 "<h4 "[^\>]*xml:lang[^\>]*\> {
93         WorkOnTokenSet( XRM_TEXT_START , yytext );
96 "</h4>" {
97         WorkOnTokenSet( XRM_TEXT_END, yytext );
99 "<h5 "[^\>]*xml:lang[^\>]*\> {
100         WorkOnTokenSet( XRM_TEXT_START , yytext );
103 "</h5>" {
104         WorkOnTokenSet( XRM_TEXT_END, yytext );
107 "<display-name>" {
108         WorkOnTokenSet( DESC_DISPLAY_NAME_START , yytext );
111 "</display-name>" {
112         WorkOnTokenSet( DESC_DISPLAY_NAME_END, yytext );
115 "<name "[^\>]*lang[^\>]*\> {
116         WorkOnTokenSet( DESC_TEXT_START , yytext );
119 "</name>" {
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 );
137 "<!--"  {
138         char c1 = 0, c2 = 0;
139         int c3 = yyinput();
140         char pChar[2];
141         pChar[1] = 0x00;
142         pChar[0] = c3;
144         WorkOnTokenSet( COMMENT, yytext );
145         WorkOnTokenSet( COMMENT, pChar );
147         for(;;) {
148                 if ( c3 == EOF )
149                         break;
150                 if ( c1 == '-' && c2 == '-' && c3 == '>' )
151                         break;
152                 c1 = c2;
153                 c2 = c3;
154                 c3 = yyinput();
155                 pChar[0] = c3;
156                 WorkOnTokenSet( COMMENT, pChar );
157         }
160 .|\n {
161         if ( bText == 1 )
162                 WorkOnTokenSet( XML_TEXTCHAR, yytext );
163         else
164                 WorkOnTokenSet( UNKNOWNCHAR, yytext );
170 /*****************************************************************************/
171 int     yywrap(void)
172 /*****************************************************************************/
174         return 1;
177 /*****************************************************************************/
178 void YYWarning( const char *s )
179 /*****************************************************************************/
181         /* write warning to stderr */
182         fprintf( stderr,
183                 "Warning: \"%s\" in line %d: \"%s\"\n", s, yylineno, yytext  );
186 /*****************************************************************************/
187 void yyerror ( const char *s )
188 /*****************************************************************************/
190         /* write error to stderr */
191         fprintf( stderr,
192                 "Error: \"%s\" in line %d: \"%s\"\n", s, yylineno, yytext  );
193         SetError();
196 SAL_IMPLEMENT_MAIN_WITH_ARGS(argc, argv) {
197         /* error level */
198         int nRetValue = 0;
199         FILE *pFile;
201         if ( !GetOutputFile( argc, argv ) )
202         {
203                 return 1;
204         }
205         pFile = GetXrmFile();
206         InitXrmExport( getFilename() );
208     if ( !pFile )
209                 return 1;
211         yyin = pFile;
213         /* create global instance of class XmlExport */
214         //InitXrmExport( pOutput );
216         /* start parser */
217         yylex();
219         /* get error info. and end export */
220         nRetValue = GetError();
221         EndXrmExport();
223         /* return error level */
224         return nRetValue;