lok: add character parameter to renderFont
[LibreOffice.git] / l10ntools / source / cfglex.l
blobfe53a88507e12e968a6be00dbb4cda01ea2a4c0a
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 cfg source files
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 <stdlib.h>
41 #include <stdio.h>
43 #include "sal/main.h"
45 #include "cfglex.hxx"
47 #define YY_NO_UNISTD_H
49 int yycolumn = 1;
50 #define YY_USER_ACTION yycolumn += yyleng;
52 int bText=0;
55 %option yylineno
56 %option never-interactive
58 %p 24000
59 %e 1200
60 %n 500
64 \<[^\>]*"xml:lang="\""x-no-translate"\"[^\<]*\/\>       {
65         bText = 0;
66         workOnTokenSet( CFG_TOKEN_NO_TRANSLATE, yytext );
69 \<.*\/\> {
70         bText = 0;
71         workOnTokenSet( ANYTOKEN, yytext );
74 \<[^\>]*"xml:lang="\".*\"[^\<]*\>       {
75         bText = 1;
76         workOnTokenSet( CFG_TEXT_START, yytext );
80 \<[^\/\!][^\>]*\>       {
81         bText = 0;
82         workOnTokenSet( CFG_TAG, yytext );
85 "<!"DOCTYPE[^\>]*\>     {
86         bText = 0;
87         workOnTokenSet( CFG_TAG, yytext );
91 \<\!\-\-        {
92         char c1 = 0, c2 = 0;
93         int c3 = yyinput();
94         char pChar[2];
95         pChar[1] = 0x00;
96         pChar[0] = c3;
98         workOnTokenSet( COMMENT, yytext );
99         workOnTokenSet( COMMENT, pChar );
101         for(;;) {
102                 if ( c3 == EOF )
103                         break;
104                 if ( c1 == '-' && c2 == '-' && c3 == '>' )
105                         break;
106                 c1 = c2;
107                 c2 = c3;
108                 c3 = yyinput();
110                 pChar[0] = c3;
111                 workOnTokenSet( COMMENT, pChar );
112         }
115 \<\/[^\>]*\> {
116         bText = 0;
117         workOnTokenSet( CFG_CLOSETAG, yytext );
120 \<[^\>\!]*\> {
121         bText = 0;
122         if ( yytext[ 1 ] == '!' && yytext[ 2 ] == '-' && yytext[ 3 ] == '-' )
123                 workOnTokenSet( COMMENT, yytext );
124         else
125                 workOnTokenSet( CFG_UNKNOWNTAG, yytext );
128 .|\n {
129     yycolumn = 1;
130         if ( bText == 1 )
131                 workOnTokenSet( CFG_TEXTCHAR, yytext );
132         else
133                 workOnTokenSet( UNKNOWNCHAR, yytext );
139 /*****************************************************************************/
140 int     yywrap(void)
141 /*****************************************************************************/
143         return 1;
146 /*****************************************************************************/
147 void YYWarning( const char *s )
148 /*****************************************************************************/
150         /* write warning to stderr */
151         fprintf( stderr,
152                 "Warning: \"%s\" in line %d, column %d: \"%s\"\n", s, yylineno, yycolumn, yytext  );
155 /*****************************************************************************/
156 void yyerror ( const char *s )
157 /*****************************************************************************/
159         /* write error to stderr */
160         fprintf( stderr,
161                 "Error: \"%s\" in line %d, column %d: \"%s\"\n", s, yylineno, yycolumn, yytext  );
162         exit(EXIT_FAILURE);
165 SAL_IMPLEMENT_MAIN_WITH_ARGS(argc, argv) {
166     yyin = init(argc, argv);
167     yylex();
168     return EXIT_SUCCESS;