LCOV - code coverage report
Current view: top level - src - scan_citi.l (source / functions) Hit Total Coverage
Test: qucs-core-0.0.19 Code Coverage Lines: 0 45 0.0 %
Date: 2015-01-05 16:01:02 Functions: 0 0 -
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 60 0.0 %

           Branch data     Line data    Source code
       1                 :            : /* -*-c-*- */
       2                 :            : 
       3                 :            : %{
       4                 :            : /*
       5                 :            :  * scan_citi.l - scanner for CITIfiles
       6                 :            :  *
       7                 :            :  * Copyright (C) 2006 Stefan Jahn <stefan@lkcc.org>
       8                 :            :  *
       9                 :            :  * This is free software; you can redistribute it and/or modify
      10                 :            :  * it under the terms of the GNU General Public License as published by
      11                 :            :  * the Free Software Foundation; either version 2, or (at your option)
      12                 :            :  * any later version.
      13                 :            :  *
      14                 :            :  * This software is distributed in the hope that it will be useful,
      15                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      16                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      17                 :            :  * GNU General Public License for more details.
      18                 :            :  *
      19                 :            :  * You should have received a copy of the GNU General Public License
      20                 :            :  * along with this package; see the file COPYING.  If not, write to
      21                 :            :  * the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor,
      22                 :            :  * Boston, MA 02110-1301, USA.
      23                 :            :  *
      24                 :            :  * $Id$
      25                 :            :  *
      26                 :            :  */
      27                 :            : 
      28                 :            : #if HAVE_CONFIG_H
      29                 :            : # include <config.h>
      30                 :            : #endif
      31                 :            : 
      32                 :            : #include <stdio.h>
      33                 :            : #include <stdlib.h>
      34                 :            : #include <string.h>
      35                 :            : #include <ctype.h>
      36                 :            : 
      37                 :            : #ifdef __MINGW32__
      38                 :            : #include <io.h>
      39                 :            : #endif
      40                 :            : 
      41                 :            : #ifdef HAVE_UNISTD_H
      42                 :            : #include <unistd.h>
      43                 :            : #endif
      44                 :            : 
      45                 :            : #include "logging.h"
      46                 :            : #include "complex.h"
      47                 :            : #include "object.h"
      48                 :            : #include "vector.h"
      49                 :            : #include "dataset.h"
      50                 :            : #include "check_citi.h"
      51                 :            : #include "tokens_citi.h"
      52                 :            : 
      53                 :            : using namespace qucs;
      54                 :            : 
      55                 :            : %}
      56                 :            : 
      57                 :            : WS       [ \t\n\r]
      58                 :            : ID       [a-zA-Z_][a-zA-Z0-9_\.]*
      59                 :            : DIGIT    [0-9]
      60                 :            : EXPONENT [Ee][+-]?{DIGIT}+
      61                 :            : INT      [+-]?{DIGIT}+
      62                 :            : FLOAT1   [+-]?{DIGIT}+{EXPONENT}
      63                 :            : FLOAT2   [+-]?{DIGIT}*"."{DIGIT}+({EXPONENT})?
      64                 :            : SPACE    [ \t]
      65                 :            : EOL      \r?\n
      66                 :            : 
      67                 :            : %x COMMENTS FLOATS LISTS DATAS VALUES
      68                 :            : %option yylineno noyywrap nounput prefix="citi_"
      69                 :            : 
      70                 :            : %%
      71                 :            : 
      72                 :          0 : <INITIAL,FLOATS,LISTS>{EOL}+ { /* detect end of line */ return Eol; }
      73                 :            : 
      74                 :            : <*>{SPACE} /* skip spaces */
      75         [ #  # ]:          0 : 
      76                 :            : <INITIAL,DATAS>{INT} { /* identify integer */
      77         [ #  # ]:          0 :     citi_lval.d = strtol (citi_text, NULL, 10);
      78                 :          0 :     return Integer;
      79                 :            :   }
      80                 :            : 
      81                 :            : <INITIAL>[a-zA-Z]"."{DIGIT}+"."{DIGIT}+ {
      82         [ #  # ]:          0 :     return Version;
      83                 :            :   }
      84                 :            : 
      85                 :            : <INITIAL,DATAS>("RI"|"MAG"|"MAGANGLE"|"DBANGLE") {
      86         [ #  # ]:          0 :     citi_lval.ident = strdup (citi_text);
      87                 :          0 :     return VarType;
      88                 :            :   }
      89                 :            : 
      90                 :          0 : <INITIAL>^"CITIFILE" { return CITIFILE; }
      91         [ #  # ]:          0 : <INITIAL>^"VAR"      { return VAR; }
      92                 :          0 : <INITIAL>^"DATA"     { BEGIN(DATAS); return DATA; }
      93         [ #  # ]:          0 : <INITIAL>^"NAME"     { return NAME; }
      94         [ #  # ]:          0 : <INITIAL>^"BEGIN"    { BEGIN(FLOATS); return Begin; }
      95         [ #  # ]:          0 : <INITIAL>^"CONSTANT" { BEGIN(VALUES); return CONSTANT; }
      96         [ #  # ]:          0 : <INITIAL>^"COMMENT"  { BEGIN(COMMENTS); }
      97         [ #  # ]:          0 : 
      98         [ #  # ]:          0 : <INITIAL>^"SEG_LIST_BEGIN" { BEGIN(LISTS); return SegListBegin; }
      99         [ #  # ]:          0 : <INITIAL>^"VAR_LIST_BEGIN" { BEGIN(LISTS); return VarListBegin; }
     100                 :          0 : <LISTS>^"SEG_LIST_END" { BEGIN(INITIAL); return SegListEnd; }
     101         [ #  # ]:          0 : <LISTS>^"VAR_LIST_END" { BEGIN(INITIAL); return VarListEnd; }
     102         [ #  # ]:          0 : <LISTS>^"SEG" { return SEG; }
     103         [ #  # ]:          0 : 
     104         [ #  # ]:          0 : <INITIAL,DATAS,VALUES>{ID} { /* identify identifier */
     105         [ #  # ]:          0 :     citi_lval.ident = strdup (citi_text);
     106                 :          0 :     return Identifier;
     107                 :            :   }
     108                 :            : 
     109                 :            : <FLOATS,LISTS,VALUES>({FLOAT1}|{FLOAT2}|{INT}) { /* identify float */
     110         [ #  # ]:          0 :     citi_lval.f = strtod (citi_text, NULL);
     111                 :          0 :     return Float;
     112                 :            :   }
     113                 :            : 
     114                 :          0 : <VALUES>{EOL}+ { BEGIN(INITIAL); return Eol; }
     115                 :            : 
     116         [ #  # ]:          0 : <DATAS>"," { /* pass the ',' to the parser */ return ','; }
     117         [ #  # ]:          0 : <DATAS>"[" { /* pass the '[' to the parser */ return '['; }
     118                 :          0 : <DATAS>"]" { /* pass the ']' to the parser */ BEGIN(INITIAL); return ']'; }
     119         [ #  # ]:          0 : <DATAS>{EOL}+ { BEGIN(INITIAL); return Eol; }
     120         [ #  # ]:          0 : 
     121                 :          0 : <FLOATS>"," { /* pass the ',' to the parser */ return ','; }
     122 [ #  # ][ #  # ]:          0 : 
     123                 :          0 : <FLOATS>^"END" { BEGIN(INITIAL); return End; }
     124         [ #  # ]:          0 : 
     125                 :            : <INITIAL>^"#" { /* leave these characters */
     126         [ #  # ]:          0 :     BEGIN(COMMENTS);
     127                 :            :   }
     128                 :          0 : 
     129                 :            : <COMMENTS>.      { /* skip any character in here */ }
     130         [ #  # ]:          0 : <COMMENTS>{EOL}+ { BEGIN(INITIAL); /* skipping ends here */ }
     131                 :          0 : 
     132                 :            : <*>. { /* any other character in invalid */
     133 [ #  # ][ #  # ]:          0 :     logprint (LOG_ERROR,
     134                 :            :               "line %d: syntax error, unrecognized character: `%s'\n",
     135                 :          0 :               citi_lineno, citi_text);
     136                 :          0 :     return InvalidCharacter;
     137                 :            :   }
     138                 :            : 
     139                 :          0 : %%

Generated by: LCOV version 1.11