lok: add character parameter to renderFont
[LibreOffice.git] / l10ntools / source / srclex.l
blob8fbb583613195c587c00585c5957498b17f289e7
2 %{
3 /*
4  * This file is part of the LibreOffice project.
5  *
6  * This Source Code Form is subject to the terms of the Mozilla Public
7  * License, v. 2.0. If a copy of the MPL was not distributed with this
8  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9  *
10  * This file incorporates work covered by the following license notice:
11  *
12  *   Licensed to the Apache Software Foundation (ASF) under one or more
13  *   contributor license agreements. See the NOTICE file distributed
14  *   with this work for additional information regarding copyright
15  *   ownership. The ASF licenses this file to you under the Apache
16  *   License, Version 2.0 (the "License"); you may not use this file
17  *   except in compliance with the License. You may obtain a copy of
18  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
19  */
22  * lexer for parsing resource source files (*.src)
23  */
25 #include "sal/config.h"
27 /* enlarge token buffer to tokenize whole strings */
28 #undef YYLMAX
29 #define YYLMAX 64000
31 /* to enable debug output define LEXDEBUG */
32 #define LEXDEBUG                1
33 #ifdef LEXDEBUG
34 #define OUTPUT  fprintf
35 #else
36 #define OUTPUT(Par1,Par2);
37 #endif
39 /* table of possible token ids */
40 #include "tokens.h"
41 #include <stdlib.h>
42 #include <stdio.h>
44 #include "sal/main.h"
46 #include "srclex.hxx"
48 #define YY_NO_UNISTD_H
50 /* forwards */
51 void YYWarning();
54 %option yylineno
55 %option never-interactive
57 %p 24000
58 %e 1200
59 %n 500
63 ^[\t ]*"#pragma".*      {
64         WorkOnTokenSet( PRAGMA, yytext );
67 ^[ \t]*\n {
68         WorkOnTokenSet( EMPTYLINE, yytext );
71 [\t ]+                          |
72 ^[\t ]*"#include".*     |
73 ^[\t ]*"#undef".*       |
74 "//".*                          |
75 ";"                             |
76 "<"                                     |
77 ">"                                     |
78 \n      {
79         WorkOnTokenSet( IGNOREDTOKENS, yytext );
81 "/*"    {
82         char c1 = 0;
83         int c2 = yyinput();
84         char pChar[2];
85         pChar[1] = 0x00;
86         pChar[0] = c2;
88         WorkOnTokenSet( COMMENT, yytext );
89         WorkOnTokenSet( COMMENT, pChar );
90         for(;;) {
91                 if ( c2 == EOF )
92                         break;
93                 if ( c1 == '*' && c2 == '/' )
94                         break;
95                 c1 = c2;
96                 c2 = yyinput();
97                 pChar[0] = c2;
98                 WorkOnTokenSet( COMMENT, pChar );
99         }
102 ^[\t ]*"#ifndef".+$     |
103 ^[\t ]*"#ifdef".+$      |
104 ^[\t ]*"#if".+$         |
105 ^[\t ]*"#elif".*$       |
106 ^[\t ]*"#else".*$       |
107 ^[\t ]*"#endif".*$      {
108         WorkOnTokenSet( CONDITION, yytext );
111 [a-zA-Z]+[\t ]+[^={\n]+[\t ] {
112 /* defined Res */
113         WorkOnTokenSet( DEFINEDRES, yytext );
116 [a-zA-Z]+[ \t]+[^={;\n]+\n[ \t]*"#".*\n[ \t]*"{"        |
117 [a-zA-Z]+[ \t]+[^={;\n]+\n?([ \t]*"//".*\n)*[ \t]*"{"   {
118 /* RESOURCE // String TTT_XX ... */
119         WorkOnTokenSet( RESOURCE, yytext );
122 ^[\t ]*[a-zA-Z_]+[\t ]*"\\"?[\t ]*\n?[ \t]*"{"[\t ]*"\\"?       {
123 /* SMALRESOURCE // String ... */
124         WorkOnTokenSet( SMALRESOURCE, yytext );
127 [\t ]*[a-zA-Z0-9_]+[ \t]*("["[ \t]*[a-zA-Z0-9_\-]+[ \t]*"]"[ \t]*)?=[ \t]*L?\".*\".*\n? {
128 /* TEXTLINE // TextTyp = "A Text" */
129         WorkOnTokenSet( TEXTLINE, yytext );
132 [\t ]*[a-zA-Z0-9_]+[ \t]*("["[ \t]*[a-zA-Z0-9_\-]+[ \t]*"]"[ \t]*)?(\n[ \t]*)?=([ \t]*\n)?(([a-zA-Z0-9_]+)|(\".*\")|([ \t\n]*))*\".*\"(([a-zA-Z0-9_]+)|(\".*\")|([ \t\n]*))*;   {
133 /* LONGTEXTLINE // TextTyp = "A Text" HHH_XXX "A Text" ZZZ_TTT ... */
134         WorkOnTokenSet( LONGTEXTLINE, yytext );
137 \".*\" {
138 /* TEXT // "A Text" */
139         WorkOnTokenSet( TEXT, yytext );
142 "{"[ \t]*\\?    {
143 /* LEVELUP */
144         WorkOnTokenSet( LEVELUP, yytext );
147 "}"[ \t]*;([ \t]*\\)?   {
148 /* LEVELDOWN */
149         WorkOnTokenSet( LEVELDOWN, yytext );
152 [a-zA-Z0-9_]+[ \t]*"="[ \t]*"MAP_APPFONT"[ \t]*"(".+")".*       {
153 /* APPFONTMAPPING  Typ = MAP_APPFONT( ... ) */
154         WorkOnTokenSet( APPFONTMAPPING, yytext );
157 [a-zA-Z0-9_]+[ \t]*"="[\t ]*([ \t]*"//".*\n)*.* |
158 [a-zA-Z0-9_]+[ \t]*"=".*        {
159 /* ASSIGNMENT  Typ = ...  */
160  WorkOnTokenSet( ASSIGNMENT, yytext );
165 [a-zA-Z0-9_]+[ \t]*("["[ \t]*[a-zA-Z0-9_\-]+[ \t]*"]"[ \t]*)?"="[ \t]*(\\[ \t]*)?\n?[ \t]*"{"[ \t]*(\\[ \t]*)?\n?[ \t]*"<"      {
166 /* LISTASSIGNMENT  Typ [ ... ] = ... */
167         WorkOnTokenSet( LISTASSIGNMENT, yytext );
170 "StringList"+[ \t]*("["[ \t]*[a-zA-Z0-9_\-]+[ \t]*"]"[ \t]*)?"="[ \t]*(\\[ \t]*)?\n?[ \t]*"{"[ \t]*(\\[ \t]*)?\n?[ \t]* {
171 /* LISTASSIGNMENT  Typ [ ... ] = ... */
172         WorkOnTokenSet( LISTASSIGNMENT, yytext );
175 "<"?[ \t]*L?\".*\".*">" {
176 /* LISTTEXT */
177         WorkOnTokenSet( LISTTEXT, yytext );
180 [ \t]*"#define"[ \t]+[a-zA-Z0-9_]+.*"\\"        {
181 /* RSCDEFINE  #define ... */
182         WorkOnTokenSet( RSCDEFINE, yytext );
185 [ \t]*"#define"[ \t]+[a-zA-Z0-9_]+.+ {
186 /* #define ... */
187         WorkOnTokenSet( NORMDEFINE, yytext );
190 "\\" {
191 /* RSCDEFINELEND */
192         WorkOnTokenSet( RSCDEFINELEND, yytext );
195 [a-zA-Z0-9_]+[ \t]*; {
196 /* allowed other tokens like "49 ;" or "SFX_... ;" */
197         WorkOnTokenSet( ANYTOKEN, yytext );
200 .       {
201         WorkOnTokenSet( UNKNOWNCHAR, yytext );
202 /*      YYWarning( "Unknown Char" ); */
205 "{"?[ \t]*\".*\"[ \t]*";"[ \t]*"}" {
206 /* LISTTEXT_ */
207         WorkOnTokenSet( LISTTEXT_, yytext );
212 /*****************************************************************************/
213 int     yywrap(void)
214 /*****************************************************************************/
216         return 1;
219 /*****************************************************************************/
220 void YYWarning( const char *s )
221 /*****************************************************************************/
223         /* write warning to stderr */
224         fprintf( stderr, "Warning: \"%s\" in line %d: \"%s\"\n", s, yylineno, yytext  );
227 /*****************************************************************************/
228 void yyerror( const char *s )
229 /*****************************************************************************/
231         /* write error to stderr */
232         fprintf( stderr, "Error: \"%s\" in line %d: \"%s\"\n", s, yylineno, yytext  );
233         SetError();
236 SAL_IMPLEMENT_MAIN_WITH_ARGS(argc, argv) {
237     yyin = init(argc, argv);
238     yylex();
239     Close();
240     return EXIT_SUCCESS;