| | |
Eliminate Left Recursive Grammar
Please support our Computer Science advertiser: Learn about neural networks and artificial intelligence.
![]() |
Hello! Im going to be coding a parser program soon but first i need to eliminate Left Recursive Rules from this Grammar - as i will be doing a recursive desent parser.
Ive looked for some tutorials on how to eliminate the problem, but to no avail - they are a wee bit confusing. Some say i may need to introduce a new terminal but im still not so sure how to do this.
Below is the grammer:
and the rules for the left recursive grammar:
I would appreciate it if someone could either point me towards a informative tutorial or could show me which of the above lines follow the second LR rule - i think i can find the ones which follow the first rule.
Thanks very much, if im asking to much just give me some pointers if thats ok
Because i need to understand
Ive looked for some tutorials on how to eliminate the problem, but to no avail - they are a wee bit confusing. Some say i may need to introduce a new terminal but im still not so sure how to do this.
Below is the grammer:
and the rules for the left recursive grammar:
•
•
•
•
The grammar as written is not LL(1); it has left-recursive rules of the form:
<X list> ::= <X> | <X list> separator <X>
and rules of the form:
<something> ::= α X β | α Y γ
where α, β and γ are strings of terminals and/or non-terminals (α non-null) and X and Y are different terminal symbols.
<program> ::= <procedure list> <procedure list> ::= <procedure definition> | <procedure list> ; <procedure definition> <procedure definition> ::= <procedure heading> <block> <procedure heading> ::= procedure identifier is | procedure identifier ( <declaration list> ) is <declaration list> ::= <declaration> | <declaration list> ; <declaration> <declaration> ::= <identifier list> : integer | <identifier list> : float | <identifier list> : string <identifier list> ::= identifier | <identifier list> , identifier <block> ::= <declaration list> <statement part> <statement part> ::= begin <statement list> end <statement list> ::= <statement> | <statement list> ; <statement> <statement> ::= <assignment statement> | <if statement> | <while statement> | <procedure statement> | <until statement> <assignment statement> ::= identifier := <expression> | 4 identifier := stringConstant <if statement> ::= if <condition> then <statement list> end if | if <condition> then <statement list> else <statement list> end if <while statement> ::= while <condition> loop <statement list> end loop <procedure statement> ::= call identifier (<argument list> ) <until statement> ::= do <statement list> until <condition> <argument list> ::= identifier | <argument list> , identifier <condition> ::= identifier <conditional operator> identifier | identifier <conditional operator> numberConstant | identifier <conditional operator> stringConstant <conditional operator> ::= > | >= | = | /= | < | <= <expression> ::= <term> | <expression> + <term> | <expression> - <term> <term> ::= <factor> | <term> * <factor> | <term> / <factor> <factor> ::= identifier | numberConstant | ( <expression> )
I would appreciate it if someone could either point me towards a informative tutorial or could show me which of the above lines follow the second LR rule - i think i can find the ones which follow the first rule.
Thanks very much, if im asking to much just give me some pointers if thats ok
Because i need to understand
![]() |
Similar Threads
- Decimal to Binary Converer (VB.NET)
- how do you reverse a linked list using recursion and return it as a string? (Java)
- Hello and Please Help (Computer Science)
- Syntax Analyser and General Java Help (Java)
- recursive findaverage function for Binary search tree (C)
- Recursive prime number f(x) (C)
Other Threads in the Computer Science Forum
- Previous Thread: Does random data compress?
- Next Thread: Oracle and PostreSQL grammar classes
| Thread Tools | Search this Thread |
ai algorithm algorithms amazon assignment assignmenthelp assignments automata battery bigbrother binary bittorrent bizarre bletchleypark blogging bomb business cern codebreaker compiler computer computers computerscience computertrackingsoftware conversion csc data dataanalysis dataintepretation development dfa dissertation dissertations dissertationthesis dissertationtopic ebook employment energy floatingpoint foreclosuresoftware fuel gadgets geeks givemetehcodez government graphics hardware history homeowners homeworkassignment homeworkhelp humor ibm idea ideas internet iphone ipod itcontracts jobs kindle laser laws linkbait lsmeans mainframes marketing mining mobileapplication msaccess netbeans networking news os p2p piracy piratebay programming research sas science security sex simulation software spying sql study supercomputer supercomputing sweden technology textfield turing turingtest two'scompliment uk virus warehouse ww2





