I am trying to write a small and simple parser for symbolic specifications in C ++. At first I tried using tools like Yacc / Bison (which I already know) and ANTLR, but they are too cumbersome and complicated for what I'm trying to do.
My tongue has the following binary operators: = (specification) + (sum) . (product); and the following unary operators: Seq (sequence of expressions), Z (###) (a single element that can be numbered), and E (###) (a neutral element that can also be numbered). It should also contain variables. I believe that the priority of linking to the amount and product should be the standard priority.
Here is an example rule system:
A = Seq B
B = Z(1) + Z(2).Z(2).C
C = E(1) + Z(4).Z(4).B
which I would like to analyze on an associative map by indexing expression trees (Seq B) to the variable name (A).
After several additional attempts (e.g. using Python), I determined the perfect tool for this, Spirit in the Boost library. I would like something more closely integrated into the code. And the following StackOverflow provides most of the elements I need:
logical operator (grammar) in C ++
However, Spirit is quite complicated, and the fact that I donβt like the advanced features of C ++ that the library uses - or more than that, I'm not sure how to fix the errors given by my compiler, helps me. My last attempt:
https://gist.github.com/anonymous/354bb84e54042a3b54f3
It will not compile. Even if this happened, Iβm not sure that I understand how I will manipulate the analyzed structure. I'm not sure I'm on the right track.
- ? ?
1: , .
"VAR = EXPR"
EXPR:
EXPR := EXPR + EXPR
| EXPR . EXPR
| Seq EXPR
| Z<digits*> (defaults to zero if not placed)
| E<digits*> (defaults to zero if not placed)
| VAR
VAR := alnum+ (excludes Z## and E##)
:
PP = Z + L1 . R1 + L2 . R2 + L3 . R3 + Seq Z3 . Seq Z4
L1 = Z10.Z9
R1 = Z12.PP + E4
...
:
[ "PP" -> parsing tree that I can navigate for (Z + L1...)
"L1" -> parsing tree for ...
]
PP:
PP = (((((Z + (L1 . R1)) + (L2 . R2)) + (L3 . R3))) + ((Seq Z3) . (Seq Z4)))
, cv_and_he , :
- , ;
- , ;
- , / .
My endgoal - , .
2: :
https://gist.github.com/anonymous/b6a63a1aa5caa6461dd6
, , . :
- ( );
- (, , - -).
3: , : " " , .. , .
4: :
, ?
, . , .