#include <reference_parser_base.h>
}
+%token_prefix tk
%stack_size 0
%syntax_error {
}
+phrase(T)::=.
+
+phrase(LH) ::= phrase(RH) chaine(STR).
+phrase(LH) ::= phrase(RH) SPACE.
+phrase(LH) ::= phrase(RH) global_reference(R).
+phrase(LH) ::= phrase(RH) local_reference(R).
+
+global_reference(LH) ::= GLOBAL_REF_BEGIN fragment(F) REF_END.
+
+local_reference(LH) ::= LOCAL_REF_BEGIN fragment(F) REF_END.
+
+
+fragment(LH) ::= chaine(RH).
+
+fragment(LH) ::= SPACE.
+
+fragment(LH) ::= chaine(CH) global_reference(GR).
+fragment(LH) ::= global_reference(GR) chaine(CH).
+fragment(LH) ::= local_reference(GR) chaine(CH).
+fragment(LH) ::= fragment(RH) chaine(CH).
+fragment(LH) ::= fragment(RH) SPACE.
+fragment(LH) ::= fragment(RH) global_reference(GR).
+fragment(LH) ::= fragment(RH) local_reference(LR).
+
+fragment(LH) ::= global_reference(GR).
+fragment(LH) ::= local_reference(LR).
+
+
+function(LF) ::= function_if(RF).
+function(LF) ::= function_not(RF).
+function(LF) ::= function_or(RF).
+function(LF) ::= function_and(RF).
+function(LF) ::= function_isset(RF).
+function(LF) ::= function_filter(RF).
+function(LF) ::= function_filter_out(RF).
+
+function_if(LF) ::= IF three_parameters(PARAM) REF_END.
+
+function_isset(LF) ::= ISSET parameter(PARAM) REF_END.
+
+function_not(LF) ::= NOT function(RFF) REF_END.
+
+function_or(LF) ::= OR parameters(PARAM) REF_END.
+
+function_and(LF) ::= AND parameters(PARAM) REF_END.
+
+function_filter(LF) ::= FILTER three_parameters(PARAM) REF_END.
+
+function_filter_out(LF) ::= FILTER_OUT three_parameters(PARAM) REF_END.
+
+
+parameter(LP) ::= global_reference(RH).
+parameter(LP) ::= local_reference(RH).
+
+parameter(LP) ::= chaine(CH).
+
+parameters(LH) ::= parameter(RH).
+parameters(LH) ::= parameters(RH) VIRGULE parameter(RP).
+
+three_parameters(LH) ::= parameter VIRGULE parameter VIRGULE parameter.
+
+
+chaine(RH)::= CHAINE(T). {
+ RH = T;
+}
+chaine(RH)::= WORD(T). {
+ RH = T;
+}
+
machine reference_lexer;
+ main := |*
+ # space
+ [ \t]+ => { PARSE(tkSPACE); };
+ '$' => { PARSE(tkCHAINE); };
+ '${' => { PARSE(tkSPACE); };
+ '${and' => { PARSE(tkAND); };
+ '${or' => { PARSE(tkOR); };
+ '${if' => { PARSE(tkIF); };
+ '${not' => { PARSE(tkNOT); };
+ [a-z][A-Za-z]* => { PARSE2(tkWORD,std::string(ts,te)); } ;
+ *|;
}%%
#include <string>
#include <cstring>
#include <stdlib.h>
#include <numeric>
+/* For the tokens */
+#include <reference.h>
+
+#define PARSE(x) do {} while(0)
+#define PARSE2(x,y) do {} while(0)
+
+%%write data;
+
+int reference_scanner( std::string &s)
+{
+ int cs,act;
+ unsigned char *ts;
+ unsigned char *te;
+
+ %%write init;
+
+ {
+ unsigned char *p = reinterpret_cast<unsigned char *>(const_cast<char *>(s.c_str()));
+ unsigned char *pe;
+ unsigned char *eof;
+
+ size_t length = s.length();
+ pe = p + length;
+ eof = pe;
+ %%write exec;
+ }
+
+ return 0;
+}