[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

"dangling else" in SDF



We work with CENTAUR version 1.1 and we have tried to implement the
"dangling else" using your formalism SDF version 1.9. In particular we
have described a small language "If" as follows:

------------------------------------

module If
 
sorts ID STAT
 
lexical syntax
 
[a-z]+                     -> ID
[ \n]                      -> LAYOUT
 
context-free syntax
 
if ID then STAT            -> STAT
if ID then STAT else STAT  -> STAT
stat                       -> STAT

------------------------------------

which presents an evident shift-reduce conflict, but when we try to
analyze the following input 

------------------------------------

if a then if b then if c then stat else stat else stat

------------------------------------

there is not such a conflict ?????????. In relation to this, we have
two questions:

    1. What is the reason, if you use an LR(0) automaton ?
    2. How can I do to implement the "dangling else" ?

Thanks

Manuel Vilares
--------------