process after Left most derivation i think, im not totally convinced. I am just intrigued of how to create a parser in C#. I've been studying the theory for the past couple of days and I have come into something I don't fully understand which is rightmost and leftmost derivations for example:
Input - aa+a*
and the grammar is S -> SS + | SS * | a
S -> SS + | SS * | a
My Solution: S | S+S | S S+S | a+S S | AA+S A | AA + A obviously my paper solution had interior leaves and what not.
I have a solution for this just not convinced its right in the parser tree. Any solutions would be very much appreciated. anybody know the right solution including the parse tree?
Parse Tree
| |==| a | | |==|==| a | | | | + | |==| a | | *
How do I build this tree?
given a -> shift (a) given a -> shift (a) given + -> reduce ((a) (a) +) given a -> shift (a) given * -> reduce (((a) (a) +) (a) *)
This parse tree
- S
-
- S
-
- S
- a
-
- S
- a
- +
-
- S
- a
- '*'
is produced by this Perl script using a general BNF parser . Hope this will help you test various grammar/input combinations you may have.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.