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

Generated by: LCOV version 1.11