Grammar ruls for the compiler-compiler

I did find back some sheets with examples of the grammar. Here is one for an IF-THEN-ELSE-FI statement:
(struc xxfif
       (open "IF" < cond < < (sit a))
     a (struc xxfall)
       (special "THEN" > (trans trstat) < (sit b))
       (ill "ELSE" "then missing")
       (ill "ELIF" "then missing")
       (ill "FI" "then-else missing")
     b (struc xxfall)
       (special _; > (trans trstat) <)
       (special "ELSE" > (trans trstat) > < T < (sit c))
       (ill "THEN" "double then")
       (special "ELIF" > (trans trstat) > < < (sit a))
       (close "FI" > (trans trstat) > > )
     c (struc xxfall)
       (special _; > (trans trstat) < )
       (close "FI" > (trans trstat) > > )
       (ill "THEN" "then after else")
       (ill "ELSE" "double else")
)
Note that all non-terminals start with "xxf". The parser was a two level parser. The first level would parse the big parts, like the above IF-THEN-ELSE-FI statement, and the second level would parse the smaller parts, like the expressions inside the parts. The (trans trstat) indicates the activation of the second level parsing, according to the "trstat" rules of the previous part. The `<' and `>' are transformed into the `(' and `)' brackets in the output. Some rules for the second level parsing are:
(mdiop xxfosd set setq scons sappend splus smin snext schange smap add)
(diop sets sets :=)
(diop scons scons :=+c)
(diop sappend sappend :=+a)
(diop splus splus :=+)
(diop smin smin :=-)
(diop snext snext :=next)
(diop schange schange :=:)
(diop smap smap :=map)
(diop add add :=add)
(mmonop xxfosm sadd1 ssub1)
(forward xxfos xxfosd xxfosm sets scons sappend
        splus smin snext schange smap)

(mdiop xxfomd map mapc maplist mapcon mapcar)
(backward xxfom xxfomd)

(diop or or or)
(mdiop xxfosor cons append pair)
(diop cons cons +c)
(diop append append +c)
(diop pair pair +p)
(forward xxfolor xxfosor cons append pair)

(diop and and and)
(forward xxfoland and)

(monop not not not)
(forward xxfolnot not)

(mdiop xxfoltd atom null numberp member memq)
Don't ask me what it means exactly, but it seems to define diadic operators (diop) and monadic operators (monop) which and their associativeness (forward and backward), and the order of the definitions seems to imply priorities.


home and email