neverclaimscan.ll 2.19 KB
Newer Older
1
/* Copyright (C) 2010, 2011 Laboratoire de Recherche et Dveloppement de
2
** l'Epita (LRDE).
Felix Abecassis's avatar
Felix Abecassis committed
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
**
** This file is part of Spot, a model checking library.
**
** Spot is free software; you can redistribute it and/or modify it
** under the terms of the GNU General Public License as published by
** the Free Software Foundation; either version 2 of the License, or
** (at your option) any later version.
**
** Spot is distributed in the hope that it will be useful, but WITHOUT
** ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
** or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
** License for more details.
**
** You should have received a copy of the GNU General Public License
** along with Spot; see the file COPYING.  If not, write to the Free
** Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
** 02111-1307, USA.
*/
%option noyywrap
%option prefix="neverclaimyy"
%option outfile="lex.yy.c"

%{
#include <string>
27
#include "neverparse/parsedecl.hh"
Felix Abecassis's avatar
Felix Abecassis committed
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51

#define YY_USER_ACTION \
  yylloc->columns(yyleng);

#define YY_NEVER_INTERACTIVE 1

typedef neverclaimyy::parser::token token;

%}

eol      \n|\r|\n\r|\r\n

%%

%{
  yylloc->step();
%}

                        /* skip blanks */
{eol}			yylloc->lines(yyleng); yylloc->step();
[ \t]+			yylloc->step();
"/*".*"*/"		yylloc->step();

"never"			return token::NEVER;
52
"skip"			return token::SKIP;
Felix Abecassis's avatar
Felix Abecassis committed
53
"if"			return token::IF;
54
"fi"			return token::FI;
Felix Abecassis's avatar
Felix Abecassis committed
55
56
"->"			return token::ARROW;
"goto"			return token::GOTO;
57
"false"|"0"		return token::FALSE;
Felix Abecassis's avatar
Felix Abecassis committed
58

59
("!"[ \t]+)?"(".*")"|"true"|"1"   {
60
61
62
                          yylval->str = new std::string(yytext, yyleng);
			  return token::FORMULA;
                        }
Felix Abecassis's avatar
Felix Abecassis committed
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101

[a-zA-Z][a-zA-Z0-9_]*   {
			  yylval->str = new std::string(yytext, yyleng);
	                  return token::IDENT;
		        }

.			return *yytext;

%{
  /* Dummy use of yyunput to shut up a gcc warning.  */
  (void) &yyunput;
%}

%%

namespace spot
{
  int
  neverclaimyyopen(const std::string &name)
  {
    if (name == "-")
      {
        yyin = stdin;
      }
    else
      {
        yyin = fopen(name.c_str(), "r");
        if (!yyin)
	  return 1;
      }
    return 0;
  }

  void
  neverclaimyyclose()
  {
    fclose(yyin);
  }
}