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

          Line data    Source code
       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             :  */
      19             : 
      20             : /*
      21             :  * lexer for parsing cfg source files
      22             :  */
      23             : 
      24             : #include "sal/config.h"
      25             : 
      26             : /* enlarge token buffer to tokenize whole strings */
      27             : #undef YYLMAX
      28             : #define YYLMAX 64000
      29             : 
      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
      37             : 
      38             : /* table of possible token ids */
      39             : #include "tokens.h"
      40             : #include <stdlib.h>
      41             : #include <stdio.h>
      42             : 
      43             : #include "sal/main.h"
      44             : 
      45             : #include "cfglex.hxx"
      46             : 
      47             : #if HAVE_GCC_PRAGMA_DIAGNOSTIC_MODIFY
      48             : #pragma GCC diagnostic ignored "-Wunused-function"
      49             : #pragma GCC diagnostic ignored "-Wunused-label"
      50             : #if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6))
      51             : #pragma GCC diagnostic ignored "-Wunused-but-set-variable"
      52             : #endif
      53             : #elif defined _MSC_VER
      54             : #pragma warning(push, 1)
      55             : #endif
      56             : #define YY_NO_UNISTD_H
      57             : 
      58             : int yycolumn = 1;
      59             : #define YY_USER_ACTION yycolumn += yyleng;
      60             : 
      61             : int bText=0;
      62             : %}
      63             : 
      64             : %option yylineno
      65             : %option never-interactive
      66             : 
      67             : %p 24000
      68             : %e 1200
      69             : %n 500
      70             : 
      71             : %%
      72             : 
      73             : \<[^\>]*"xml:lang="\""x-no-translate"\"[^\<]*\/\>     {
      74           0 :         bText = 0;
      75           0 :         workOnTokenSet( CFG_TOKEN_NO_TRANSLATE, yytext );
      76             : }
      77           0 : 
      78             : \<.*\/\> {
      79           0 :         bText = 0;
      80           0 :         workOnTokenSet( ANYTOKEN, yytext );
      81             : }
      82           0 : 
      83             : \<[^\>]*"xml:lang="\".*\"[^\<]*\>       {
      84           0 :         bText = 1;
      85           0 :         workOnTokenSet( CFG_TEXT_START, yytext );
      86             : }
      87           0 : 
      88             : 
      89             : \<[^\/\!][^\>]*\>      {
      90           0 :         bText = 0;
      91           0 :         workOnTokenSet( CFG_TAG, yytext );
      92             : }
      93           0 : 
      94             : "<!"DOCTYPE[^\>]*\>  {
      95           0 :         bText = 0;
      96           0 :         workOnTokenSet( CFG_TAG, yytext );
      97             : }
      98           0 : 
      99             : 
     100           0 : \<\!\-\-     {
     101           0 :         char c1 = 0, c2 = 0;
     102           0 :         int c3 = yyinput();
     103             :         char pChar[2];
     104           0 :         pChar[1] = 0x00;
     105           0 :         pChar[0] = c3;
     106             : 
     107           0 :         workOnTokenSet( COMMENT, yytext );
     108           0 :         workOnTokenSet( COMMENT, pChar );
     109             : 
     110             :         for(;;) {
     111           0 :                 if ( c3 == EOF )
     112           0 :                         break;
     113           0 :                 if ( c1 == '-' && c2 == '-' && c3 == '>' )
     114           0 :                         break;
     115           0 :                 c1 = c2;
     116           0 :                 c2 = c3;
     117           0 :                 c3 = yyinput();
     118             : 
     119           0 :                 pChar[0] = c3;
     120           0 :                 workOnTokenSet( COMMENT, pChar );
     121           0 :         }
     122             : }
     123           0 : 
     124             : \<\/[^\>]*\> {
     125           0 :         bText = 0;
     126           0 :         workOnTokenSet( CFG_CLOSETAG, yytext );
     127             : }
     128           0 : 
     129             : \<[^\>\!]*\> {
     130           0 :         bText = 0;
     131           0 :         if ( yytext[ 1 ] == '!' && yytext[ 2 ] == '-' && yytext[ 3 ] == '-' )
     132           0 :                 workOnTokenSet( COMMENT, yytext );
     133             :         else
     134           0 :                 workOnTokenSet( CFG_UNKNOWNTAG, yytext );
     135             : }
     136           0 : 
     137             : .|\n {
     138           0 :     yycolumn = 1;
     139           0 :         if ( bText == 1 )
     140           0 :                 workOnTokenSet( CFG_TEXTCHAR, yytext );
     141             :         else
     142           0 :                 workOnTokenSet( UNKNOWNCHAR, yytext );
     143             : }
     144           0 : 
     145             : 
     146           0 : %%
     147           0 : 
     148             : /*****************************************************************************/
     149             : int     yywrap(void)
     150           0 : /*****************************************************************************/
     151             : {
     152             :         return 1;
     153           0 : }
     154             : 
     155             : /*****************************************************************************/
     156             : void YYWarning( const char *s )
     157           0 : /*****************************************************************************/
     158             : {
     159             :         /* write warning to stderr */
     160             :         fprintf( stderr,
     161             :                 "Warning: \"%s\" in line %d, column %d: \"%s\"\n", s, yylineno, yycolumn, yytext  );
     162           0 : }
     163           0 : 
     164             : /*****************************************************************************/
     165             : void yyerror ( const char *s )
     166           0 : /*****************************************************************************/
     167             : {
     168             :         /* write error to stderr */
     169             :         fprintf( stderr,
     170             :                 "Error: \"%s\" in line %d, column %d: \"%s\"\n", s, yylineno, yycolumn, yytext  );
     171           0 :         exit(EXIT_FAILURE);
     172           0 : }
     173             : 
     174             : SAL_IMPLEMENT_MAIN_WITH_ARGS(argc, argv) {
     175           0 :     yyin = init(argc, argv);
     176           0 :     yylex();
     177           0 :     return EXIT_SUCCESS;
     178           0 : }

Generated by: LCOV version 1.10