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

Generated by: LCOV version 1.10