LCOV - code coverage report
Current view: top level - l10ntools/source - cfglex.l (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 0 60 0.0 %
Date: 2015-06-13 12:38:46 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 __GNUC__
      48             : #pragma GCC diagnostic ignored "-Wunused-function"
      49             : #pragma GCC diagnostic ignored "-Wunused-label"
      50             : #pragma GCC diagnostic ignored "-Wunused-but-set-variable"
      51             : #elif defined _MSC_VER
      52             : #pragma warning(push, 1)
      53             : #endif
      54             : #define YY_NO_UNISTD_H
      55             : 
      56             : int yycolumn = 1;
      57             : #define YY_USER_ACTION yycolumn += yyleng;
      58             : 
      59             : int bText=0;
      60             : %}
      61             : 
      62             : %option yylineno
      63             : %option never-interactive
      64             : 
      65             : %p 24000
      66             : %e 1200
      67             : %n 500
      68             : 
      69             : %%
      70             : 
      71             : \<[^\>]*"xml:lang="\""x-no-translate"\"[^\<]*\/\>     {
      72           0 :         bText = 0;
      73           0 :         workOnTokenSet( CFG_TOKEN_NO_TRANSLATE, yytext );
      74             : }
      75           0 : 
      76             : \<.*\/\> {
      77           0 :         bText = 0;
      78           0 :         workOnTokenSet( ANYTOKEN, yytext );
      79             : }
      80           0 : 
      81             : \<[^\>]*"xml:lang="\".*\"[^\<]*\>       {
      82           0 :         bText = 1;
      83           0 :         workOnTokenSet( CFG_TEXT_START, yytext );
      84             : }
      85           0 : 
      86             : 
      87             : \<[^\/\!][^\>]*\>      {
      88           0 :         bText = 0;
      89           0 :         workOnTokenSet( CFG_TAG, yytext );
      90             : }
      91           0 : 
      92             : "<!"DOCTYPE[^\>]*\>  {
      93           0 :         bText = 0;
      94           0 :         workOnTokenSet( CFG_TAG, yytext );
      95             : }
      96           0 : 
      97             : 
      98           0 : \<\!\-\-     {
      99           0 :         char c1 = 0, c2 = 0;
     100           0 :         int c3 = yyinput();
     101             :         char pChar[2];
     102           0 :         pChar[1] = 0x00;
     103           0 :         pChar[0] = c3;
     104             : 
     105           0 :         workOnTokenSet( COMMENT, yytext );
     106           0 :         workOnTokenSet( COMMENT, pChar );
     107             : 
     108             :         for(;;) {
     109           0 :                 if ( c3 == EOF )
     110           0 :                         break;
     111           0 :                 if ( c1 == '-' && c2 == '-' && c3 == '>' )
     112           0 :                         break;
     113           0 :                 c1 = c2;
     114           0 :                 c2 = c3;
     115           0 :                 c3 = yyinput();
     116             : 
     117           0 :                 pChar[0] = c3;
     118           0 :                 workOnTokenSet( COMMENT, pChar );
     119           0 :         }
     120             : }
     121           0 : 
     122             : \<\/[^\>]*\> {
     123           0 :         bText = 0;
     124           0 :         workOnTokenSet( CFG_CLOSETAG, yytext );
     125             : }
     126           0 : 
     127             : \<[^\>\!]*\> {
     128           0 :         bText = 0;
     129           0 :         if ( yytext[ 1 ] == '!' && yytext[ 2 ] == '-' && yytext[ 3 ] == '-' )
     130           0 :                 workOnTokenSet( COMMENT, yytext );
     131             :         else
     132           0 :                 workOnTokenSet( CFG_UNKNOWNTAG, yytext );
     133             : }
     134           0 : 
     135             : .|\n {
     136           0 :     yycolumn = 1;
     137           0 :         if ( bText == 1 )
     138           0 :                 workOnTokenSet( CFG_TEXTCHAR, yytext );
     139             :         else
     140           0 :                 workOnTokenSet( UNKNOWNCHAR, yytext );
     141             : }
     142           0 : 
     143             : 
     144           0 : %%
     145           0 : 
     146             : /*****************************************************************************/
     147             : int     yywrap(void)
     148           0 : /*****************************************************************************/
     149             : {
     150             :         return 1;
     151           0 : }
     152             : 
     153             : /*****************************************************************************/
     154             : void YYWarning( const char *s )
     155           0 : /*****************************************************************************/
     156             : {
     157             :         /* write warning to stderr */
     158             :         fprintf( stderr,
     159             :                 "Warning: \"%s\" in line %d, column %d: \"%s\"\n", s, yylineno, yycolumn, yytext  );
     160           0 : }
     161           0 : 
     162             : /*****************************************************************************/
     163             : void yyerror ( const char *s )
     164           0 : /*****************************************************************************/
     165             : {
     166             :         /* write error to stderr */
     167             :         fprintf( stderr,
     168             :                 "Error: \"%s\" in line %d, column %d: \"%s\"\n", s, yylineno, yycolumn, yytext  );
     169           0 :         exit(EXIT_FAILURE);
     170           0 : }
     171             : 
     172             : SAL_IMPLEMENT_MAIN_WITH_ARGS(argc, argv) {
     173           0 :     yyin = init(argc, argv);
     174           0 :     yylex();
     175           0 :     return EXIT_SUCCESS;
     176           0 : }

Generated by: LCOV version 1.11