LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/l10ntools/source - xrmlex.l (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 84 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 xml-property source files (*.xml)
      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             : /* external functions (C++ code, declared as extern "C" */
      59             : extern "C" int WorkOnTokenSet( int, char* );
      60             : extern "C" int Argument( char * );
      61             : extern "C" int InitXrmExport( char * , char * );
      62             : extern "C" int EndXrmExport();
      63             : extern "C" int GetError();
      64             : extern "C" int SetError();
      65             : extern "C" char *GetOutputFile( int argc, char* argv[]);
      66             : extern "C" FILE *GetXrmFile();
      67             : extern "C" int isQuiet();
      68             : extern "C" char* getFilename();
      69             : 
      70             : /* forwards */
      71             : void YYWarning();
      72             : 
      73             : int bText=0;
      74             : %}
      75             : 
      76             : %option yylineno
      77             : %option never-interactive
      78             : 
      79             : %p 24000
      80             : %e 1200
      81             : %n 500
      82             : 
      83             : %%
      84             : 
      85             : "<p "[^\>]*xml:lang[^\>]*\> {
      86           0 :         WorkOnTokenSet( XRM_TEXT_START , yytext );
      87             : }
      88           0 : 
      89             : "</p>" {
      90           0 :         WorkOnTokenSet( XRM_TEXT_END, yytext );
      91             : }
      92           0 : 
      93             : "<h1 "[^\>]*xml:lang[^\>]*\> {
      94           0 :         WorkOnTokenSet( XRM_TEXT_START , yytext );
      95             : }
      96           0 : 
      97             : "</h1>" {
      98           0 :         WorkOnTokenSet( XRM_TEXT_END, yytext );
      99             : }
     100           0 : "<h2 "[^\>]*xml:lang[^\>]*\> {
     101           0 :         WorkOnTokenSet( XRM_TEXT_START , yytext );
     102             : }
     103           0 : 
     104             : "</h2>" {
     105           0 :         WorkOnTokenSet( XRM_TEXT_END, yytext );
     106             : }
     107           0 : "<h3 "[^\>]*xml:lang[^\>]*\> {
     108           0 :         WorkOnTokenSet( XRM_TEXT_START , yytext );
     109             : }
     110           0 : 
     111             : "</h3>" {
     112           0 :         WorkOnTokenSet( XRM_TEXT_END, yytext );
     113             : }
     114           0 : "<h4 "[^\>]*xml:lang[^\>]*\> {
     115           0 :         WorkOnTokenSet( XRM_TEXT_START , yytext );
     116             : }
     117           0 : 
     118             : "</h4>" {
     119           0 :         WorkOnTokenSet( XRM_TEXT_END, yytext );
     120             : }
     121           0 : "<h5 "[^\>]*xml:lang[^\>]*\> {
     122           0 :         WorkOnTokenSet( XRM_TEXT_START , yytext );
     123             : }
     124           0 : 
     125             : "</h5>" {
     126           0 :         WorkOnTokenSet( XRM_TEXT_END, yytext );
     127             : }
     128           0 : 
     129             : "<display-name>" {
     130           0 :         WorkOnTokenSet( DESC_DISPLAY_NAME_START , yytext );
     131             : }
     132           0 : 
     133             : "</display-name>" {
     134           0 :         WorkOnTokenSet( DESC_DISPLAY_NAME_END, yytext );
     135             : }
     136           0 : 
     137             : "<name "[^\>]*lang[^\>]*\> {
     138           0 :         WorkOnTokenSet( DESC_TEXT_START , yytext );
     139             : }
     140           0 : 
     141             : "</name>" {
     142           0 :         WorkOnTokenSet( DESC_TEXT_END, yytext );
     143             : }
     144           0 : 
     145             : "<extension-description>" {
     146           0 :         WorkOnTokenSet( DESC_EXTENSION_DESCRIPTION_START , yytext );
     147             : }
     148           0 : 
     149             : "</extension-description>" {
     150           0 :         WorkOnTokenSet( DESC_EXTENSION_DESCRIPTION_END , yytext );
     151             : }
     152           0 : 
     153             : "<src "[^\>]*lang[^\>]*\> {
     154           0 :         WorkOnTokenSet( DESC_EXTENSION_DESCRIPTION_SRC , yytext );
     155             : }
     156           0 : 
     157             : 
     158             : 
     159             : "<!--"     {
     160           0 :         char c1 = 0, c2 = 0;
     161           0 :         int c3 = yyinput();
     162             :         char pChar[2];
     163           0 :         pChar[1] = 0x00;
     164           0 :         pChar[0] = c3;
     165             : 
     166           0 :         WorkOnTokenSet( COMMENT, yytext );
     167           0 :         WorkOnTokenSet( COMMENT, pChar );
     168             : 
     169             :         for(;;) {
     170           0 :                 if ( c3 == EOF )
     171           0 :                         break;
     172           0 :                 if ( c1 == '-' && c2 == '-' && c3 == '>' )
     173           0 :                         break;
     174           0 :                 c1 = c2;
     175           0 :                 c2 = c3;
     176           0 :                 c3 = yyinput();
     177           0 :                 pChar[0] = c3;
     178           0 :                 WorkOnTokenSet( COMMENT, pChar );
     179           0 :         }
     180             : }
     181           0 : 
     182             : .|\n {
     183           0 :         if ( bText == 1 )
     184           0 :                 WorkOnTokenSet( XML_TEXTCHAR, yytext );
     185             :         else
     186           0 :                 WorkOnTokenSet( UNKNOWNCHAR, yytext );
     187             : }
     188           0 : 
     189             : 
     190           0 : %%
     191           0 : 
     192             : /*****************************************************************************/
     193             : int     yywrap(void)
     194           0 : /*****************************************************************************/
     195             : {
     196             :         return 1;
     197           0 : }
     198             : 
     199             : /*****************************************************************************/
     200             : void YYWarning( const char *s )
     201           0 : /*****************************************************************************/
     202             : {
     203             :         /* write warning to stderr */
     204             :         fprintf( stderr,
     205             :                 "Warning: \"%s\" in line %d: \"%s\"\n", s, yylineno, yytext  );
     206           0 : }
     207           0 : 
     208             : /*****************************************************************************/
     209             : void yyerror ( const char *s )
     210           0 : /*****************************************************************************/
     211             : {
     212             :         /* write error to stderr */
     213             :         fprintf( stderr,
     214             :                 "Error: \"%s\" in line %d: \"%s\"\n", s, yylineno, yytext  );
     215           0 :         SetError();
     216           0 : }
     217           0 : 
     218             : SAL_IMPLEMENT_MAIN_WITH_ARGS(argc, argv) {
     219           0 :         /* error level */
     220             :         int nRetValue = 0;
     221           0 :         char *pOutput;
     222             :         FILE *pFile;
     223             : 
     224             :         pOutput = GetOutputFile( argc, argv );
     225           0 : 
     226             :         if ( !pOutput )
     227           0 :         {
     228             :                 return 1;
     229           0 :         }
     230             :         pFile = GetXrmFile();
     231           0 :         InitXrmExport( pOutput , getFilename() );
     232           0 : 
     233             :     if ( !pFile )
     234           0 :                 return 1;
     235           0 : 
     236             :         yyin = pFile;
     237           0 : 
     238             :         /* create global instance of class XmlExport */
     239             :         //InitXrmExport( pOutput );
     240             : 
     241             :         /* start parser */
     242             :         yylex();
     243           0 : 
     244             :         /* get error info. and end export */
     245             :         nRetValue = GetError();
     246           0 :         EndXrmExport();
     247           0 : 
     248             :         /* return error level */
     249             :         return nRetValue;
     250           0 : }

Generated by: LCOV version 1.10