M. Sperber, H. Klaeren Wintersemester 1998/99
Compilerbau I
Blatt 5
Abgabe: 24.11.1998
1 + 1 + 1. Geben Sie -- gemäß der Angaben
über Präzedenz und Assoziativität im Caml-Handbuch -- eine
äquivalente eindeutige Grammatik an.
\:
\|
`=13
¯
¯
exp
\:
literal
\|
ident
\| (
operator-name
)
\| (
exp
)
\|
exp
exp
\|
prefix-symbol
exp
\|
exp
infix-symbol
exp
\| if
exp
then
exp
else
exp
\|
exp
or
exp
\|
exp
&
exp
\|
exp
;
exp
\| function
ident
->
exp
\| raise
exp
\| try
exp
with
ident
->
exp
\| let rec
let-binding
more-bindings
in
exp
\| [
sequence
]
literal
\: ( ) \|
integer-literal
\|
character-literal
\|
string-literal
operator-name
\:
infix-symbol
\|
prefix-symbol
sequence
\:
empty
\|
exp
sequence-rest
sequence-rest
\: ;
exp
let-binding
\:
ident
=
exp
more-bindings
\: and
let-binding
definition
\: let rec
let-binding
more-bindings
program
\:
definition
type 'ident syntax =
Nil
| Int of int
| String of string
| Char of char
| Ident of 'ident
| Builtin of 'ident
| Apply of 'ident syntax * 'ident syntax
| If of 'ident syntax * 'ident syntax * 'ident syntax
| Sequence of 'ident syntax * 'ident syntax
| Function of 'ident * 'ident syntax
| Raise of 'ident syntax
| Try of 'ident syntax * 'ident * 'ident syntax
| Let of 'ident binding * 'ident syntax
| Letrec of 'ident binding list * 'ident syntax
and 'ident binding = 'ident * 'ident syntax
type 'ident definition = 'ident binding list
type 'ident program = 'ident definition list