~tapaal-ltl/verifypn/rule-D-fix

« back to all changes in this revision

Viewing changes to PetriEngine/PQL/PQLQueryTokens.l

  • Committer: Jonas Finnemann Jensen
  • Date: 2011-09-15 13:30:00 UTC
  • Revision ID: jopsen@gmail.com-20110915133000-wnywm1odf82emiuw
Import of sources from github

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
%{
 
2
#include <string>
 
3
#include "PQL.h"
 
4
#include "PQLQueryParser.parser.hpp"
 
5
#define SAVE_TOKEN pqlqlval.string = new std::string(pqlqtext, pqlqleng)
 
6
#define TOKEN(t) (pqlqlval.token = t)
 
7
extern "C" int pqlqwrap(){return 1;}
 
8
extern PetriEngine::PQL::Condition* query;
 
9
extern int pqlqparse();
 
10
%}
 
11
%option prefix="pqlq"
 
12
%option nounput
 
13
 
 
14
digit         [0-9]
 
15
letter        [a-zA-Z_]
 
16
 
 
17
%%
 
18
 
 
19
[ \t\n\r]                                       ;
 
20
"and"                                           {return TOKEN(AND);}
 
21
"AND"                                           {return TOKEN(AND);}
 
22
"or"                                            {return TOKEN(OR);}
 
23
"OR"                                            {return TOKEN(OR);}
 
24
"not"                                           {return TOKEN(NOT);}
 
25
"NOT"                                           {return TOKEN(NOT);}
 
26
{letter}({letter}|{digit})*     {SAVE_TOKEN; return ID;}
 
27
{digit}+                                        {SAVE_TOKEN; return INT;}
 
28
"&&"                                            {return TOKEN(AND);}
 
29
"||"                                            {return TOKEN(OR);}
 
30
"!"                                                     {return TOKEN(NOT);}
 
31
"=="                                            {return TOKEN(EQUAL);}
 
32
"!="                                            {return TOKEN(NEQUAL);}
 
33
"<"                                                     {return TOKEN(LESS);}
 
34
"<="                                            {return TOKEN(LESSEQUAL);}
 
35
">"                                                     {return TOKEN(GREATER);}
 
36
">="                                            {return TOKEN(GREATEREQUAL);}
 
37
"("                                                     {return TOKEN(LPAREN);}
 
38
")"                                                     {return TOKEN(RPAREN);}
 
39
"+"                                                     {return TOKEN(PLUS);}
 
40
"-"                                                     {return TOKEN(MINUS);}
 
41
"*"                                                     {return TOKEN(MULTIPLY);}
 
42
"="                                                     {return TOKEN(EQUAL);}
 
43
.                                                       {printf("Unknown token %s!\n", pqlqtext); yyterminate();}
 
44
 
 
45
%%
 
46
namespace PetriEngine{ namespace PQL {
 
47
Condition* ParseQuery(const std::string& queryString) {
 
48
        query = NULL;
 
49
 
 
50
        //Load up input buffer in Flex
 
51
        YY_BUFFER_STATE buf = pqlq_scan_string(queryString.c_str());
 
52
 
 
53
        if(pqlqparse() != 0)
 
54
                return NULL;
 
55
 
 
56
        //Delete the buffer
 
57
        pqlq_delete_buffer(buf);
 
58
 
 
59
        return query;
 
60
 
61
}}