[lemon] Building rules are ok. Need to fixe the build errors now
authorandre ebersold <andre.ebersold@siemens.com>
Thu, 13 Jun 2024 15:03:03 +0000 (17:03 +0200)
committerandre ebersold <andre.ebersold@siemens.com>
Thu, 13 Jun 2024 15:03:03 +0000 (17:03 +0200)
src/properties/CMakeLists.txt
src/properties/reference.lemon
src/properties/reference_lexer.ragel

index 9c229fa3aad5787b8ef0b2c9aedea3d69018df76..279c8739e86d346a62334f15b9fa4ac57b6ab188 100644 (file)
@@ -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
index 36fe8cc65e0e61cfdcf037982d7a64b7fef99ca2..9941c259fcc62209cacae9012663ee35a1f9fe05 100644 (file)
@@ -40,6 +40,7 @@
 #include <reference_parser_base.h>
 }
 
+%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;
+}
+
index 558300d4efe0c6f5553bfc489283c05e1e087ea7..dea1125574209077649cce9f25abe02d5a456a7e 100644 (file)
@@ -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 <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;
+}