LCOV - code coverage report
Current view: top level - l10ntools/source - srclex.l (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 97 0.0 %
Date: 2014-04-14 Functions: 0 5 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : 
       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             :  */
      20             : 
      21             : /*
      22             :  * lexer for parsing resource source files (*.src)
      23             :  */
      24             : 
      25             : #include "sal/config.h"
      26             : 
      27             : /* enlarge token buffer to tokenize whole strings */
      28             : #undef YYLMAX
      29             : #define YYLMAX 64000
      30             : 
      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
      38             : 
      39             : /* table of possible token ids */
      40             : #include "tokens.h"
      41             : #include <stdlib.h>
      42             : #include <stdio.h>
      43             : 
      44             : #include "sal/main.h"
      45             : 
      46             : #include "srclex.hxx"
      47             : 
      48             : #if HAVE_GCC_PRAGMA_DIAGNOSTIC_MODIFY
      49             : #pragma GCC diagnostic ignored "-Wunused-function"
      50             : #pragma GCC diagnostic ignored "-Wunused-label"
      51             : #if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6))
      52             : #pragma GCC diagnostic ignored "-Wunused-but-set-variable"
      53             : #endif
      54             : #elif defined _MSC_VER
      55             : #pragma warning(push, 1)
      56             : #endif
      57             : #define YY_NO_UNISTD_H
      58             : 
      59             : /* forwards */
      60             : void YYWarning();
      61             : %}
      62             : 
      63             : %option yylineno
      64             : %option never-interactive
      65             : 
      66             : %p 24000
      67             : %e 1200
      68             : %n 500
      69             : 
      70             : %%
      71             : 
      72             : ^[\t ]*"#pragma".*    {
      73           0 :         WorkOnTokenSet( PRAGMA, yytext );
      74             : }
      75           0 : 
      76             : ^[ \t]*\n {
      77           0 :         WorkOnTokenSet( EMPTYLINE, yytext );
      78           0 : }
      79           0 : 
      80             : [\t ]+                          |
      81             : ^[\t ]*"#include".*   |
      82             : ^[\t ]*"#undef".*     |
      83             : "//".*                                |
      84             : ";"                           |
      85             : "<"                                        |
      86             : ">"                                        |
      87             : \n      {
      88           0 :         WorkOnTokenSet( IGNOREDTOKENS, yytext );
      89           0 : }
      90           0 : "/*"  {
      91           0 :         char c1 = 0;
      92           0 :         int c2 = yyinput();
      93             :         char pChar[2];
      94           0 :         pChar[1] = 0x00;
      95           0 :         pChar[0] = c2;
      96             : 
      97           0 :         WorkOnTokenSet( COMMENT, yytext );
      98           0 :         WorkOnTokenSet( COMMENT, pChar );
      99             :         for(;;) {
     100           0 :                 if ( c2 == EOF )
     101           0 :                         break;
     102           0 :                 if ( c1 == '*' && c2 == '/' )
     103           0 :                         break;
     104           0 :                 c1 = c2;
     105           0 :                 c2 = yyinput();
     106           0 :                 pChar[0] = c2;
     107           0 :                 WorkOnTokenSet( COMMENT, pChar );
     108           0 :         }
     109             : }
     110           0 : 
     111             : ^[\t ]*"#ifndef".+$   |
     112           0 : ^[\t ]*"#ifdef".+$    |
     113           0 : ^[\t ]*"#if".+$               |
     114           0 : ^[\t ]*"#elif".*$     |
     115           0 : ^[\t ]*"#else".*$     |
     116             : ^[\t ]*"#endif".*$    {
     117           0 :         WorkOnTokenSet( CONDITION, yytext );
     118             : }
     119           0 : 
     120             : [a-zA-Z]+[\t ]+[^={\n]+[\t ] {
     121           0 : /* defined Res */
     122           0 :         WorkOnTokenSet( DEFINEDRES, yytext );
     123             : }
     124           0 : 
     125             : [a-zA-Z]+[ \t]+[^={;\n]+\n[ \t]*"#".*\n[ \t]*"{"    |
     126             : [a-zA-Z]+[ \t]+[^={;\n]+\n?([ \t]*"//".*\n)*[ \t]*"{"       {
     127             : /* RESOURCE // String TTT_XX ... */
     128           0 :         WorkOnTokenSet( RESOURCE, yytext );
     129             : }
     130           0 : 
     131             : ^[\t ]*[a-zA-Z_]+[\t ]*"\\"?[\t ]*\n?[ \t]*"{"[\t ]*"\\"? {
     132             : /* SMALRESOURCE // String ... */
     133           0 :         WorkOnTokenSet( SMALRESOURCE, yytext );
     134             : }
     135           0 : 
     136             : [\t ]*[a-zA-Z0-9_]+[ \t]*("["[ \t]*[a-zA-Z0-9_\-]+[ \t]*"]"[ \t]*)?=[ \t]*L?\".*\".*\n?   {
     137             : /* TEXTLINE // TextTyp = "A Text" */
     138           0 :         WorkOnTokenSet( TEXTLINE, yytext );
     139             : }
     140           0 : 
     141             : [\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]*))*; {
     142             : /* LONGTEXTLINE // TextTyp = "A Text" HHH_XXX "A Text" ZZZ_TTT ... */
     143           0 :         WorkOnTokenSet( LONGTEXTLINE, yytext );
     144             : }
     145           0 : 
     146             : \".*\" {
     147           0 : /* TEXT // "A Text" */
     148           0 :         WorkOnTokenSet( TEXT, yytext );
     149             : }
     150           0 : 
     151             : "{"[ \t]*\\?  {
     152           0 : /* LEVELUP */
     153           0 :         WorkOnTokenSet( LEVELUP, yytext );
     154             : }
     155           0 : 
     156             : "}"[ \t]*;([ \t]*\\)? {
     157           0 : /* LEVELDOWN */
     158           0 :         WorkOnTokenSet( LEVELDOWN, yytext );
     159             : }
     160           0 : 
     161             : [a-zA-Z0-9_]+[ \t]*"="[ \t]*"MAP_APPFONT"[ \t]*"(".+")".*       {
     162           0 : /* APPFONTMAPPING  Typ = MAP_APPFONT( ... ) */
     163           0 :         WorkOnTokenSet( APPFONTMAPPING, yytext );
     164             : }
     165           0 : 
     166             : [a-zA-Z0-9_]+[ \t]*"="[\t ]*([ \t]*"//".*\n)*.*     |
     167             : [a-zA-Z0-9_]+[ \t]*"=".*      {
     168             : /* ASSIGNMENT  Typ = ...  */
     169           0 :  WorkOnTokenSet( ASSIGNMENT, yytext );
     170             : }
     171           0 : 
     172             : 
     173             : 
     174           0 : [a-zA-Z0-9_]+[ \t]*("["[ \t]*[a-zA-Z0-9_\-]+[ \t]*"]"[ \t]*)?"="[ \t]*(\\[ \t]*)?\n?[ \t]*"{"[ \t]*(\\[ \t]*)?\n?[ \t]*"<" {
     175             : /* LISTASSIGNMENT  Typ [ ... ] = ... */
     176           0 :         WorkOnTokenSet( LISTASSIGNMENT, yytext );
     177             : }
     178           0 : 
     179             : "StringList"+[ \t]*("["[ \t]*[a-zA-Z0-9_\-]+[ \t]*"]"[ \t]*)?"="[ \t]*(\\[ \t]*)?\n?[ \t]*"{"[ \t]*(\\[ \t]*)?\n?[ \t]*       {
     180             : /* LISTASSIGNMENT  Typ [ ... ] = ... */
     181           0 :         WorkOnTokenSet( LISTASSIGNMENT, yytext );
     182             : }
     183           0 : 
     184             : "<"?[ \t]*L?\".*\".*">" {
     185           0 : /* LISTTEXT */
     186           0 :         WorkOnTokenSet( LISTTEXT, yytext );
     187             : }
     188           0 : 
     189             : [ \t]*"#define"[ \t]+[a-zA-Z0-9_]+.*"\\"    {
     190           0 : /* RSCDEFINE  #define ... */
     191           0 :         WorkOnTokenSet( RSCDEFINE, yytext );
     192             : }
     193           0 : 
     194             : [ \t]*"#define"[ \t]+[a-zA-Z0-9_]+.+ {
     195           0 : /* #define ... */
     196           0 :         WorkOnTokenSet( NORMDEFINE, yytext );
     197             : }
     198           0 : 
     199             : "\\" {
     200           0 : /* RSCDEFINELEND */
     201           0 :         WorkOnTokenSet( RSCDEFINELEND, yytext );
     202             : }
     203           0 : 
     204             : [a-zA-Z0-9_]+[ \t]*; {
     205           0 : /* allowed other tokens like "49 ;" or "SFX_... ;" */
     206           0 :         WorkOnTokenSet( ANYTOKEN, yytext );
     207             : }
     208           0 : 
     209             : .       {
     210           0 :         WorkOnTokenSet( UNKNOWNCHAR, yytext );
     211             : /*      YYWarning( "Unknown Char" ); */
     212             : }
     213           0 : 
     214             : "{"?[ \t]*\".*\"[ \t]*";"[ \t]*"}" {
     215           0 : /* _LISTTEXT */
     216           0 :         WorkOnTokenSet( _LISTTEXT, yytext );
     217             : }
     218           0 : 
     219           0 : %%
     220           0 : 
     221             : /*****************************************************************************/
     222             : int     yywrap(void)
     223           0 : /*****************************************************************************/
     224             : {
     225             :         return 1;
     226           0 : }
     227             : 
     228             : /*****************************************************************************/
     229             : void YYWarning( const char *s )
     230           0 : /*****************************************************************************/
     231             : {
     232             :         /* write warning to stderr */
     233             :         fprintf( stderr, "Warning: \"%s\" in line %d: \"%s\"\n", s, yylineno, yytext  );
     234           0 : }
     235           0 : 
     236             : /*****************************************************************************/
     237             : void yyerror( const char *s )
     238           0 : /*****************************************************************************/
     239             : {
     240             :         /* write error to stderr */
     241             :         fprintf( stderr, "Error: \"%s\" in line %d: \"%s\"\n", s, yylineno, yytext  );
     242           0 :         SetError();
     243           0 : }
     244           0 : 
     245             : SAL_IMPLEMENT_MAIN_WITH_ARGS(argc, argv) {
     246           0 :     int e;
     247             :     yyin = init(argc, argv);
     248           0 :     yylex();
     249           0 :     e = GetError();
     250           0 :     Close();
     251           0 :     return EXIT_SUCCESS;
     252           0 : }

Generated by: LCOV version 1.10