fp-il

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

commit 60c8f636596de722a91f9dba1f2ae631a61a6484
parent 2824d28a6fd65e0a1f70a1f8b149a198e7e7fa8d
Author: Erik Oosting <crazazy@tilde.cafe>
Date:   Mon, 11 Dec 2023 16:11:59 +0100

add more operators

Diffstat:
Mgen/ANF.interp | 24++++++++++++++++++++++--
Mgen/ANF.tokens | 48++++++++++++++++++++++++++++++++++--------------
Mgen/ANFLexer.interp | 34++++++++++++++++++++++++++++++++--
Mgen/ANFLexer.py | 98+++++++++++++++++++++++++++++++++++++++++++++++++++----------------------------
Mgen/ANFLexer.tokens | 48++++++++++++++++++++++++++++++++++--------------
Mgen/ANFListener.py | 90+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mgen/ANFParser.py | 639++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-------------
Mgen/ANFVisitor.py | 50++++++++++++++++++++++++++++++++++++++++++++++++++
Mgrammar/ANF.g4 | 13++++++++++++-
9 files changed, 874 insertions(+), 170 deletions(-)

diff --git a/gen/ANF.interp b/gen/ANF.interp @@ -1,11 +1,21 @@ token literal names: null +'true' +'false' '(' '+' ')' '-' '*' '/' +'>' +'<' +'==' +'<<' +'>>' +'&&' +'||' +'^^' ':' ',' 'let' @@ -28,6 +38,16 @@ null null null null +null +null +null +null +null +null +null +null +null +null IDENT NUMBER WS @@ -39,4 +59,4 @@ cexp atn: -[4, 1, 14, 66, 2, 0, 7, 0, 2, 1, 7, 1, 2, 2, 7, 2, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 3, 0, 39, 8, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 5, 1, 46, 8, 1, 10, 1, 12, 1, 49, 9, 1, 1, 1, 1, 1, 1, 1, 3, 1, 54, 8, 1, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 3, 2, 64, 8, 2, 1, 2, 0, 0, 3, 0, 2, 4, 0, 0, 71, 0, 38, 1, 0, 0, 0, 2, 53, 1, 0, 0, 0, 4, 63, 1, 0, 0, 0, 6, 39, 5, 12, 0, 0, 7, 39, 5, 13, 0, 0, 8, 9, 5, 1, 0, 0, 9, 10, 3, 0, 0, 0, 10, 11, 5, 2, 0, 0, 11, 12, 3, 0, 0, 0, 12, 13, 5, 3, 0, 0, 13, 39, 1, 0, 0, 0, 14, 15, 5, 1, 0, 0, 15, 16, 3, 0, 0, 0, 16, 17, 5, 4, 0, 0, 17, 18, 3, 0, 0, 0, 18, 19, 5, 3, 0, 0, 19, 39, 1, 0, 0, 0, 20, 21, 5, 1, 0, 0, 21, 22, 3, 0, 0, 0, 22, 23, 5, 5, 0, 0, 23, 24, 3, 0, 0, 0, 24, 25, 5, 3, 0, 0, 25, 39, 1, 0, 0, 0, 26, 27, 5, 1, 0, 0, 27, 28, 3, 0, 0, 0, 28, 29, 5, 6, 0, 0, 29, 30, 3, 0, 0, 0, 30, 31, 5, 3, 0, 0, 31, 39, 1, 0, 0, 0, 32, 33, 5, 1, 0, 0, 33, 34, 5, 12, 0, 0, 34, 35, 5, 7, 0, 0, 35, 36, 3, 4, 2, 0, 36, 37, 5, 3, 0, 0, 37, 39, 1, 0, 0, 0, 38, 6, 1, 0, 0, 0, 38, 7, 1, 0, 0, 0, 38, 8, 1, 0, 0, 0, 38, 14, 1, 0, 0, 0, 38, 20, 1, 0, 0, 0, 38, 26, 1, 0, 0, 0, 38, 32, 1, 0, 0, 0, 39, 1, 1, 0, 0, 0, 40, 41, 5, 12, 0, 0, 41, 42, 5, 1, 0, 0, 42, 47, 3, 0, 0, 0, 43, 44, 5, 8, 0, 0, 44, 46, 3, 0, 0, 0, 45, 43, 1, 0, 0, 0, 46, 49, 1, 0, 0, 0, 47, 45, 1, 0, 0, 0, 47, 48, 1, 0, 0, 0, 48, 50, 1, 0, 0, 0, 49, 47, 1, 0, 0, 0, 50, 51, 5, 3, 0, 0, 51, 54, 1, 0, 0, 0, 52, 54, 3, 0, 0, 0, 53, 40, 1, 0, 0, 0, 53, 52, 1, 0, 0, 0, 54, 3, 1, 0, 0, 0, 55, 56, 5, 9, 0, 0, 56, 57, 5, 12, 0, 0, 57, 58, 5, 10, 0, 0, 58, 59, 3, 2, 1, 0, 59, 60, 5, 11, 0, 0, 60, 61, 3, 4, 2, 0, 61, 64, 1, 0, 0, 0, 62, 64, 3, 2, 1, 0, 63, 55, 1, 0, 0, 0, 63, 62, 1, 0, 0, 0, 64, 5, 1, 0, 0, 0, 4, 38, 47, 53, 63]- \ No newline at end of file +[4, 1, 24, 116, 2, 0, 7, 0, 2, 1, 7, 1, 2, 2, 7, 2, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 3, 0, 89, 8, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 5, 1, 96, 8, 1, 10, 1, 12, 1, 99, 9, 1, 1, 1, 1, 1, 1, 1, 3, 1, 104, 8, 1, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 3, 2, 114, 8, 2, 1, 2, 0, 0, 3, 0, 2, 4, 0, 0, 131, 0, 88, 1, 0, 0, 0, 2, 103, 1, 0, 0, 0, 4, 113, 1, 0, 0, 0, 6, 89, 5, 1, 0, 0, 7, 89, 5, 2, 0, 0, 8, 89, 5, 22, 0, 0, 9, 89, 5, 23, 0, 0, 10, 11, 5, 3, 0, 0, 11, 12, 3, 0, 0, 0, 12, 13, 5, 4, 0, 0, 13, 14, 3, 0, 0, 0, 14, 15, 5, 5, 0, 0, 15, 89, 1, 0, 0, 0, 16, 17, 5, 3, 0, 0, 17, 18, 3, 0, 0, 0, 18, 19, 5, 6, 0, 0, 19, 20, 3, 0, 0, 0, 20, 21, 5, 5, 0, 0, 21, 89, 1, 0, 0, 0, 22, 23, 5, 3, 0, 0, 23, 24, 3, 0, 0, 0, 24, 25, 5, 7, 0, 0, 25, 26, 3, 0, 0, 0, 26, 27, 5, 5, 0, 0, 27, 89, 1, 0, 0, 0, 28, 29, 5, 3, 0, 0, 29, 30, 3, 0, 0, 0, 30, 31, 5, 8, 0, 0, 31, 32, 3, 0, 0, 0, 32, 33, 5, 5, 0, 0, 33, 89, 1, 0, 0, 0, 34, 35, 5, 3, 0, 0, 35, 36, 3, 0, 0, 0, 36, 37, 5, 9, 0, 0, 37, 38, 3, 0, 0, 0, 38, 39, 5, 5, 0, 0, 39, 89, 1, 0, 0, 0, 40, 41, 5, 3, 0, 0, 41, 42, 3, 0, 0, 0, 42, 43, 5, 10, 0, 0, 43, 44, 3, 0, 0, 0, 44, 45, 5, 5, 0, 0, 45, 89, 1, 0, 0, 0, 46, 47, 5, 3, 0, 0, 47, 48, 3, 0, 0, 0, 48, 49, 5, 11, 0, 0, 49, 50, 3, 0, 0, 0, 50, 51, 5, 5, 0, 0, 51, 89, 1, 0, 0, 0, 52, 53, 5, 3, 0, 0, 53, 54, 3, 0, 0, 0, 54, 55, 5, 12, 0, 0, 55, 56, 3, 0, 0, 0, 56, 57, 5, 5, 0, 0, 57, 89, 1, 0, 0, 0, 58, 59, 5, 3, 0, 0, 59, 60, 3, 0, 0, 0, 60, 61, 5, 13, 0, 0, 61, 62, 3, 0, 0, 0, 62, 63, 5, 5, 0, 0, 63, 89, 1, 0, 0, 0, 64, 65, 5, 3, 0, 0, 65, 66, 3, 0, 0, 0, 66, 67, 5, 14, 0, 0, 67, 68, 3, 0, 0, 0, 68, 69, 5, 5, 0, 0, 69, 89, 1, 0, 0, 0, 70, 71, 5, 3, 0, 0, 71, 72, 3, 0, 0, 0, 72, 73, 5, 15, 0, 0, 73, 74, 3, 0, 0, 0, 74, 75, 5, 5, 0, 0, 75, 89, 1, 0, 0, 0, 76, 77, 5, 3, 0, 0, 77, 78, 3, 0, 0, 0, 78, 79, 5, 16, 0, 0, 79, 80, 3, 0, 0, 0, 80, 81, 5, 5, 0, 0, 81, 89, 1, 0, 0, 0, 82, 83, 5, 3, 0, 0, 83, 84, 5, 22, 0, 0, 84, 85, 5, 17, 0, 0, 85, 86, 3, 4, 2, 0, 86, 87, 5, 5, 0, 0, 87, 89, 1, 0, 0, 0, 88, 6, 1, 0, 0, 0, 88, 7, 1, 0, 0, 0, 88, 8, 1, 0, 0, 0, 88, 9, 1, 0, 0, 0, 88, 10, 1, 0, 0, 0, 88, 16, 1, 0, 0, 0, 88, 22, 1, 0, 0, 0, 88, 28, 1, 0, 0, 0, 88, 34, 1, 0, 0, 0, 88, 40, 1, 0, 0, 0, 88, 46, 1, 0, 0, 0, 88, 52, 1, 0, 0, 0, 88, 58, 1, 0, 0, 0, 88, 64, 1, 0, 0, 0, 88, 70, 1, 0, 0, 0, 88, 76, 1, 0, 0, 0, 88, 82, 1, 0, 0, 0, 89, 1, 1, 0, 0, 0, 90, 91, 5, 22, 0, 0, 91, 92, 5, 3, 0, 0, 92, 97, 3, 0, 0, 0, 93, 94, 5, 18, 0, 0, 94, 96, 3, 0, 0, 0, 95, 93, 1, 0, 0, 0, 96, 99, 1, 0, 0, 0, 97, 95, 1, 0, 0, 0, 97, 98, 1, 0, 0, 0, 98, 100, 1, 0, 0, 0, 99, 97, 1, 0, 0, 0, 100, 101, 5, 5, 0, 0, 101, 104, 1, 0, 0, 0, 102, 104, 3, 0, 0, 0, 103, 90, 1, 0, 0, 0, 103, 102, 1, 0, 0, 0, 104, 3, 1, 0, 0, 0, 105, 106, 5, 19, 0, 0, 106, 107, 5, 22, 0, 0, 107, 108, 5, 20, 0, 0, 108, 109, 3, 2, 1, 0, 109, 110, 5, 21, 0, 0, 110, 111, 3, 4, 2, 0, 111, 114, 1, 0, 0, 0, 112, 114, 3, 2, 1, 0, 113, 105, 1, 0, 0, 0, 113, 112, 1, 0, 0, 0, 114, 5, 1, 0, 0, 0, 4, 88, 97, 103, 113]+ \ No newline at end of file diff --git a/gen/ANF.tokens b/gen/ANF.tokens @@ -9,17 +9,37 @@ T__7=8 T__8=9 T__9=10 T__10=11 -IDENT=12 -NUMBER=13 -WS=14 -'('=1 -'+'=2 -')'=3 -'-'=4 -'*'=5 -'/'=6 -':'=7 -','=8 -'let'=9 -'='=10 -'in'=11 +T__11=12 +T__12=13 +T__13=14 +T__14=15 +T__15=16 +T__16=17 +T__17=18 +T__18=19 +T__19=20 +T__20=21 +IDENT=22 +NUMBER=23 +WS=24 +'true'=1 +'false'=2 +'('=3 +'+'=4 +')'=5 +'-'=6 +'*'=7 +'/'=8 +'>'=9 +'<'=10 +'=='=11 +'<<'=12 +'>>'=13 +'&&'=14 +'||'=15 +'^^'=16 +':'=17 +','=18 +'let'=19 +'='=20 +'in'=21 diff --git a/gen/ANFLexer.interp b/gen/ANFLexer.interp @@ -1,11 +1,21 @@ token literal names: null +'true' +'false' '(' '+' ')' '-' '*' '/' +'>' +'<' +'==' +'<<' +'>>' +'&&' +'||' +'^^' ':' ',' 'let' @@ -28,6 +38,16 @@ null null null null +null +null +null +null +null +null +null +null +null +null IDENT NUMBER WS @@ -44,6 +64,16 @@ T__7 T__8 T__9 T__10 +T__11 +T__12 +T__13 +T__14 +T__15 +T__16 +T__17 +T__18 +T__19 +T__20 IDENT NUMBER Letter @@ -58,4 +88,4 @@ mode names: DEFAULT_MODE atn: -[4, 0, 14, 82, 6, -1, 2, 0, 7, 0, 2, 1, 7, 1, 2, 2, 7, 2, 2, 3, 7, 3, 2, 4, 7, 4, 2, 5, 7, 5, 2, 6, 7, 6, 2, 7, 7, 7, 2, 8, 7, 8, 2, 9, 7, 9, 2, 10, 7, 10, 2, 11, 7, 11, 2, 12, 7, 12, 2, 13, 7, 13, 2, 14, 7, 14, 2, 15, 7, 15, 1, 0, 1, 0, 1, 1, 1, 1, 1, 2, 1, 2, 1, 3, 1, 3, 1, 4, 1, 4, 1, 5, 1, 5, 1, 6, 1, 6, 1, 7, 1, 7, 1, 8, 1, 8, 1, 8, 1, 8, 1, 9, 1, 9, 1, 10, 1, 10, 1, 10, 1, 11, 1, 11, 1, 11, 5, 11, 62, 8, 11, 10, 11, 12, 11, 65, 9, 11, 1, 12, 4, 12, 68, 8, 12, 11, 12, 12, 12, 69, 1, 13, 1, 13, 1, 14, 1, 14, 1, 15, 4, 15, 77, 8, 15, 11, 15, 12, 15, 78, 1, 15, 1, 15, 0, 0, 16, 1, 1, 3, 2, 5, 3, 7, 4, 9, 5, 11, 6, 13, 7, 15, 8, 17, 9, 19, 10, 21, 11, 23, 12, 25, 13, 27, 0, 29, 0, 31, 14, 1, 0, 2, 2, 0, 65, 90, 97, 122, 3, 0, 9, 10, 13, 13, 32, 32, 83, 0, 1, 1, 0, 0, 0, 0, 3, 1, 0, 0, 0, 0, 5, 1, 0, 0, 0, 0, 7, 1, 0, 0, 0, 0, 9, 1, 0, 0, 0, 0, 11, 1, 0, 0, 0, 0, 13, 1, 0, 0, 0, 0, 15, 1, 0, 0, 0, 0, 17, 1, 0, 0, 0, 0, 19, 1, 0, 0, 0, 0, 21, 1, 0, 0, 0, 0, 23, 1, 0, 0, 0, 0, 25, 1, 0, 0, 0, 0, 31, 1, 0, 0, 0, 1, 33, 1, 0, 0, 0, 3, 35, 1, 0, 0, 0, 5, 37, 1, 0, 0, 0, 7, 39, 1, 0, 0, 0, 9, 41, 1, 0, 0, 0, 11, 43, 1, 0, 0, 0, 13, 45, 1, 0, 0, 0, 15, 47, 1, 0, 0, 0, 17, 49, 1, 0, 0, 0, 19, 53, 1, 0, 0, 0, 21, 55, 1, 0, 0, 0, 23, 58, 1, 0, 0, 0, 25, 67, 1, 0, 0, 0, 27, 71, 1, 0, 0, 0, 29, 73, 1, 0, 0, 0, 31, 76, 1, 0, 0, 0, 33, 34, 5, 40, 0, 0, 34, 2, 1, 0, 0, 0, 35, 36, 5, 43, 0, 0, 36, 4, 1, 0, 0, 0, 37, 38, 5, 41, 0, 0, 38, 6, 1, 0, 0, 0, 39, 40, 5, 45, 0, 0, 40, 8, 1, 0, 0, 0, 41, 42, 5, 42, 0, 0, 42, 10, 1, 0, 0, 0, 43, 44, 5, 47, 0, 0, 44, 12, 1, 0, 0, 0, 45, 46, 5, 58, 0, 0, 46, 14, 1, 0, 0, 0, 47, 48, 5, 44, 0, 0, 48, 16, 1, 0, 0, 0, 49, 50, 5, 108, 0, 0, 50, 51, 5, 101, 0, 0, 51, 52, 5, 116, 0, 0, 52, 18, 1, 0, 0, 0, 53, 54, 5, 61, 0, 0, 54, 20, 1, 0, 0, 0, 55, 56, 5, 105, 0, 0, 56, 57, 5, 110, 0, 0, 57, 22, 1, 0, 0, 0, 58, 63, 3, 27, 13, 0, 59, 62, 3, 27, 13, 0, 60, 62, 3, 29, 14, 0, 61, 59, 1, 0, 0, 0, 61, 60, 1, 0, 0, 0, 62, 65, 1, 0, 0, 0, 63, 61, 1, 0, 0, 0, 63, 64, 1, 0, 0, 0, 64, 24, 1, 0, 0, 0, 65, 63, 1, 0, 0, 0, 66, 68, 3, 29, 14, 0, 67, 66, 1, 0, 0, 0, 68, 69, 1, 0, 0, 0, 69, 67, 1, 0, 0, 0, 69, 70, 1, 0, 0, 0, 70, 26, 1, 0, 0, 0, 71, 72, 7, 0, 0, 0, 72, 28, 1, 0, 0, 0, 73, 74, 2, 48, 57, 0, 74, 30, 1, 0, 0, 0, 75, 77, 7, 1, 0, 0, 76, 75, 1, 0, 0, 0, 77, 78, 1, 0, 0, 0, 78, 76, 1, 0, 0, 0, 78, 79, 1, 0, 0, 0, 79, 80, 1, 0, 0, 0, 80, 81, 6, 15, 0, 0, 81, 32, 1, 0, 0, 0, 5, 0, 61, 63, 69, 78, 1, 6, 0, 0]- \ No newline at end of file +[4, 0, 24, 135, 6, -1, 2, 0, 7, 0, 2, 1, 7, 1, 2, 2, 7, 2, 2, 3, 7, 3, 2, 4, 7, 4, 2, 5, 7, 5, 2, 6, 7, 6, 2, 7, 7, 7, 2, 8, 7, 8, 2, 9, 7, 9, 2, 10, 7, 10, 2, 11, 7, 11, 2, 12, 7, 12, 2, 13, 7, 13, 2, 14, 7, 14, 2, 15, 7, 15, 2, 16, 7, 16, 2, 17, 7, 17, 2, 18, 7, 18, 2, 19, 7, 19, 2, 20, 7, 20, 2, 21, 7, 21, 2, 22, 7, 22, 2, 23, 7, 23, 2, 24, 7, 24, 2, 25, 7, 25, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 2, 1, 3, 1, 3, 1, 4, 1, 4, 1, 5, 1, 5, 1, 6, 1, 6, 1, 7, 1, 7, 1, 8, 1, 8, 1, 9, 1, 9, 1, 10, 1, 10, 1, 10, 1, 11, 1, 11, 1, 11, 1, 12, 1, 12, 1, 12, 1, 13, 1, 13, 1, 13, 1, 14, 1, 14, 1, 14, 1, 15, 1, 15, 1, 15, 1, 16, 1, 16, 1, 17, 1, 17, 1, 18, 1, 18, 1, 18, 1, 18, 1, 19, 1, 19, 1, 20, 1, 20, 1, 20, 1, 21, 1, 21, 1, 21, 5, 21, 115, 8, 21, 10, 21, 12, 21, 118, 9, 21, 1, 22, 4, 22, 121, 8, 22, 11, 22, 12, 22, 122, 1, 23, 1, 23, 1, 24, 1, 24, 1, 25, 4, 25, 130, 8, 25, 11, 25, 12, 25, 131, 1, 25, 1, 25, 0, 0, 26, 1, 1, 3, 2, 5, 3, 7, 4, 9, 5, 11, 6, 13, 7, 15, 8, 17, 9, 19, 10, 21, 11, 23, 12, 25, 13, 27, 14, 29, 15, 31, 16, 33, 17, 35, 18, 37, 19, 39, 20, 41, 21, 43, 22, 45, 23, 47, 0, 49, 0, 51, 24, 1, 0, 2, 2, 0, 65, 90, 97, 122, 3, 0, 9, 10, 13, 13, 32, 32, 136, 0, 1, 1, 0, 0, 0, 0, 3, 1, 0, 0, 0, 0, 5, 1, 0, 0, 0, 0, 7, 1, 0, 0, 0, 0, 9, 1, 0, 0, 0, 0, 11, 1, 0, 0, 0, 0, 13, 1, 0, 0, 0, 0, 15, 1, 0, 0, 0, 0, 17, 1, 0, 0, 0, 0, 19, 1, 0, 0, 0, 0, 21, 1, 0, 0, 0, 0, 23, 1, 0, 0, 0, 0, 25, 1, 0, 0, 0, 0, 27, 1, 0, 0, 0, 0, 29, 1, 0, 0, 0, 0, 31, 1, 0, 0, 0, 0, 33, 1, 0, 0, 0, 0, 35, 1, 0, 0, 0, 0, 37, 1, 0, 0, 0, 0, 39, 1, 0, 0, 0, 0, 41, 1, 0, 0, 0, 0, 43, 1, 0, 0, 0, 0, 45, 1, 0, 0, 0, 0, 51, 1, 0, 0, 0, 1, 53, 1, 0, 0, 0, 3, 58, 1, 0, 0, 0, 5, 64, 1, 0, 0, 0, 7, 66, 1, 0, 0, 0, 9, 68, 1, 0, 0, 0, 11, 70, 1, 0, 0, 0, 13, 72, 1, 0, 0, 0, 15, 74, 1, 0, 0, 0, 17, 76, 1, 0, 0, 0, 19, 78, 1, 0, 0, 0, 21, 80, 1, 0, 0, 0, 23, 83, 1, 0, 0, 0, 25, 86, 1, 0, 0, 0, 27, 89, 1, 0, 0, 0, 29, 92, 1, 0, 0, 0, 31, 95, 1, 0, 0, 0, 33, 98, 1, 0, 0, 0, 35, 100, 1, 0, 0, 0, 37, 102, 1, 0, 0, 0, 39, 106, 1, 0, 0, 0, 41, 108, 1, 0, 0, 0, 43, 111, 1, 0, 0, 0, 45, 120, 1, 0, 0, 0, 47, 124, 1, 0, 0, 0, 49, 126, 1, 0, 0, 0, 51, 129, 1, 0, 0, 0, 53, 54, 5, 116, 0, 0, 54, 55, 5, 114, 0, 0, 55, 56, 5, 117, 0, 0, 56, 57, 5, 101, 0, 0, 57, 2, 1, 0, 0, 0, 58, 59, 5, 102, 0, 0, 59, 60, 5, 97, 0, 0, 60, 61, 5, 108, 0, 0, 61, 62, 5, 115, 0, 0, 62, 63, 5, 101, 0, 0, 63, 4, 1, 0, 0, 0, 64, 65, 5, 40, 0, 0, 65, 6, 1, 0, 0, 0, 66, 67, 5, 43, 0, 0, 67, 8, 1, 0, 0, 0, 68, 69, 5, 41, 0, 0, 69, 10, 1, 0, 0, 0, 70, 71, 5, 45, 0, 0, 71, 12, 1, 0, 0, 0, 72, 73, 5, 42, 0, 0, 73, 14, 1, 0, 0, 0, 74, 75, 5, 47, 0, 0, 75, 16, 1, 0, 0, 0, 76, 77, 5, 62, 0, 0, 77, 18, 1, 0, 0, 0, 78, 79, 5, 60, 0, 0, 79, 20, 1, 0, 0, 0, 80, 81, 5, 61, 0, 0, 81, 82, 5, 61, 0, 0, 82, 22, 1, 0, 0, 0, 83, 84, 5, 60, 0, 0, 84, 85, 5, 60, 0, 0, 85, 24, 1, 0, 0, 0, 86, 87, 5, 62, 0, 0, 87, 88, 5, 62, 0, 0, 88, 26, 1, 0, 0, 0, 89, 90, 5, 38, 0, 0, 90, 91, 5, 38, 0, 0, 91, 28, 1, 0, 0, 0, 92, 93, 5, 124, 0, 0, 93, 94, 5, 124, 0, 0, 94, 30, 1, 0, 0, 0, 95, 96, 5, 94, 0, 0, 96, 97, 5, 94, 0, 0, 97, 32, 1, 0, 0, 0, 98, 99, 5, 58, 0, 0, 99, 34, 1, 0, 0, 0, 100, 101, 5, 44, 0, 0, 101, 36, 1, 0, 0, 0, 102, 103, 5, 108, 0, 0, 103, 104, 5, 101, 0, 0, 104, 105, 5, 116, 0, 0, 105, 38, 1, 0, 0, 0, 106, 107, 5, 61, 0, 0, 107, 40, 1, 0, 0, 0, 108, 109, 5, 105, 0, 0, 109, 110, 5, 110, 0, 0, 110, 42, 1, 0, 0, 0, 111, 116, 3, 47, 23, 0, 112, 115, 3, 47, 23, 0, 113, 115, 3, 49, 24, 0, 114, 112, 1, 0, 0, 0, 114, 113, 1, 0, 0, 0, 115, 118, 1, 0, 0, 0, 116, 114, 1, 0, 0, 0, 116, 117, 1, 0, 0, 0, 117, 44, 1, 0, 0, 0, 118, 116, 1, 0, 0, 0, 119, 121, 3, 49, 24, 0, 120, 119, 1, 0, 0, 0, 121, 122, 1, 0, 0, 0, 122, 120, 1, 0, 0, 0, 122, 123, 1, 0, 0, 0, 123, 46, 1, 0, 0, 0, 124, 125, 7, 0, 0, 0, 125, 48, 1, 0, 0, 0, 126, 127, 2, 48, 57, 0, 127, 50, 1, 0, 0, 0, 128, 130, 7, 1, 0, 0, 129, 128, 1, 0, 0, 0, 130, 131, 1, 0, 0, 0, 131, 129, 1, 0, 0, 0, 131, 132, 1, 0, 0, 0, 132, 133, 1, 0, 0, 0, 133, 134, 6, 25, 0, 0, 134, 52, 1, 0, 0, 0, 5, 0, 114, 116, 122, 131, 1, 6, 0, 0]+ \ No newline at end of file diff --git a/gen/ANFLexer.py b/gen/ANFLexer.py @@ -10,33 +10,51 @@ else: def serializedATN(): return [ - 4,0,14,82,6,-1,2,0,7,0,2,1,7,1,2,2,7,2,2,3,7,3,2,4,7,4,2,5,7,5,2, - 6,7,6,2,7,7,7,2,8,7,8,2,9,7,9,2,10,7,10,2,11,7,11,2,12,7,12,2,13, - 7,13,2,14,7,14,2,15,7,15,1,0,1,0,1,1,1,1,1,2,1,2,1,3,1,3,1,4,1,4, - 1,5,1,5,1,6,1,6,1,7,1,7,1,8,1,8,1,8,1,8,1,9,1,9,1,10,1,10,1,10,1, - 11,1,11,1,11,5,11,62,8,11,10,11,12,11,65,9,11,1,12,4,12,68,8,12, - 11,12,12,12,69,1,13,1,13,1,14,1,14,1,15,4,15,77,8,15,11,15,12,15, - 78,1,15,1,15,0,0,16,1,1,3,2,5,3,7,4,9,5,11,6,13,7,15,8,17,9,19,10, - 21,11,23,12,25,13,27,0,29,0,31,14,1,0,2,2,0,65,90,97,122,3,0,9,10, - 13,13,32,32,83,0,1,1,0,0,0,0,3,1,0,0,0,0,5,1,0,0,0,0,7,1,0,0,0,0, - 9,1,0,0,0,0,11,1,0,0,0,0,13,1,0,0,0,0,15,1,0,0,0,0,17,1,0,0,0,0, - 19,1,0,0,0,0,21,1,0,0,0,0,23,1,0,0,0,0,25,1,0,0,0,0,31,1,0,0,0,1, - 33,1,0,0,0,3,35,1,0,0,0,5,37,1,0,0,0,7,39,1,0,0,0,9,41,1,0,0,0,11, - 43,1,0,0,0,13,45,1,0,0,0,15,47,1,0,0,0,17,49,1,0,0,0,19,53,1,0,0, - 0,21,55,1,0,0,0,23,58,1,0,0,0,25,67,1,0,0,0,27,71,1,0,0,0,29,73, - 1,0,0,0,31,76,1,0,0,0,33,34,5,40,0,0,34,2,1,0,0,0,35,36,5,43,0,0, - 36,4,1,0,0,0,37,38,5,41,0,0,38,6,1,0,0,0,39,40,5,45,0,0,40,8,1,0, - 0,0,41,42,5,42,0,0,42,10,1,0,0,0,43,44,5,47,0,0,44,12,1,0,0,0,45, - 46,5,58,0,0,46,14,1,0,0,0,47,48,5,44,0,0,48,16,1,0,0,0,49,50,5,108, - 0,0,50,51,5,101,0,0,51,52,5,116,0,0,52,18,1,0,0,0,53,54,5,61,0,0, - 54,20,1,0,0,0,55,56,5,105,0,0,56,57,5,110,0,0,57,22,1,0,0,0,58,63, - 3,27,13,0,59,62,3,27,13,0,60,62,3,29,14,0,61,59,1,0,0,0,61,60,1, - 0,0,0,62,65,1,0,0,0,63,61,1,0,0,0,63,64,1,0,0,0,64,24,1,0,0,0,65, - 63,1,0,0,0,66,68,3,29,14,0,67,66,1,0,0,0,68,69,1,0,0,0,69,67,1,0, - 0,0,69,70,1,0,0,0,70,26,1,0,0,0,71,72,7,0,0,0,72,28,1,0,0,0,73,74, - 2,48,57,0,74,30,1,0,0,0,75,77,7,1,0,0,76,75,1,0,0,0,77,78,1,0,0, - 0,78,76,1,0,0,0,78,79,1,0,0,0,79,80,1,0,0,0,80,81,6,15,0,0,81,32, - 1,0,0,0,5,0,61,63,69,78,1,6,0,0 + 4,0,24,135,6,-1,2,0,7,0,2,1,7,1,2,2,7,2,2,3,7,3,2,4,7,4,2,5,7,5, + 2,6,7,6,2,7,7,7,2,8,7,8,2,9,7,9,2,10,7,10,2,11,7,11,2,12,7,12,2, + 13,7,13,2,14,7,14,2,15,7,15,2,16,7,16,2,17,7,17,2,18,7,18,2,19,7, + 19,2,20,7,20,2,21,7,21,2,22,7,22,2,23,7,23,2,24,7,24,2,25,7,25,1, + 0,1,0,1,0,1,0,1,0,1,1,1,1,1,1,1,1,1,1,1,1,1,2,1,2,1,3,1,3,1,4,1, + 4,1,5,1,5,1,6,1,6,1,7,1,7,1,8,1,8,1,9,1,9,1,10,1,10,1,10,1,11,1, + 11,1,11,1,12,1,12,1,12,1,13,1,13,1,13,1,14,1,14,1,14,1,15,1,15,1, + 15,1,16,1,16,1,17,1,17,1,18,1,18,1,18,1,18,1,19,1,19,1,20,1,20,1, + 20,1,21,1,21,1,21,5,21,115,8,21,10,21,12,21,118,9,21,1,22,4,22,121, + 8,22,11,22,12,22,122,1,23,1,23,1,24,1,24,1,25,4,25,130,8,25,11,25, + 12,25,131,1,25,1,25,0,0,26,1,1,3,2,5,3,7,4,9,5,11,6,13,7,15,8,17, + 9,19,10,21,11,23,12,25,13,27,14,29,15,31,16,33,17,35,18,37,19,39, + 20,41,21,43,22,45,23,47,0,49,0,51,24,1,0,2,2,0,65,90,97,122,3,0, + 9,10,13,13,32,32,136,0,1,1,0,0,0,0,3,1,0,0,0,0,5,1,0,0,0,0,7,1,0, + 0,0,0,9,1,0,0,0,0,11,1,0,0,0,0,13,1,0,0,0,0,15,1,0,0,0,0,17,1,0, + 0,0,0,19,1,0,0,0,0,21,1,0,0,0,0,23,1,0,0,0,0,25,1,0,0,0,0,27,1,0, + 0,0,0,29,1,0,0,0,0,31,1,0,0,0,0,33,1,0,0,0,0,35,1,0,0,0,0,37,1,0, + 0,0,0,39,1,0,0,0,0,41,1,0,0,0,0,43,1,0,0,0,0,45,1,0,0,0,0,51,1,0, + 0,0,1,53,1,0,0,0,3,58,1,0,0,0,5,64,1,0,0,0,7,66,1,0,0,0,9,68,1,0, + 0,0,11,70,1,0,0,0,13,72,1,0,0,0,15,74,1,0,0,0,17,76,1,0,0,0,19,78, + 1,0,0,0,21,80,1,0,0,0,23,83,1,0,0,0,25,86,1,0,0,0,27,89,1,0,0,0, + 29,92,1,0,0,0,31,95,1,0,0,0,33,98,1,0,0,0,35,100,1,0,0,0,37,102, + 1,0,0,0,39,106,1,0,0,0,41,108,1,0,0,0,43,111,1,0,0,0,45,120,1,0, + 0,0,47,124,1,0,0,0,49,126,1,0,0,0,51,129,1,0,0,0,53,54,5,116,0,0, + 54,55,5,114,0,0,55,56,5,117,0,0,56,57,5,101,0,0,57,2,1,0,0,0,58, + 59,5,102,0,0,59,60,5,97,0,0,60,61,5,108,0,0,61,62,5,115,0,0,62,63, + 5,101,0,0,63,4,1,0,0,0,64,65,5,40,0,0,65,6,1,0,0,0,66,67,5,43,0, + 0,67,8,1,0,0,0,68,69,5,41,0,0,69,10,1,0,0,0,70,71,5,45,0,0,71,12, + 1,0,0,0,72,73,5,42,0,0,73,14,1,0,0,0,74,75,5,47,0,0,75,16,1,0,0, + 0,76,77,5,62,0,0,77,18,1,0,0,0,78,79,5,60,0,0,79,20,1,0,0,0,80,81, + 5,61,0,0,81,82,5,61,0,0,82,22,1,0,0,0,83,84,5,60,0,0,84,85,5,60, + 0,0,85,24,1,0,0,0,86,87,5,62,0,0,87,88,5,62,0,0,88,26,1,0,0,0,89, + 90,5,38,0,0,90,91,5,38,0,0,91,28,1,0,0,0,92,93,5,124,0,0,93,94,5, + 124,0,0,94,30,1,0,0,0,95,96,5,94,0,0,96,97,5,94,0,0,97,32,1,0,0, + 0,98,99,5,58,0,0,99,34,1,0,0,0,100,101,5,44,0,0,101,36,1,0,0,0,102, + 103,5,108,0,0,103,104,5,101,0,0,104,105,5,116,0,0,105,38,1,0,0,0, + 106,107,5,61,0,0,107,40,1,0,0,0,108,109,5,105,0,0,109,110,5,110, + 0,0,110,42,1,0,0,0,111,116,3,47,23,0,112,115,3,47,23,0,113,115,3, + 49,24,0,114,112,1,0,0,0,114,113,1,0,0,0,115,118,1,0,0,0,116,114, + 1,0,0,0,116,117,1,0,0,0,117,44,1,0,0,0,118,116,1,0,0,0,119,121,3, + 49,24,0,120,119,1,0,0,0,121,122,1,0,0,0,122,120,1,0,0,0,122,123, + 1,0,0,0,123,46,1,0,0,0,124,125,7,0,0,0,125,48,1,0,0,0,126,127,2, + 48,57,0,127,50,1,0,0,0,128,130,7,1,0,0,129,128,1,0,0,0,130,131,1, + 0,0,0,131,129,1,0,0,0,131,132,1,0,0,0,132,133,1,0,0,0,133,134,6, + 25,0,0,134,52,1,0,0,0,5,0,114,116,122,131,1,6,0,0 ] class ANFLexer(Lexer): @@ -56,24 +74,36 @@ class ANFLexer(Lexer): T__8 = 9 T__9 = 10 T__10 = 11 - IDENT = 12 - NUMBER = 13 - WS = 14 + T__11 = 12 + T__12 = 13 + T__13 = 14 + T__14 = 15 + T__15 = 16 + T__16 = 17 + T__17 = 18 + T__18 = 19 + T__19 = 20 + T__20 = 21 + IDENT = 22 + NUMBER = 23 + WS = 24 channelNames = [ u"DEFAULT_TOKEN_CHANNEL", u"HIDDEN" ] modeNames = [ "DEFAULT_MODE" ] literalNames = [ "<INVALID>", - "'('", "'+'", "')'", "'-'", "'*'", "'/'", "':'", "','", "'let'", - "'='", "'in'" ] + "'true'", "'false'", "'('", "'+'", "')'", "'-'", "'*'", "'/'", + "'>'", "'<'", "'=='", "'<<'", "'>>'", "'&&'", "'||'", "'^^'", + "':'", "','", "'let'", "'='", "'in'" ] symbolicNames = [ "<INVALID>", "IDENT", "NUMBER", "WS" ] ruleNames = [ "T__0", "T__1", "T__2", "T__3", "T__4", "T__5", "T__6", - "T__7", "T__8", "T__9", "T__10", "IDENT", "NUMBER", "Letter", - "Digit", "WS" ] + "T__7", "T__8", "T__9", "T__10", "T__11", "T__12", "T__13", + "T__14", "T__15", "T__16", "T__17", "T__18", "T__19", + "T__20", "IDENT", "NUMBER", "Letter", "Digit", "WS" ] grammarFileName = "ANF.g4" diff --git a/gen/ANFLexer.tokens b/gen/ANFLexer.tokens @@ -9,17 +9,37 @@ T__7=8 T__8=9 T__9=10 T__10=11 -IDENT=12 -NUMBER=13 -WS=14 -'('=1 -'+'=2 -')'=3 -'-'=4 -'*'=5 -'/'=6 -':'=7 -','=8 -'let'=9 -'='=10 -'in'=11 +T__11=12 +T__12=13 +T__13=14 +T__14=15 +T__15=16 +T__16=17 +T__17=18 +T__18=19 +T__19=20 +T__20=21 +IDENT=22 +NUMBER=23 +WS=24 +'true'=1 +'false'=2 +'('=3 +'+'=4 +')'=5 +'-'=6 +'*'=7 +'/'=8 +'>'=9 +'<'=10 +'=='=11 +'<<'=12 +'>>'=13 +'&&'=14 +'||'=15 +'^^'=16 +':'=17 +','=18 +'let'=19 +'='=20 +'in'=21 diff --git a/gen/ANFListener.py b/gen/ANFListener.py @@ -8,6 +8,24 @@ else: # This class defines a complete listener for a parse tree produced by ANFParser. class ANFListener(ParseTreeListener): + # Enter a parse tree produced by ANFParser#true. + def enterTrue(self, ctx:ANFParser.TrueContext): + pass + + # Exit a parse tree produced by ANFParser#true. + def exitTrue(self, ctx:ANFParser.TrueContext): + pass + + + # Enter a parse tree produced by ANFParser#false. + def enterFalse(self, ctx:ANFParser.FalseContext): + pass + + # Exit a parse tree produced by ANFParser#false. + def exitFalse(self, ctx:ANFParser.FalseContext): + pass + + # Enter a parse tree produced by ANFParser#var. def enterVar(self, ctx:ANFParser.VarContext): pass @@ -62,6 +80,78 @@ class ANFListener(ParseTreeListener): pass + # Enter a parse tree produced by ANFParser#gt. + def enterGt(self, ctx:ANFParser.GtContext): + pass + + # Exit a parse tree produced by ANFParser#gt. + def exitGt(self, ctx:ANFParser.GtContext): + pass + + + # Enter a parse tree produced by ANFParser#lt. + def enterLt(self, ctx:ANFParser.LtContext): + pass + + # Exit a parse tree produced by ANFParser#lt. + def exitLt(self, ctx:ANFParser.LtContext): + pass + + + # Enter a parse tree produced by ANFParser#eq. + def enterEq(self, ctx:ANFParser.EqContext): + pass + + # Exit a parse tree produced by ANFParser#eq. + def exitEq(self, ctx:ANFParser.EqContext): + pass + + + # Enter a parse tree produced by ANFParser#bsl. + def enterBsl(self, ctx:ANFParser.BslContext): + pass + + # Exit a parse tree produced by ANFParser#bsl. + def exitBsl(self, ctx:ANFParser.BslContext): + pass + + + # Enter a parse tree produced by ANFParser#bsr. + def enterBsr(self, ctx:ANFParser.BsrContext): + pass + + # Exit a parse tree produced by ANFParser#bsr. + def exitBsr(self, ctx:ANFParser.BsrContext): + pass + + + # Enter a parse tree produced by ANFParser#and. + def enterAnd(self, ctx:ANFParser.AndContext): + pass + + # Exit a parse tree produced by ANFParser#and. + def exitAnd(self, ctx:ANFParser.AndContext): + pass + + + # Enter a parse tree produced by ANFParser#or. + def enterOr(self, ctx:ANFParser.OrContext): + pass + + # Exit a parse tree produced by ANFParser#or. + def exitOr(self, ctx:ANFParser.OrContext): + pass + + + # Enter a parse tree produced by ANFParser#xor. + def enterXor(self, ctx:ANFParser.XorContext): + pass + + # Exit a parse tree produced by ANFParser#xor. + def exitXor(self, ctx:ANFParser.XorContext): + pass + + # Enter a parse tree produced by ANFParser#lam. def enterLam(self, ctx:ANFParser.LamContext): pass diff --git a/gen/ANFParser.py b/gen/ANFParser.py @@ -10,27 +10,44 @@ else: def serializedATN(): return [ - 4,1,14,66,2,0,7,0,2,1,7,1,2,2,7,2,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1, + 4,1,24,116,2,0,7,0,2,1,7,1,2,2,7,2,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1, 0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1, - 0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,3,0,39,8,0,1,1,1,1,1,1,1,1,1,1, - 5,1,46,8,1,10,1,12,1,49,9,1,1,1,1,1,1,1,3,1,54,8,1,1,2,1,2,1,2,1, - 2,1,2,1,2,1,2,1,2,3,2,64,8,2,1,2,0,0,3,0,2,4,0,0,71,0,38,1,0,0,0, - 2,53,1,0,0,0,4,63,1,0,0,0,6,39,5,12,0,0,7,39,5,13,0,0,8,9,5,1,0, - 0,9,10,3,0,0,0,10,11,5,2,0,0,11,12,3,0,0,0,12,13,5,3,0,0,13,39,1, - 0,0,0,14,15,5,1,0,0,15,16,3,0,0,0,16,17,5,4,0,0,17,18,3,0,0,0,18, - 19,5,3,0,0,19,39,1,0,0,0,20,21,5,1,0,0,21,22,3,0,0,0,22,23,5,5,0, - 0,23,24,3,0,0,0,24,25,5,3,0,0,25,39,1,0,0,0,26,27,5,1,0,0,27,28, - 3,0,0,0,28,29,5,6,0,0,29,30,3,0,0,0,30,31,5,3,0,0,31,39,1,0,0,0, - 32,33,5,1,0,0,33,34,5,12,0,0,34,35,5,7,0,0,35,36,3,4,2,0,36,37,5, - 3,0,0,37,39,1,0,0,0,38,6,1,0,0,0,38,7,1,0,0,0,38,8,1,0,0,0,38,14, - 1,0,0,0,38,20,1,0,0,0,38,26,1,0,0,0,38,32,1,0,0,0,39,1,1,0,0,0,40, - 41,5,12,0,0,41,42,5,1,0,0,42,47,3,0,0,0,43,44,5,8,0,0,44,46,3,0, - 0,0,45,43,1,0,0,0,46,49,1,0,0,0,47,45,1,0,0,0,47,48,1,0,0,0,48,50, - 1,0,0,0,49,47,1,0,0,0,50,51,5,3,0,0,51,54,1,0,0,0,52,54,3,0,0,0, - 53,40,1,0,0,0,53,52,1,0,0,0,54,3,1,0,0,0,55,56,5,9,0,0,56,57,5,12, - 0,0,57,58,5,10,0,0,58,59,3,2,1,0,59,60,5,11,0,0,60,61,3,4,2,0,61, - 64,1,0,0,0,62,64,3,2,1,0,63,55,1,0,0,0,63,62,1,0,0,0,64,5,1,0,0, - 0,4,38,47,53,63 + 0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1, + 0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1, + 0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1, + 0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,3,0,89,8,0,1,1,1,1,1,1, + 1,1,1,1,5,1,96,8,1,10,1,12,1,99,9,1,1,1,1,1,1,1,3,1,104,8,1,1,2, + 1,2,1,2,1,2,1,2,1,2,1,2,1,2,3,2,114,8,2,1,2,0,0,3,0,2,4,0,0,131, + 0,88,1,0,0,0,2,103,1,0,0,0,4,113,1,0,0,0,6,89,5,1,0,0,7,89,5,2,0, + 0,8,89,5,22,0,0,9,89,5,23,0,0,10,11,5,3,0,0,11,12,3,0,0,0,12,13, + 5,4,0,0,13,14,3,0,0,0,14,15,5,5,0,0,15,89,1,0,0,0,16,17,5,3,0,0, + 17,18,3,0,0,0,18,19,5,6,0,0,19,20,3,0,0,0,20,21,5,5,0,0,21,89,1, + 0,0,0,22,23,5,3,0,0,23,24,3,0,0,0,24,25,5,7,0,0,25,26,3,0,0,0,26, + 27,5,5,0,0,27,89,1,0,0,0,28,29,5,3,0,0,29,30,3,0,0,0,30,31,5,8,0, + 0,31,32,3,0,0,0,32,33,5,5,0,0,33,89,1,0,0,0,34,35,5,3,0,0,35,36, + 3,0,0,0,36,37,5,9,0,0,37,38,3,0,0,0,38,39,5,5,0,0,39,89,1,0,0,0, + 40,41,5,3,0,0,41,42,3,0,0,0,42,43,5,10,0,0,43,44,3,0,0,0,44,45,5, + 5,0,0,45,89,1,0,0,0,46,47,5,3,0,0,47,48,3,0,0,0,48,49,5,11,0,0,49, + 50,3,0,0,0,50,51,5,5,0,0,51,89,1,0,0,0,52,53,5,3,0,0,53,54,3,0,0, + 0,54,55,5,12,0,0,55,56,3,0,0,0,56,57,5,5,0,0,57,89,1,0,0,0,58,59, + 5,3,0,0,59,60,3,0,0,0,60,61,5,13,0,0,61,62,3,0,0,0,62,63,5,5,0,0, + 63,89,1,0,0,0,64,65,5,3,0,0,65,66,3,0,0,0,66,67,5,14,0,0,67,68,3, + 0,0,0,68,69,5,5,0,0,69,89,1,0,0,0,70,71,5,3,0,0,71,72,3,0,0,0,72, + 73,5,15,0,0,73,74,3,0,0,0,74,75,5,5,0,0,75,89,1,0,0,0,76,77,5,3, + 0,0,77,78,3,0,0,0,78,79,5,16,0,0,79,80,3,0,0,0,80,81,5,5,0,0,81, + 89,1,0,0,0,82,83,5,3,0,0,83,84,5,22,0,0,84,85,5,17,0,0,85,86,3,4, + 2,0,86,87,5,5,0,0,87,89,1,0,0,0,88,6,1,0,0,0,88,7,1,0,0,0,88,8,1, + 0,0,0,88,9,1,0,0,0,88,10,1,0,0,0,88,16,1,0,0,0,88,22,1,0,0,0,88, + 28,1,0,0,0,88,34,1,0,0,0,88,40,1,0,0,0,88,46,1,0,0,0,88,52,1,0,0, + 0,88,58,1,0,0,0,88,64,1,0,0,0,88,70,1,0,0,0,88,76,1,0,0,0,88,82, + 1,0,0,0,89,1,1,0,0,0,90,91,5,22,0,0,91,92,5,3,0,0,92,97,3,0,0,0, + 93,94,5,18,0,0,94,96,3,0,0,0,95,93,1,0,0,0,96,99,1,0,0,0,97,95,1, + 0,0,0,97,98,1,0,0,0,98,100,1,0,0,0,99,97,1,0,0,0,100,101,5,5,0,0, + 101,104,1,0,0,0,102,104,3,0,0,0,103,90,1,0,0,0,103,102,1,0,0,0,104, + 3,1,0,0,0,105,106,5,19,0,0,106,107,5,22,0,0,107,108,5,20,0,0,108, + 109,3,2,1,0,109,110,5,21,0,0,110,111,3,4,2,0,111,114,1,0,0,0,112, + 114,3,2,1,0,113,105,1,0,0,0,113,112,1,0,0,0,114,5,1,0,0,0,4,88,97, + 103,113 ] class ANFParser ( Parser ): @@ -43,13 +60,17 @@ class ANFParser ( Parser ): sharedContextCache = PredictionContextCache() - literalNames = [ "<INVALID>", "'('", "'+'", "')'", "'-'", "'*'", "'/'", - "':'", "','", "'let'", "'='", "'in'" ] + literalNames = [ "<INVALID>", "'true'", "'false'", "'('", "'+'", "')'", + "'-'", "'*'", "'/'", "'>'", "'<'", "'=='", "'<<'", + "'>>'", "'&&'", "'||'", "'^^'", "':'", "','", "'let'", + "'='", "'in'" ] symbolicNames = [ "<INVALID>", "<INVALID>", "<INVALID>", "<INVALID>", "<INVALID>", "<INVALID>", "<INVALID>", "<INVALID>", "<INVALID>", "<INVALID>", "<INVALID>", "<INVALID>", - "IDENT", "NUMBER", "WS" ] + "<INVALID>", "<INVALID>", "<INVALID>", "<INVALID>", + "<INVALID>", "<INVALID>", "<INVALID>", "<INVALID>", + "<INVALID>", "<INVALID>", "IDENT", "NUMBER", "WS" ] RULE_aexp = 0 RULE_funcall = 1 @@ -69,9 +90,19 @@ class ANFParser ( Parser ): T__8=9 T__9=10 T__10=11 - IDENT=12 - NUMBER=13 - WS=14 + T__11=12 + T__12=13 + T__13=14 + T__14=15 + T__15=16 + T__16=17 + T__17=18 + T__18=19 + T__19=20 + T__20=21 + IDENT=22 + NUMBER=23 + WS=24 def __init__(self, input:TokenStream, output:TextIO = sys.stdout): super().__init__(input, output) @@ -127,7 +158,7 @@ class ANFParser ( Parser ): return visitor.visitChildren(self) - class DivContext(AexpContext): + class BsrContext(AexpContext): def __init__(self, parser, ctx:ParserRuleContext): # actually a ANFParser.AexpContext super().__init__(parser) @@ -141,16 +172,16 @@ class ANFParser ( Parser ): def enterRule(self, listener:ParseTreeListener): - if hasattr( listener, "enterDiv" ): - listener.enterDiv(self) + if hasattr( listener, "enterBsr" ): + listener.enterBsr(self) def exitRule(self, listener:ParseTreeListener): - if hasattr( listener, "exitDiv" ): - listener.exitDiv(self) + if hasattr( listener, "exitBsr" ): + listener.exitBsr(self) def accept(self, visitor:ParseTreeVisitor): - if hasattr( visitor, "visitDiv" ): - return visitor.visitDiv(self) + if hasattr( visitor, "visitBsr" ): + return visitor.visitBsr(self) else: return visitor.visitChildren(self) @@ -183,6 +214,34 @@ class ANFParser ( Parser ): return visitor.visitChildren(self) + class OrContext(AexpContext): + + def __init__(self, parser, ctx:ParserRuleContext): # actually a ANFParser.AexpContext + super().__init__(parser) + self.copyFrom(ctx) + + def aexp(self, i:int=None): + if i is None: + return self.getTypedRuleContexts(ANFParser.AexpContext) + else: + return self.getTypedRuleContext(ANFParser.AexpContext,i) + + + def enterRule(self, listener:ParseTreeListener): + if hasattr( listener, "enterOr" ): + listener.enterOr(self) + + def exitRule(self, listener:ParseTreeListener): + if hasattr( listener, "exitOr" ): + listener.exitOr(self) + + def accept(self, visitor:ParseTreeVisitor): + if hasattr( visitor, "visitOr" ): + return visitor.visitOr(self) + else: + return visitor.visitChildren(self) + + class MulContext(AexpContext): def __init__(self, parser, ctx:ParserRuleContext): # actually a ANFParser.AexpContext @@ -259,6 +318,190 @@ class ANFParser ( Parser ): return visitor.visitChildren(self) + class FalseContext(AexpContext): + + def __init__(self, parser, ctx:ParserRuleContext): # actually a ANFParser.AexpContext + super().__init__(parser) + self.copyFrom(ctx) + + + def enterRule(self, listener:ParseTreeListener): + if hasattr( listener, "enterFalse" ): + listener.enterFalse(self) + + def exitRule(self, listener:ParseTreeListener): + if hasattr( listener, "exitFalse" ): + listener.exitFalse(self) + + def accept(self, visitor:ParseTreeVisitor): + if hasattr( visitor, "visitFalse" ): + return visitor.visitFalse(self) + else: + return visitor.visitChildren(self) + + + class LtContext(AexpContext): + + def __init__(self, parser, ctx:ParserRuleContext): # actually a ANFParser.AexpContext + super().__init__(parser) + self.copyFrom(ctx) + + def aexp(self, i:int=None): + if i is None: + return self.getTypedRuleContexts(ANFParser.AexpContext) + else: + return self.getTypedRuleContext(ANFParser.AexpContext,i) + + + def enterRule(self, listener:ParseTreeListener): + if hasattr( listener, "enterLt" ): + listener.enterLt(self) + + def exitRule(self, listener:ParseTreeListener): + if hasattr( listener, "exitLt" ): + listener.exitLt(self) + + def accept(self, visitor:ParseTreeVisitor): + if hasattr( visitor, "visitLt" ): + return visitor.visitLt(self) + else: + return visitor.visitChildren(self) + + + class EqContext(AexpContext): + + def __init__(self, parser, ctx:ParserRuleContext): # actually a ANFParser.AexpContext + super().__init__(parser) + self.copyFrom(ctx) + + def aexp(self, i:int=None): + if i is None: + return self.getTypedRuleContexts(ANFParser.AexpContext) + else: + return self.getTypedRuleContext(ANFParser.AexpContext,i) + + + def enterRule(self, listener:ParseTreeListener): + if hasattr( listener, "enterEq" ): + listener.enterEq(self) + + def exitRule(self, listener:ParseTreeListener): + if hasattr( listener, "exitEq" ): + listener.exitEq(self) + + def accept(self, visitor:ParseTreeVisitor): + if hasattr( visitor, "visitEq" ): + return visitor.visitEq(self) + else: + return visitor.visitChildren(self) + + + class GtContext(AexpContext): + + def __init__(self, parser, ctx:ParserRuleContext): # actually a ANFParser.AexpContext + super().__init__(parser) + self.copyFrom(ctx) + + def aexp(self, i:int=None): + if i is None: + return self.getTypedRuleContexts(ANFParser.AexpContext) + else: + return self.getTypedRuleContext(ANFParser.AexpContext,i) + + + def enterRule(self, listener:ParseTreeListener): + if hasattr( listener, "enterGt" ): + listener.enterGt(self) + + def exitRule(self, listener:ParseTreeListener): + if hasattr( listener, "exitGt" ): + listener.exitGt(self) + + def accept(self, visitor:ParseTreeVisitor): + if hasattr( visitor, "visitGt" ): + return visitor.visitGt(self) + else: + return visitor.visitChildren(self) + + + class DivContext(AexpContext): + + def __init__(self, parser, ctx:ParserRuleContext): # actually a ANFParser.AexpContext + super().__init__(parser) + self.copyFrom(ctx) + + def aexp(self, i:int=None): + if i is None: + return self.getTypedRuleContexts(ANFParser.AexpContext) + else: + return self.getTypedRuleContext(ANFParser.AexpContext,i) + + + def enterRule(self, listener:ParseTreeListener): + if hasattr( listener, "enterDiv" ): + listener.enterDiv(self) + + def exitRule(self, listener:ParseTreeListener): + if hasattr( listener, "exitDiv" ): + listener.exitDiv(self) + + def accept(self, visitor:ParseTreeVisitor): + if hasattr( visitor, "visitDiv" ): + return visitor.visitDiv(self) + else: + return visitor.visitChildren(self) + + + class AndContext(AexpContext): + + def __init__(self, parser, ctx:ParserRuleContext): # actually a ANFParser.AexpContext + super().__init__(parser) + self.copyFrom(ctx) + + def aexp(self, i:int=None): + if i is None: + return self.getTypedRuleContexts(ANFParser.AexpContext) + else: + return self.getTypedRuleContext(ANFParser.AexpContext,i) + + + def enterRule(self, listener:ParseTreeListener): + if hasattr( listener, "enterAnd" ): + listener.enterAnd(self) + + def exitRule(self, listener:ParseTreeListener): + if hasattr( listener, "exitAnd" ): + listener.exitAnd(self) + + def accept(self, visitor:ParseTreeVisitor): + if hasattr( visitor, "visitAnd" ): + return visitor.visitAnd(self) + else: + return visitor.visitChildren(self) + + + class TrueContext(AexpContext): + + def __init__(self, parser, ctx:ParserRuleContext): # actually a ANFParser.AexpContext + super().__init__(parser) + self.copyFrom(ctx) + + + def enterRule(self, listener:ParseTreeListener): + if hasattr( listener, "enterTrue" ): + listener.enterTrue(self) + + def exitRule(self, listener:ParseTreeListener): + if hasattr( listener, "exitTrue" ): + listener.exitTrue(self) + + def accept(self, visitor:ParseTreeVisitor): + if hasattr( visitor, "visitTrue" ): + return visitor.visitTrue(self) + else: + return visitor.visitChildren(self) + + class LamContext(AexpContext): def __init__(self, parser, ctx:ParserRuleContext): # actually a ANFParser.AexpContext @@ -286,102 +529,292 @@ class ANFParser ( Parser ): return visitor.visitChildren(self) + class BslContext(AexpContext): + + def __init__(self, parser, ctx:ParserRuleContext): # actually a ANFParser.AexpContext + super().__init__(parser) + self.copyFrom(ctx) + + def aexp(self, i:int=None): + if i is None: + return self.getTypedRuleContexts(ANFParser.AexpContext) + else: + return self.getTypedRuleContext(ANFParser.AexpContext,i) + + + def enterRule(self, listener:ParseTreeListener): + if hasattr( listener, "enterBsl" ): + listener.enterBsl(self) + + def exitRule(self, listener:ParseTreeListener): + if hasattr( listener, "exitBsl" ): + listener.exitBsl(self) + + def accept(self, visitor:ParseTreeVisitor): + if hasattr( visitor, "visitBsl" ): + return visitor.visitBsl(self) + else: + return visitor.visitChildren(self) + + + class XorContext(AexpContext): + + def __init__(self, parser, ctx:ParserRuleContext): # actually a ANFParser.AexpContext + super().__init__(parser) + self.copyFrom(ctx) + + def aexp(self, i:int=None): + if i is None: + return self.getTypedRuleContexts(ANFParser.AexpContext) + else: + return self.getTypedRuleContext(ANFParser.AexpContext,i) + + + def enterRule(self, listener:ParseTreeListener): + if hasattr( listener, "enterXor" ): + listener.enterXor(self) + + def exitRule(self, listener:ParseTreeListener): + if hasattr( listener, "exitXor" ): + listener.exitXor(self) + + def accept(self, visitor:ParseTreeVisitor): + if hasattr( visitor, "visitXor" ): + return visitor.visitXor(self) + else: + return visitor.visitChildren(self) + + def aexp(self): localctx = ANFParser.AexpContext(self, self._ctx, self.state) self.enterRule(localctx, 0, self.RULE_aexp) try: - self.state = 38 + self.state = 88 self._errHandler.sync(self) la_ = self._interp.adaptivePredict(self._input,0,self._ctx) if la_ == 1: - localctx = ANFParser.VarContext(self, localctx) + localctx = ANFParser.TrueContext(self, localctx) self.enterOuterAlt(localctx, 1) self.state = 6 - self.match(ANFParser.IDENT) + self.match(ANFParser.T__0) pass elif la_ == 2: - localctx = ANFParser.NumContext(self, localctx) + localctx = ANFParser.FalseContext(self, localctx) self.enterOuterAlt(localctx, 2) self.state = 7 - self.match(ANFParser.NUMBER) + self.match(ANFParser.T__1) pass elif la_ == 3: - localctx = ANFParser.AddContext(self, localctx) + localctx = ANFParser.VarContext(self, localctx) self.enterOuterAlt(localctx, 3) self.state = 8 - self.match(ANFParser.T__0) + self.match(ANFParser.IDENT) + pass + + elif la_ == 4: + localctx = ANFParser.NumContext(self, localctx) + self.enterOuterAlt(localctx, 4) self.state = 9 - self.aexp() + self.match(ANFParser.NUMBER) + pass + + elif la_ == 5: + localctx = ANFParser.AddContext(self, localctx) + self.enterOuterAlt(localctx, 5) self.state = 10 - self.match(ANFParser.T__1) + self.match(ANFParser.T__2) self.state = 11 self.aexp() self.state = 12 - self.match(ANFParser.T__2) + self.match(ANFParser.T__3) + self.state = 13 + self.aexp() + self.state = 14 + self.match(ANFParser.T__4) pass - elif la_ == 4: + elif la_ == 6: localctx = ANFParser.SubContext(self, localctx) - self.enterOuterAlt(localctx, 4) - self.state = 14 - self.match(ANFParser.T__0) - self.state = 15 - self.aexp() + self.enterOuterAlt(localctx, 6) self.state = 16 - self.match(ANFParser.T__3) + self.match(ANFParser.T__2) self.state = 17 self.aexp() self.state = 18 - self.match(ANFParser.T__2) + self.match(ANFParser.T__5) + self.state = 19 + self.aexp() + self.state = 20 + self.match(ANFParser.T__4) pass - elif la_ == 5: + elif la_ == 7: localctx = ANFParser.MulContext(self, localctx) - self.enterOuterAlt(localctx, 5) - self.state = 20 - self.match(ANFParser.T__0) - self.state = 21 - self.aexp() + self.enterOuterAlt(localctx, 7) self.state = 22 - self.match(ANFParser.T__4) + self.match(ANFParser.T__2) self.state = 23 self.aexp() self.state = 24 - self.match(ANFParser.T__2) + self.match(ANFParser.T__6) + self.state = 25 + self.aexp() + self.state = 26 + self.match(ANFParser.T__4) pass - elif la_ == 6: + elif la_ == 8: localctx = ANFParser.DivContext(self, localctx) - self.enterOuterAlt(localctx, 6) - self.state = 26 - self.match(ANFParser.T__0) - self.state = 27 - self.aexp() + self.enterOuterAlt(localctx, 8) self.state = 28 - self.match(ANFParser.T__5) + self.match(ANFParser.T__2) self.state = 29 self.aexp() self.state = 30 - self.match(ANFParser.T__2) + self.match(ANFParser.T__7) + self.state = 31 + self.aexp() + self.state = 32 + self.match(ANFParser.T__4) pass - elif la_ == 7: - localctx = ANFParser.LamContext(self, localctx) - self.enterOuterAlt(localctx, 7) - self.state = 32 - self.match(ANFParser.T__0) - self.state = 33 - self.match(ANFParser.IDENT) + elif la_ == 9: + localctx = ANFParser.GtContext(self, localctx) + self.enterOuterAlt(localctx, 9) self.state = 34 - self.match(ANFParser.T__6) + self.match(ANFParser.T__2) self.state = 35 - self.cexp() + self.aexp() self.state = 36 + self.match(ANFParser.T__8) + self.state = 37 + self.aexp() + self.state = 38 + self.match(ANFParser.T__4) + pass + + elif la_ == 10: + localctx = ANFParser.LtContext(self, localctx) + self.enterOuterAlt(localctx, 10) + self.state = 40 + self.match(ANFParser.T__2) + self.state = 41 + self.aexp() + self.state = 42 + self.match(ANFParser.T__9) + self.state = 43 + self.aexp() + self.state = 44 + self.match(ANFParser.T__4) + pass + + elif la_ == 11: + localctx = ANFParser.EqContext(self, localctx) + self.enterOuterAlt(localctx, 11) + self.state = 46 + self.match(ANFParser.T__2) + self.state = 47 + self.aexp() + self.state = 48 + self.match(ANFParser.T__10) + self.state = 49 + self.aexp() + self.state = 50 + self.match(ANFParser.T__4) + pass + + elif la_ == 12: + localctx = ANFParser.BslContext(self, localctx) + self.enterOuterAlt(localctx, 12) + self.state = 52 + self.match(ANFParser.T__2) + self.state = 53 + self.aexp() + self.state = 54 + self.match(ANFParser.T__11) + self.state = 55 + self.aexp() + self.state = 56 + self.match(ANFParser.T__4) + pass + + elif la_ == 13: + localctx = ANFParser.BsrContext(self, localctx) + self.enterOuterAlt(localctx, 13) + self.state = 58 + self.match(ANFParser.T__2) + self.state = 59 + self.aexp() + self.state = 60 + self.match(ANFParser.T__12) + self.state = 61 + self.aexp() + self.state = 62 + self.match(ANFParser.T__4) + pass + + elif la_ == 14: + localctx = ANFParser.AndContext(self, localctx) + self.enterOuterAlt(localctx, 14) + self.state = 64 + self.match(ANFParser.T__2) + self.state = 65 + self.aexp() + self.state = 66 + self.match(ANFParser.T__13) + self.state = 67 + self.aexp() + self.state = 68 + self.match(ANFParser.T__4) + pass + + elif la_ == 15: + localctx = ANFParser.OrContext(self, localctx) + self.enterOuterAlt(localctx, 15) + self.state = 70 self.match(ANFParser.T__2) + self.state = 71 + self.aexp() + self.state = 72 + self.match(ANFParser.T__14) + self.state = 73 + self.aexp() + self.state = 74 + self.match(ANFParser.T__4) + pass + + elif la_ == 16: + localctx = ANFParser.XorContext(self, localctx) + self.enterOuterAlt(localctx, 16) + self.state = 76 + self.match(ANFParser.T__2) + self.state = 77 + self.aexp() + self.state = 78 + self.match(ANFParser.T__15) + self.state = 79 + self.aexp() + self.state = 80 + self.match(ANFParser.T__4) + pass + + elif la_ == 17: + localctx = ANFParser.LamContext(self, localctx) + self.enterOuterAlt(localctx, 17) + self.state = 82 + self.match(ANFParser.T__2) + self.state = 83 + self.match(ANFParser.IDENT) + self.state = 84 + self.match(ANFParser.T__16) + self.state = 85 + self.cexp() + self.state = 86 + self.match(ANFParser.T__4) pass @@ -473,38 +906,38 @@ class ANFParser ( Parser ): self.enterRule(localctx, 2, self.RULE_funcall) self._la = 0 # Token type try: - self.state = 53 + self.state = 103 self._errHandler.sync(self) la_ = self._interp.adaptivePredict(self._input,2,self._ctx) if la_ == 1: localctx = ANFParser.CallContext(self, localctx) self.enterOuterAlt(localctx, 1) - self.state = 40 + self.state = 90 self.match(ANFParser.IDENT) - self.state = 41 - self.match(ANFParser.T__0) - self.state = 42 + self.state = 91 + self.match(ANFParser.T__2) + self.state = 92 self.aexp() - self.state = 47 + self.state = 97 self._errHandler.sync(self) _la = self._input.LA(1) - while _la==8: - self.state = 43 - self.match(ANFParser.T__7) - self.state = 44 + while _la==18: + self.state = 93 + self.match(ANFParser.T__17) + self.state = 94 self.aexp() - self.state = 49 + self.state = 99 self._errHandler.sync(self) _la = self._input.LA(1) - self.state = 50 - self.match(ANFParser.T__2) + self.state = 100 + self.match(ANFParser.T__4) pass elif la_ == 2: localctx = ANFParser.AtomContext(self, localctx) self.enterOuterAlt(localctx, 2) - self.state = 52 + self.state = 102 self.aexp() pass @@ -596,29 +1029,29 @@ class ANFParser ( Parser ): localctx = ANFParser.CexpContext(self, self._ctx, self.state) self.enterRule(localctx, 4, self.RULE_cexp) try: - self.state = 63 + self.state = 113 self._errHandler.sync(self) token = self._input.LA(1) - if token in [9]: + if token in [19]: localctx = ANFParser.LetContext(self, localctx) self.enterOuterAlt(localctx, 1) - self.state = 55 - self.match(ANFParser.T__8) - self.state = 56 + self.state = 105 + self.match(ANFParser.T__18) + self.state = 106 self.match(ANFParser.IDENT) - self.state = 57 - self.match(ANFParser.T__9) - self.state = 58 + self.state = 107 + self.match(ANFParser.T__19) + self.state = 108 self.funcall() - self.state = 59 - self.match(ANFParser.T__10) - self.state = 60 + self.state = 109 + self.match(ANFParser.T__20) + self.state = 110 self.cexp() pass - elif token in [1, 12, 13]: + elif token in [1, 2, 3, 22, 23]: localctx = ANFParser.FcContext(self, localctx) self.enterOuterAlt(localctx, 2) - self.state = 62 + self.state = 112 self.funcall() pass else: diff --git a/gen/ANFVisitor.py b/gen/ANFVisitor.py @@ -9,6 +9,16 @@ else: class ANFVisitor(ParseTreeVisitor): + # Visit a parse tree produced by ANFParser#true. + def visitTrue(self, ctx:ANFParser.TrueContext): + return self.visitChildren(ctx) + + + # Visit a parse tree produced by ANFParser#false. + def visitFalse(self, ctx:ANFParser.FalseContext): + return self.visitChildren(ctx) + + # Visit a parse tree produced by ANFParser#var. def visitVar(self, ctx:ANFParser.VarContext): return self.visitChildren(ctx) @@ -39,6 +49,46 @@ class ANFVisitor(ParseTreeVisitor): return self.visitChildren(ctx) + # Visit a parse tree produced by ANFParser#gt. + def visitGt(self, ctx:ANFParser.GtContext): + return self.visitChildren(ctx) + + + # Visit a parse tree produced by ANFParser#lt. + def visitLt(self, ctx:ANFParser.LtContext): + return self.visitChildren(ctx) + + + # Visit a parse tree produced by ANFParser#eq. + def visitEq(self, ctx:ANFParser.EqContext): + return self.visitChildren(ctx) + + + # Visit a parse tree produced by ANFParser#bsl. + def visitBsl(self, ctx:ANFParser.BslContext): + return self.visitChildren(ctx) + + + # Visit a parse tree produced by ANFParser#bsr. + def visitBsr(self, ctx:ANFParser.BsrContext): + return self.visitChildren(ctx) + + + # Visit a parse tree produced by ANFParser#and. + def visitAnd(self, ctx:ANFParser.AndContext): + return self.visitChildren(ctx) + + + # Visit a parse tree produced by ANFParser#or. + def visitOr(self, ctx:ANFParser.OrContext): + return self.visitChildren(ctx) + + + # Visit a parse tree produced by ANFParser#xor. + def visitXor(self, ctx:ANFParser.XorContext): + return self.visitChildren(ctx) + + # Visit a parse tree produced by ANFParser#lam. def visitLam(self, ctx:ANFParser.LamContext): return self.visitChildren(ctx) diff --git a/grammar/ANF.g4 b/grammar/ANF.g4 @@ -1,12 +1,22 @@ grammar ANF; aexp - : IDENT #var + : 'true' #true + | 'false' # false + | IDENT #var | NUMBER #num | '(' aexp '+' aexp ')' #add | '(' aexp '-' aexp ')' #sub | '(' aexp '*' aexp ')' #mul | '(' aexp '/' aexp ')' #div + | '(' aexp '>' aexp ')' #gt + | '(' aexp '<' aexp ')' #lt + | '(' aexp '==' aexp ')' #eq + | '(' aexp '<<' aexp ')' #bsl + | '(' aexp '>>' aexp ')' #bsr + | '(' aexp '&&' aexp ')' #and + | '(' aexp '||' aexp ')' #or + | '(' aexp '^^' aexp ')' #xor | '(' IDENT ':' cexp ')' #lam ; @@ -16,6 +26,7 @@ funcall ; cexp : 'let' IDENT '=' funcall 'in' cexp #let + | 'if' aexp 'then' cexp 'else' cexp #if | funcall #fc ;