LibreOffice Module l10ntools (master) 1
xrmlex.l
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
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 */
19
20%{
21
22/*
23 * lexer for parsing xml-property source files (*.xml)
24 */
25
26#include <sal/config.h>
27
28/* enlarge token buffer to tokenize whole strings */
29#undef YYLMAX
30#define YYLMAX 64000
31
32/* to enable debug output define LEXDEBUG */
33#define LEXDEBUG 1
34#ifdef LEXDEBUG
35#define OUTPUT fprintf
36#else
37#define OUTPUT(Par1,Par2);
38#endif
39
40/* table of possible token ids */
41#include <tokens.h>
42#include <xrmlex.hxx>
43#include <stdlib.h>
44#include <stdio.h>
45
46#include <sal/main.h>
47
48#define YY_NO_UNISTD_H
49
50static int bText=0;
static int bText
Definition: xrmlex.l:50
51%}
52
53%option yylineno
54%option nounput
55%option never-interactive
56
57%p 24000
58%e 1200
59%n 500
60
61%%
62
63"<p "[^>]*xml:lang[^>]*> {
65}
#define XRM_TEXT_START
Definition: tokens.h:81
int WorkOnTokenSet(int nTyp, char *pTokenText)
Definition: xrmmerge.cxx:115
66
67"</p>" {
69}
#define XRM_TEXT_END
Definition: tokens.h:82
70
71"<h1 "[^>]*xml:lang[^>]*> {
73}
74
75"</h1>" {
77}
78"<h2 "[^>]*xml:lang[^>]*> {
80}
81
82"</h2>" {
84}
85"<h3 "[^>]*xml:lang[^>]*> {
87}
88
89"</h3>" {
91}
92"<h4 "[^>]*xml:lang[^>]*> {
94}
95
96"</h4>" {
98}
99"<h5 "[^>]*xml:lang[^>]*> {
100 WorkOnTokenSet( XRM_TEXT_START , yytext );
101}
102
103"</h5>" {
104 WorkOnTokenSet( XRM_TEXT_END, yytext );
105}
106
107"<display-name>" {
109}
#define DESC_DISPLAY_NAME_START
Definition: tokens.h:90
110
111"</display-name>" {
113}
#define DESC_DISPLAY_NAME_END
Definition: tokens.h:91
114
115"<name "[^>]*lang[^>]*> {
117}
#define DESC_TEXT_START
Definition: tokens.h:92
118
119"</name>" {
120 WorkOnTokenSet( DESC_TEXT_END, yytext );
121}
#define DESC_TEXT_END
Definition: tokens.h:93
122
123"<extension-description>" {
125}
#define DESC_EXTENSION_DESCRIPTION_START
Definition: tokens.h:94
126
127"</extension-description>" {
129}
#define DESC_EXTENSION_DESCRIPTION_END
Definition: tokens.h:95
130
131"<src "[^>]*lang[^>]*> {
133}
#define DESC_EXTENSION_DESCRIPTION_SRC
Definition: tokens.h:96
134
135
136
137"<!--" {
138 int c1 = 0, c2 = 0;
139 int c3 = yyinput();
140 char pChar[2];
141 pChar[1] = 0x00;
142 pChar[0] = c3;
143
144 WorkOnTokenSet( COMMENT, yytext );
145 WorkOnTokenSet( COMMENT, pChar );
146
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 }
158}
#define COMMENT
Definition: tokens.h:29
const char * pChar
159
160.|\n {
161 if ( bText == 1 )
162 WorkOnTokenSet( XML_TEXTCHAR, yytext );
163 else
164 WorkOnTokenSet( UNKNOWNCHAR, yytext );
165}
#define UNKNOWNCHAR
Definition: tokens.h:32
#define XML_TEXTCHAR
Definition: tokens.h:83
166
167
168%%
169
170/*****************************************************************************/
171int yywrap(void)
172/*****************************************************************************/
173{
174 return 1;
175}
176
177/*****************************************************************************/
178void yyerror ( const char *s )
179/*****************************************************************************/
180{
181 /* write error to stderr */
182 fprintf( stderr,
183 "Error: \"%s\" in line %d: \"%s\"\n", s, yylineno, yytext );
184 SetError();
185}
186
188 /* error level */
189 int nRetValue = 0;
190 FILE *pFile;
191
192 if ( !GetOutputFile( argc, argv ) )
193 {
194 return 1;
195 }
196 pFile = GetXrmFile();
198
199 if ( !pFile )
200 return 1;
201
202 yyin = pFile;
203
204 /* create global instance of class XmlExport */
205 //InitXrmExport( pOutput );
206
207 /* start parser */
208 yylex();
209
210 /* get error info. and end export */
211 nRetValue = GetError();
212 EndXrmExport();
213
214 /* return error level */
215 return nRetValue;
216}
217
218/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
int yylex(void)
Definition: xrmlex.l:61
int yywrap(void)
Definition: xrmlex.l:171
SAL_IMPLEMENT_MAIN_WITH_ARGS(argc, argv)
Definition: xrmlex.l:187
void yyerror(const char *s)
Definition: xrmlex.l:178
int SetError()
Definition: xrmmerge.cxx:123
int EndXrmExport()
Definition: xrmmerge.cxx:87
int GetError()
Definition: xrmmerge.cxx:132
int InitXrmExport(const char *pFilename)
Definition: xrmmerge.cxx:74
const char * getFilename()
Definition: xrmmerge.cxx:92
bool GetOutputFile(int argc, char *argv[])
Definition: xrmmerge.cxx:51
FILE * GetXrmFile()
Definition: xrmmerge.cxx:97