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

Generated by: LCOV version 1.10