From 2824d28a6fd65e0a1f70a1f8b149a198e7e7fa8d Mon Sep 17 00:00:00 2001 From: Erik Oosting Date: Mon, 11 Dec 2023 16:04:26 +0100 Subject: added labels to each rule --- grammar/ANF.g4 | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'grammar/ANF.g4') diff --git a/grammar/ANF.g4 b/grammar/ANF.g4 index 95ab835..408439c 100644 --- a/grammar/ANF.g4 +++ b/grammar/ANF.g4 @@ -1,22 +1,22 @@ grammar ANF; aexp - : IDENT - | NUMBER - | aexp '+' aexp - | aexp '-' aexp - | aexp '*' aexp - | aexp '/' aexp - | '(' IDENT ':' cexp ')' + : IDENT #var + | NUMBER #num + | '(' aexp '+' aexp ')' #add + | '(' aexp '-' aexp ')' #sub + | '(' aexp '*' aexp ')' #mul + | '(' aexp '/' aexp ')' #div + | '(' IDENT ':' cexp ')' #lam ; funcall - : IDENT '(' aexp (',' aexp)* ')' - | aexp + : IDENT '(' aexp (',' aexp)* ')' #call + | aexp #atom ; cexp - : 'let' IDENT '=' funcall 'in' cexp - | funcall + : 'let' IDENT '=' funcall 'in' cexp #let + | funcall #fc ; IDENT: Letter (Letter | Digit)*; -- cgit 1.4.1-2-gfad0