LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (http://www.linuxquestions.org/questions/programming-9/)
-   -   Grammar/ Parser questions? (http://www.linuxquestions.org/questions/programming-9/grammar-parser-questions-22771/)

JMC 06-06-2002 04:18 PM

Grammar/ Parser questions?
 
I just coded a recursive decent parser for my compiler class however, I think my grammer needs a little help. This is the grammar used:

s --> [ A S ] | ( B ) S | Nothing
A --> A#A | a
B --> ?S, | .S | b

Terminals are [ ] ( ) # ? , .

I figured out that I have to get rid of the left recursion where A is defined and I've discovered the re-write rule to get rid of it. However, the examples I have are pretty trivial.

This is what I think the new correct grammar should be:

S --> [ A S ] | ( B ) S | Nothing
A --> aT
T --> #AT | Nothing
B --> ?S, | .S | b

Do this grammer look correct to you? Thanks for any tips or suggestions!


All times are GMT -5. The time now is 05:29 AM.