From: andre ebersold Date: Thu, 13 Jun 2024 15:03:03 +0000 (+0200) Subject: [lemon] Building rules are ok. Need to fixe the build errors now X-Git-Url: https://git.ebersold.fr/?a=commitdiff_plain;h=2b189f342b86a1b1e29394c420a5e67d726d1e2b;p=antcc.git [lemon] Building rules are ok. Need to fixe the build errors now --- diff --git a/src/properties/CMakeLists.txt b/src/properties/CMakeLists.txt index 9c229fa..279c873 100644 --- a/src/properties/CMakeLists.txt +++ b/src/properties/CMakeLists.txt @@ -36,11 +36,15 @@ ADD_LIBRARY(propertylib property_file.cpp ${PLIB_GEN_SRCS} ) - ADD_EXECUTABLE(test_prop_parser reference_parser.cpp ${PLIB_GEN_SRCS} ) +# Mainly for lemon. It generates a C file that must be compile with C++ +if(WIN32) +target_compile_options(propertylib PRIVATE /Tp) +target_compile_options(test_prop_parser PRIVATE /Tp) +endif() TARGET_LINK_LIBRARIES(test_prop_parser libantcc_parser libantcc_cond libantcc ${EXPAT_LIBRARY}) SET_TARGET_PROPERTIES(test_prop_parser diff --git a/src/properties/reference.lemon b/src/properties/reference.lemon index 36fe8cc..9941c25 100644 --- a/src/properties/reference.lemon +++ b/src/properties/reference.lemon @@ -40,6 +40,7 @@ #include } +%token_prefix tk %stack_size 0 %syntax_error { @@ -88,3 +89,72 @@ value ::= function(F). { } +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; +} + diff --git a/src/properties/reference_lexer.ragel b/src/properties/reference_lexer.ragel index 558300d..dea1125 100644 --- a/src/properties/reference_lexer.ragel +++ b/src/properties/reference_lexer.ragel @@ -4,9 +4,49 @@ 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 #include #include #include +/* For the tokens */ +#include + +#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(const_cast(s.c_str())); + unsigned char *pe; + unsigned char *eof; + + size_t length = s.length(); + pe = p + length; + eof = pe; + %%write exec; + } + + return 0; +}