Enable parsing stand-alone rational expressions with the LTL parser.
* src/ltlparse/ltlparse.yy (parse_ratexp): New function. (START_LTL, START_RATEXP): Add these new tokens. (result): Parse and LTL formula or a rational expression depending on the start symbol. * src/ltlparse/public.hh (parse_ratexp): New function. * src/ltlparse/parsedecl.hh (flex_set_buffer): Add a new argument to set the starting rule. * src/ltlparse/ltlscan.ll (flex_set_buffer): Adjust. (start_token): New global variable. Return this as first token if it is set.
This commit is contained in:
parent
c6dd811b08
commit
9aebb80e08
4 changed files with 92 additions and 19 deletions
|
|
@ -43,14 +43,16 @@
|
|||
|
||||
static const char* to_parse = 0;
|
||||
static size_t to_parse_size = 0;
|
||||
static int start_token = 0;
|
||||
|
||||
typedef ltlyy::parser::token token;
|
||||
|
||||
void
|
||||
flex_set_buffer(const char* buf)
|
||||
flex_set_buffer(const char* buf, int start_tok)
|
||||
{
|
||||
to_parse = buf;
|
||||
to_parse_size = strlen(to_parse);
|
||||
start_token = start_tok;
|
||||
}
|
||||
|
||||
%}
|
||||
|
|
@ -60,6 +62,12 @@ flex_set_buffer(const char* buf)
|
|||
%%
|
||||
|
||||
%{
|
||||
if (start_token)
|
||||
{
|
||||
int t = start_token;
|
||||
start_token = 0;
|
||||
return t;
|
||||
}
|
||||
yylloc->step();
|
||||
%}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue