LL(2) to LL(1) conversion

M

Matthew Bowman

I'm in need of some assistance in converting an LL(2) grammar to an
LL(1) grammar. I'm having difficulties with this. Note: this is for
a school project and the grammar is not my choice. Thanks in advance
for any help. The grammar follows:

<program> ::= <explist>
<explist> ::= <exp> <explist> | E
<idlist> ::= ID <idlist> | E
<exp> ::= '(' ')'
| ID
| NUM
| '(' LAMBDA '(' <idlist> ')' <exp> ')'
| '(' DEFINE '(' ID <idlist> ')' <exp> ')'
| '(' IF <exp> <exp> <exp> ')'
| '(' <exp> <explist> ')'

note: E <=> epsilon

thanks in advance!!!
 
A

Artie Gold

Matthew said:
I'm in need of some assistance in converting an LL(2) grammar to an
LL(1) grammar. I'm having difficulties with this. Note: this is for
a school project and the grammar is not my choice. Thanks in advance
for any help. The grammar follows:

<program> ::= <explist>
<explist> ::= <exp> <explist> | E
<idlist> ::= ID <idlist> | E
<exp> ::= '(' ')'
| ID
| NUM
| '(' LAMBDA '(' <idlist> ')' <exp> ')'
| '(' DEFINE '(' ID <idlist> ')' <exp> ')'
| '(' IF <exp> <exp> <exp> ')'
| '(' <exp> <explist> ')'

note: E <=> epsilon
Alas, as you have no question about the standard C programming
language, you're OFF TOPIC here (which you would have known had
you read the FAQ, etc. etc.)

Try
HTH,
--ag
 
M

Matthew Bowman

Artie said:
Alas, as you have no question about the standard C programming
language, you're OFF TOPIC here

My sincere apologises :)

--
Matthew Bowman
(e-mail address removed)
Computer Science Undergraduate
Georgia Institute of Technology

"Imagination Rules The World!"
 
D

Derk Gwen

(e-mail address removed) (Matthew Bowman) wrote:
# I'm in need of some assistance in converting an LL(2) grammar to an
# LL(1) grammar. I'm having difficulties with this. Note: this is for
# a school project and the grammar is not my choice. Thanks in advance
# for any help. The grammar follows:
#
# <program> ::= <explist>
# <explist> ::= <exp> <explist> | E
# <idlist> ::= ID <idlist> | E
# <exp> ::= '(' ')'
# | ID
# | NUM
# | '(' LAMBDA '(' <idlist> ')' <exp> ')'
# | '(' DEFINE '(' ID <idlist> ')' <exp> ')'
# | '(' IF <exp> <exp> <exp> ')'
# | '(' <exp> <explist> ')'

Left factor.

<exp> ::= (<exp1> | ID | NUM
<exp1> ::= ) | LAMBDA (<idlist>) <exp>) | DEFINE (....................
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,104
Messages
2,570,643
Members
47,247
Latest member
youngcoin

Latest Threads

Top