fp-il

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

commit 258121cfb53b6b002dd0d2f68b91ce5234011620
parent d9ffc2f3f679bf6e87cf12dc1ed9809badf673da
Author: Erik Oosting <crazazy@tilde.cafe>
Date:   Tue, 12 Dec 2023 16:24:03 +0100

first visit method done

Diffstat:
MExpBuilder.py | 12+++++++++++-
Mgen/ANF.interp | 16++++++++++------
Mgen/ANF.tokens | 58++++++++++++++++++++++++++++++----------------------------
Mgen/ANFLexer.interp | 15+++++++++------
Mgen/ANFLexer.py | 129++++++++++++++++++++++++++++++++++++++++---------------------------------------
Mgen/ANFLexer.tokens | 58++++++++++++++++++++++++++++++----------------------------
Mgen/ANFListener.py | 27+++++++++++++++++++++++++++
Mgen/ANFParser.py | 650+++++++++++++++++++++++++++++++++++++++++++++++++++----------------------------
Mgen/ANFVisitor.py | 15+++++++++++++++
Mgrammar/ANF.g4 | 5+++++
10 files changed, 624 insertions(+), 361 deletions(-)

diff --git a/ExpBuilder.py b/ExpBuilder.py @@ -1,9 +1,19 @@ +from antlr4 import TerminalNode + from gen import ANFVisitor +from gen.ANFParser import ANFParser from llvmlite.ir import * class ExpBuilder(ANFVisitor): + module = Module("Program") + def __init__(self): - self.module = Module(name="Program") + self.currentFunc: Function | None = None + def visitDef(self, ctx: ANFParser.DefContext): + args = [i.getText() for i in ctx.IDENT()][1:] + i_type = IntType(64) + self.currentFunc = Function(self.module, FunctionType(i_type, [i_type] * len(args)), name=ctx.IDENT(0)) + self.visit(ctx.cexp()) diff --git a/gen/ANF.interp b/gen/ANF.interp @@ -1,10 +1,13 @@ token literal names: null +'def' +'(' +',' +')' +':' 'true' 'false' -'(' '+' -')' '-' '*' '/' @@ -16,8 +19,6 @@ null '&&' '||' '^^' -',' -':' 'let' '=' 'in' @@ -55,16 +56,19 @@ null null null null +null IDENT NUMBER STRING WS rule names: +prog +def aexp funcall cexp atn: -[4, 1, 28, 130, 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, 5, 0, 87, 8, 0, 10, 0, 12, 0, 90, 9, 0, 1, 0, 1, 0, 1, 0, 1, 0, 3, 0, 96, 8, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 5, 1, 103, 8, 1, 10, 1, 12, 1, 106, 9, 1, 1, 1, 1, 1, 1, 1, 3, 1, 111, 8, 1, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 3, 2, 128, 8, 2, 1, 2, 0, 0, 3, 0, 2, 4, 0, 0, 147, 0, 95, 1, 0, 0, 0, 2, 110, 1, 0, 0, 0, 4, 127, 1, 0, 0, 0, 6, 96, 5, 1, 0, 0, 7, 96, 5, 2, 0, 0, 8, 96, 5, 25, 0, 0, 9, 96, 5, 26, 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, 96, 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, 96, 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, 96, 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, 96, 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, 96, 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, 96, 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, 96, 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, 96, 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, 96, 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, 96, 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, 96, 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, 96, 1, 0, 0, 0, 82, 83, 5, 3, 0, 0, 83, 88, 5, 25, 0, 0, 84, 85, 5, 17, 0, 0, 85, 87, 5, 25, 0, 0, 86, 84, 1, 0, 0, 0, 87, 90, 1, 0, 0, 0, 88, 86, 1, 0, 0, 0, 88, 89, 1, 0, 0, 0, 89, 91, 1, 0, 0, 0, 90, 88, 1, 0, 0, 0, 91, 92, 5, 18, 0, 0, 92, 93, 3, 4, 2, 0, 93, 94, 5, 5, 0, 0, 94, 96, 1, 0, 0, 0, 95, 6, 1, 0, 0, 0, 95, 7, 1, 0, 0, 0, 95, 8, 1, 0, 0, 0, 95, 9, 1, 0, 0, 0, 95, 10, 1, 0, 0, 0, 95, 16, 1, 0, 0, 0, 95, 22, 1, 0, 0, 0, 95, 28, 1, 0, 0, 0, 95, 34, 1, 0, 0, 0, 95, 40, 1, 0, 0, 0, 95, 46, 1, 0, 0, 0, 95, 52, 1, 0, 0, 0, 95, 58, 1, 0, 0, 0, 95, 64, 1, 0, 0, 0, 95, 70, 1, 0, 0, 0, 95, 76, 1, 0, 0, 0, 95, 82, 1, 0, 0, 0, 96, 1, 1, 0, 0, 0, 97, 98, 5, 25, 0, 0, 98, 99, 5, 3, 0, 0, 99, 104, 3, 0, 0, 0, 100, 101, 5, 17, 0, 0, 101, 103, 3, 0, 0, 0, 102, 100, 1, 0, 0, 0, 103, 106, 1, 0, 0, 0, 104, 102, 1, 0, 0, 0, 104, 105, 1, 0, 0, 0, 105, 107, 1, 0, 0, 0, 106, 104, 1, 0, 0, 0, 107, 108, 5, 5, 0, 0, 108, 111, 1, 0, 0, 0, 109, 111, 3, 0, 0, 0, 110, 97, 1, 0, 0, 0, 110, 109, 1, 0, 0, 0, 111, 3, 1, 0, 0, 0, 112, 113, 5, 19, 0, 0, 113, 114, 5, 25, 0, 0, 114, 115, 5, 20, 0, 0, 115, 116, 3, 2, 1, 0, 116, 117, 5, 21, 0, 0, 117, 118, 3, 4, 2, 0, 118, 128, 1, 0, 0, 0, 119, 120, 5, 22, 0, 0, 120, 121, 3, 0, 0, 0, 121, 122, 5, 23, 0, 0, 122, 123, 3, 4, 2, 0, 123, 124, 5, 24, 0, 0, 124, 125, 3, 4, 2, 0, 125, 128, 1, 0, 0, 0, 126, 128, 3, 2, 1, 0, 127, 112, 1, 0, 0, 0, 127, 119, 1, 0, 0, 0, 127, 126, 1, 0, 0, 0, 128, 5, 1, 0, 0, 0, 5, 88, 95, 104, 110, 127]- \ No newline at end of file +[4, 1, 29, 157, 2, 0, 7, 0, 2, 1, 7, 1, 2, 2, 7, 2, 2, 3, 7, 3, 2, 4, 7, 4, 1, 0, 4, 0, 12, 8, 0, 11, 0, 12, 0, 13, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 5, 1, 22, 8, 1, 10, 1, 12, 1, 25, 9, 1, 3, 1, 27, 8, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 5, 2, 114, 8, 2, 10, 2, 12, 2, 117, 9, 2, 1, 2, 1, 2, 1, 2, 1, 2, 3, 2, 123, 8, 2, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 5, 3, 130, 8, 3, 10, 3, 12, 3, 133, 9, 3, 1, 3, 1, 3, 1, 3, 3, 3, 138, 8, 3, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 3, 4, 155, 8, 4, 1, 4, 0, 0, 5, 0, 2, 4, 6, 8, 0, 0, 176, 0, 11, 1, 0, 0, 0, 2, 15, 1, 0, 0, 0, 4, 122, 1, 0, 0, 0, 6, 137, 1, 0, 0, 0, 8, 154, 1, 0, 0, 0, 10, 12, 3, 2, 1, 0, 11, 10, 1, 0, 0, 0, 12, 13, 1, 0, 0, 0, 13, 11, 1, 0, 0, 0, 13, 14, 1, 0, 0, 0, 14, 1, 1, 0, 0, 0, 15, 16, 5, 1, 0, 0, 16, 17, 5, 26, 0, 0, 17, 26, 5, 2, 0, 0, 18, 23, 5, 26, 0, 0, 19, 20, 5, 3, 0, 0, 20, 22, 5, 26, 0, 0, 21, 19, 1, 0, 0, 0, 22, 25, 1, 0, 0, 0, 23, 21, 1, 0, 0, 0, 23, 24, 1, 0, 0, 0, 24, 27, 1, 0, 0, 0, 25, 23, 1, 0, 0, 0, 26, 18, 1, 0, 0, 0, 26, 27, 1, 0, 0, 0, 27, 28, 1, 0, 0, 0, 28, 29, 5, 4, 0, 0, 29, 30, 5, 5, 0, 0, 30, 31, 3, 8, 4, 0, 31, 3, 1, 0, 0, 0, 32, 123, 5, 6, 0, 0, 33, 123, 5, 7, 0, 0, 34, 123, 5, 26, 0, 0, 35, 123, 5, 27, 0, 0, 36, 123, 5, 28, 0, 0, 37, 38, 5, 2, 0, 0, 38, 39, 3, 4, 2, 0, 39, 40, 5, 8, 0, 0, 40, 41, 3, 4, 2, 0, 41, 42, 5, 4, 0, 0, 42, 123, 1, 0, 0, 0, 43, 44, 5, 2, 0, 0, 44, 45, 3, 4, 2, 0, 45, 46, 5, 9, 0, 0, 46, 47, 3, 4, 2, 0, 47, 48, 5, 4, 0, 0, 48, 123, 1, 0, 0, 0, 49, 50, 5, 2, 0, 0, 50, 51, 3, 4, 2, 0, 51, 52, 5, 10, 0, 0, 52, 53, 3, 4, 2, 0, 53, 54, 5, 4, 0, 0, 54, 123, 1, 0, 0, 0, 55, 56, 5, 2, 0, 0, 56, 57, 3, 4, 2, 0, 57, 58, 5, 11, 0, 0, 58, 59, 3, 4, 2, 0, 59, 60, 5, 4, 0, 0, 60, 123, 1, 0, 0, 0, 61, 62, 5, 2, 0, 0, 62, 63, 3, 4, 2, 0, 63, 64, 5, 12, 0, 0, 64, 65, 3, 4, 2, 0, 65, 66, 5, 4, 0, 0, 66, 123, 1, 0, 0, 0, 67, 68, 5, 2, 0, 0, 68, 69, 3, 4, 2, 0, 69, 70, 5, 13, 0, 0, 70, 71, 3, 4, 2, 0, 71, 72, 5, 4, 0, 0, 72, 123, 1, 0, 0, 0, 73, 74, 5, 2, 0, 0, 74, 75, 3, 4, 2, 0, 75, 76, 5, 14, 0, 0, 76, 77, 3, 4, 2, 0, 77, 78, 5, 4, 0, 0, 78, 123, 1, 0, 0, 0, 79, 80, 5, 2, 0, 0, 80, 81, 3, 4, 2, 0, 81, 82, 5, 15, 0, 0, 82, 83, 3, 4, 2, 0, 83, 84, 5, 4, 0, 0, 84, 123, 1, 0, 0, 0, 85, 86, 5, 2, 0, 0, 86, 87, 3, 4, 2, 0, 87, 88, 5, 16, 0, 0, 88, 89, 3, 4, 2, 0, 89, 90, 5, 4, 0, 0, 90, 123, 1, 0, 0, 0, 91, 92, 5, 2, 0, 0, 92, 93, 3, 4, 2, 0, 93, 94, 5, 17, 0, 0, 94, 95, 3, 4, 2, 0, 95, 96, 5, 4, 0, 0, 96, 123, 1, 0, 0, 0, 97, 98, 5, 2, 0, 0, 98, 99, 3, 4, 2, 0, 99, 100, 5, 18, 0, 0, 100, 101, 3, 4, 2, 0, 101, 102, 5, 4, 0, 0, 102, 123, 1, 0, 0, 0, 103, 104, 5, 2, 0, 0, 104, 105, 3, 4, 2, 0, 105, 106, 5, 19, 0, 0, 106, 107, 3, 4, 2, 0, 107, 108, 5, 4, 0, 0, 108, 123, 1, 0, 0, 0, 109, 110, 5, 2, 0, 0, 110, 115, 5, 26, 0, 0, 111, 112, 5, 3, 0, 0, 112, 114, 5, 26, 0, 0, 113, 111, 1, 0, 0, 0, 114, 117, 1, 0, 0, 0, 115, 113, 1, 0, 0, 0, 115, 116, 1, 0, 0, 0, 116, 118, 1, 0, 0, 0, 117, 115, 1, 0, 0, 0, 118, 119, 5, 5, 0, 0, 119, 120, 3, 8, 4, 0, 120, 121, 5, 4, 0, 0, 121, 123, 1, 0, 0, 0, 122, 32, 1, 0, 0, 0, 122, 33, 1, 0, 0, 0, 122, 34, 1, 0, 0, 0, 122, 35, 1, 0, 0, 0, 122, 36, 1, 0, 0, 0, 122, 37, 1, 0, 0, 0, 122, 43, 1, 0, 0, 0, 122, 49, 1, 0, 0, 0, 122, 55, 1, 0, 0, 0, 122, 61, 1, 0, 0, 0, 122, 67, 1, 0, 0, 0, 122, 73, 1, 0, 0, 0, 122, 79, 1, 0, 0, 0, 122, 85, 1, 0, 0, 0, 122, 91, 1, 0, 0, 0, 122, 97, 1, 0, 0, 0, 122, 103, 1, 0, 0, 0, 122, 109, 1, 0, 0, 0, 123, 5, 1, 0, 0, 0, 124, 125, 5, 26, 0, 0, 125, 126, 5, 2, 0, 0, 126, 131, 3, 4, 2, 0, 127, 128, 5, 3, 0, 0, 128, 130, 3, 4, 2, 0, 129, 127, 1, 0, 0, 0, 130, 133, 1, 0, 0, 0, 131, 129, 1, 0, 0, 0, 131, 132, 1, 0, 0, 0, 132, 134, 1, 0, 0, 0, 133, 131, 1, 0, 0, 0, 134, 135, 5, 4, 0, 0, 135, 138, 1, 0, 0, 0, 136, 138, 3, 4, 2, 0, 137, 124, 1, 0, 0, 0, 137, 136, 1, 0, 0, 0, 138, 7, 1, 0, 0, 0, 139, 140, 5, 20, 0, 0, 140, 141, 5, 26, 0, 0, 141, 142, 5, 21, 0, 0, 142, 143, 3, 6, 3, 0, 143, 144, 5, 22, 0, 0, 144, 145, 3, 8, 4, 0, 145, 155, 1, 0, 0, 0, 146, 147, 5, 23, 0, 0, 147, 148, 3, 4, 2, 0, 148, 149, 5, 24, 0, 0, 149, 150, 3, 8, 4, 0, 150, 151, 5, 25, 0, 0, 151, 152, 3, 8, 4, 0, 152, 155, 1, 0, 0, 0, 153, 155, 3, 6, 3, 0, 154, 139, 1, 0, 0, 0, 154, 146, 1, 0, 0, 0, 154, 153, 1, 0, 0, 0, 155, 9, 1, 0, 0, 0, 8, 13, 23, 26, 115, 122, 131, 137, 154]+ \ No newline at end of file diff --git a/gen/ANF.tokens b/gen/ANF.tokens @@ -22,31 +22,33 @@ T__20=21 T__21=22 T__22=23 T__23=24 -IDENT=25 -NUMBER=26 -STRING=27 -WS=28 -'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 -'if'=22 -'then'=23 -'else'=24 +T__24=25 +IDENT=26 +NUMBER=27 +STRING=28 +WS=29 +'def'=1 +'('=2 +','=3 +')'=4 +':'=5 +'true'=6 +'false'=7 +'+'=8 +'-'=9 +'*'=10 +'/'=11 +'>'=12 +'<'=13 +'=='=14 +'<<'=15 +'>>'=16 +'&&'=17 +'||'=18 +'^^'=19 +'let'=20 +'='=21 +'in'=22 +'if'=23 +'then'=24 +'else'=25 diff --git a/gen/ANFLexer.interp b/gen/ANFLexer.interp @@ -1,10 +1,13 @@ token literal names: null +'def' +'(' +',' +')' +':' 'true' 'false' -'(' '+' -')' '-' '*' '/' @@ -16,8 +19,6 @@ null '&&' '||' '^^' -',' -':' 'let' '=' 'in' @@ -55,6 +56,7 @@ null null null null +null IDENT NUMBER STRING @@ -85,6 +87,7 @@ T__20 T__21 T__22 T__23 +T__24 IDENT NUMBER STRING @@ -100,4 +103,4 @@ mode names: DEFAULT_MODE atn: -[4, 0, 28, 167, 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, 2, 26, 7, 26, 2, 27, 7, 27, 2, 28, 7, 28, 2, 29, 7, 29, 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, 1, 22, 1, 22, 1, 22, 1, 22, 1, 22, 1, 23, 1, 23, 1, 23, 1, 23, 1, 23, 1, 24, 1, 24, 1, 24, 5, 24, 136, 8, 24, 10, 24, 12, 24, 139, 9, 24, 1, 25, 4, 25, 142, 8, 25, 11, 25, 12, 25, 143, 1, 26, 1, 26, 1, 26, 1, 26, 5, 26, 150, 8, 26, 10, 26, 12, 26, 153, 9, 26, 1, 26, 1, 26, 1, 27, 1, 27, 1, 28, 1, 28, 1, 29, 4, 29, 162, 8, 29, 11, 29, 12, 29, 163, 1, 29, 1, 29, 0, 0, 30, 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, 24, 49, 25, 51, 26, 53, 27, 55, 0, 57, 0, 59, 28, 1, 0, 3, 2, 0, 34, 34, 94, 94, 2, 0, 65, 90, 97, 122, 3, 0, 9, 10, 13, 13, 32, 32, 170, 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, 47, 1, 0, 0, 0, 0, 49, 1, 0, 0, 0, 0, 51, 1, 0, 0, 0, 0, 53, 1, 0, 0, 0, 0, 59, 1, 0, 0, 0, 1, 61, 1, 0, 0, 0, 3, 66, 1, 0, 0, 0, 5, 72, 1, 0, 0, 0, 7, 74, 1, 0, 0, 0, 9, 76, 1, 0, 0, 0, 11, 78, 1, 0, 0, 0, 13, 80, 1, 0, 0, 0, 15, 82, 1, 0, 0, 0, 17, 84, 1, 0, 0, 0, 19, 86, 1, 0, 0, 0, 21, 88, 1, 0, 0, 0, 23, 91, 1, 0, 0, 0, 25, 94, 1, 0, 0, 0, 27, 97, 1, 0, 0, 0, 29, 100, 1, 0, 0, 0, 31, 103, 1, 0, 0, 0, 33, 106, 1, 0, 0, 0, 35, 108, 1, 0, 0, 0, 37, 110, 1, 0, 0, 0, 39, 114, 1, 0, 0, 0, 41, 116, 1, 0, 0, 0, 43, 119, 1, 0, 0, 0, 45, 122, 1, 0, 0, 0, 47, 127, 1, 0, 0, 0, 49, 132, 1, 0, 0, 0, 51, 141, 1, 0, 0, 0, 53, 145, 1, 0, 0, 0, 55, 156, 1, 0, 0, 0, 57, 158, 1, 0, 0, 0, 59, 161, 1, 0, 0, 0, 61, 62, 5, 116, 0, 0, 62, 63, 5, 114, 0, 0, 63, 64, 5, 117, 0, 0, 64, 65, 5, 101, 0, 0, 65, 2, 1, 0, 0, 0, 66, 67, 5, 102, 0, 0, 67, 68, 5, 97, 0, 0, 68, 69, 5, 108, 0, 0, 69, 70, 5, 115, 0, 0, 70, 71, 5, 101, 0, 0, 71, 4, 1, 0, 0, 0, 72, 73, 5, 40, 0, 0, 73, 6, 1, 0, 0, 0, 74, 75, 5, 43, 0, 0, 75, 8, 1, 0, 0, 0, 76, 77, 5, 41, 0, 0, 77, 10, 1, 0, 0, 0, 78, 79, 5, 45, 0, 0, 79, 12, 1, 0, 0, 0, 80, 81, 5, 42, 0, 0, 81, 14, 1, 0, 0, 0, 82, 83, 5, 47, 0, 0, 83, 16, 1, 0, 0, 0, 84, 85, 5, 62, 0, 0, 85, 18, 1, 0, 0, 0, 86, 87, 5, 60, 0, 0, 87, 20, 1, 0, 0, 0, 88, 89, 5, 61, 0, 0, 89, 90, 5, 61, 0, 0, 90, 22, 1, 0, 0, 0, 91, 92, 5, 60, 0, 0, 92, 93, 5, 60, 0, 0, 93, 24, 1, 0, 0, 0, 94, 95, 5, 62, 0, 0, 95, 96, 5, 62, 0, 0, 96, 26, 1, 0, 0, 0, 97, 98, 5, 38, 0, 0, 98, 99, 5, 38, 0, 0, 99, 28, 1, 0, 0, 0, 100, 101, 5, 124, 0, 0, 101, 102, 5, 124, 0, 0, 102, 30, 1, 0, 0, 0, 103, 104, 5, 94, 0, 0, 104, 105, 5, 94, 0, 0, 105, 32, 1, 0, 0, 0, 106, 107, 5, 44, 0, 0, 107, 34, 1, 0, 0, 0, 108, 109, 5, 58, 0, 0, 109, 36, 1, 0, 0, 0, 110, 111, 5, 108, 0, 0, 111, 112, 5, 101, 0, 0, 112, 113, 5, 116, 0, 0, 113, 38, 1, 0, 0, 0, 114, 115, 5, 61, 0, 0, 115, 40, 1, 0, 0, 0, 116, 117, 5, 105, 0, 0, 117, 118, 5, 110, 0, 0, 118, 42, 1, 0, 0, 0, 119, 120, 5, 105, 0, 0, 120, 121, 5, 102, 0, 0, 121, 44, 1, 0, 0, 0, 122, 123, 5, 116, 0, 0, 123, 124, 5, 104, 0, 0, 124, 125, 5, 101, 0, 0, 125, 126, 5, 110, 0, 0, 126, 46, 1, 0, 0, 0, 127, 128, 5, 101, 0, 0, 128, 129, 5, 108, 0, 0, 129, 130, 5, 115, 0, 0, 130, 131, 5, 101, 0, 0, 131, 48, 1, 0, 0, 0, 132, 137, 3, 55, 27, 0, 133, 136, 3, 55, 27, 0, 134, 136, 3, 57, 28, 0, 135, 133, 1, 0, 0, 0, 135, 134, 1, 0, 0, 0, 136, 139, 1, 0, 0, 0, 137, 135, 1, 0, 0, 0, 137, 138, 1, 0, 0, 0, 138, 50, 1, 0, 0, 0, 139, 137, 1, 0, 0, 0, 140, 142, 3, 57, 28, 0, 141, 140, 1, 0, 0, 0, 142, 143, 1, 0, 0, 0, 143, 141, 1, 0, 0, 0, 143, 144, 1, 0, 0, 0, 144, 52, 1, 0, 0, 0, 145, 151, 5, 34, 0, 0, 146, 150, 7, 0, 0, 0, 147, 148, 5, 92, 0, 0, 148, 150, 9, 0, 0, 0, 149, 146, 1, 0, 0, 0, 149, 147, 1, 0, 0, 0, 150, 153, 1, 0, 0, 0, 151, 149, 1, 0, 0, 0, 151, 152, 1, 0, 0, 0, 152, 154, 1, 0, 0, 0, 153, 151, 1, 0, 0, 0, 154, 155, 5, 34, 0, 0, 155, 54, 1, 0, 0, 0, 156, 157, 7, 1, 0, 0, 157, 56, 1, 0, 0, 0, 158, 159, 2, 48, 57, 0, 159, 58, 1, 0, 0, 0, 160, 162, 7, 2, 0, 0, 161, 160, 1, 0, 0, 0, 162, 163, 1, 0, 0, 0, 163, 161, 1, 0, 0, 0, 163, 164, 1, 0, 0, 0, 164, 165, 1, 0, 0, 0, 165, 166, 6, 29, 0, 0, 166, 60, 1, 0, 0, 0, 7, 0, 135, 137, 143, 149, 151, 163, 1, 6, 0, 0]- \ No newline at end of file +[4, 0, 29, 173, 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, 2, 26, 7, 26, 2, 27, 7, 27, 2, 28, 7, 28, 2, 29, 7, 29, 2, 30, 7, 30, 1, 0, 1, 0, 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, 5, 1, 5, 1, 5, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 7, 1, 7, 1, 8, 1, 8, 1, 9, 1, 9, 1, 10, 1, 10, 1, 11, 1, 11, 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, 16, 1, 17, 1, 17, 1, 17, 1, 18, 1, 18, 1, 18, 1, 19, 1, 19, 1, 19, 1, 19, 1, 20, 1, 20, 1, 21, 1, 21, 1, 21, 1, 22, 1, 22, 1, 22, 1, 23, 1, 23, 1, 23, 1, 23, 1, 23, 1, 24, 1, 24, 1, 24, 1, 24, 1, 24, 1, 25, 1, 25, 1, 25, 5, 25, 142, 8, 25, 10, 25, 12, 25, 145, 9, 25, 1, 26, 4, 26, 148, 8, 26, 11, 26, 12, 26, 149, 1, 27, 1, 27, 1, 27, 1, 27, 5, 27, 156, 8, 27, 10, 27, 12, 27, 159, 9, 27, 1, 27, 1, 27, 1, 28, 1, 28, 1, 29, 1, 29, 1, 30, 4, 30, 168, 8, 30, 11, 30, 12, 30, 169, 1, 30, 1, 30, 0, 0, 31, 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, 24, 49, 25, 51, 26, 53, 27, 55, 28, 57, 0, 59, 0, 61, 29, 1, 0, 3, 2, 0, 34, 34, 94, 94, 2, 0, 65, 90, 97, 122, 3, 0, 9, 10, 13, 13, 32, 32, 176, 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, 47, 1, 0, 0, 0, 0, 49, 1, 0, 0, 0, 0, 51, 1, 0, 0, 0, 0, 53, 1, 0, 0, 0, 0, 55, 1, 0, 0, 0, 0, 61, 1, 0, 0, 0, 1, 63, 1, 0, 0, 0, 3, 67, 1, 0, 0, 0, 5, 69, 1, 0, 0, 0, 7, 71, 1, 0, 0, 0, 9, 73, 1, 0, 0, 0, 11, 75, 1, 0, 0, 0, 13, 80, 1, 0, 0, 0, 15, 86, 1, 0, 0, 0, 17, 88, 1, 0, 0, 0, 19, 90, 1, 0, 0, 0, 21, 92, 1, 0, 0, 0, 23, 94, 1, 0, 0, 0, 25, 96, 1, 0, 0, 0, 27, 98, 1, 0, 0, 0, 29, 101, 1, 0, 0, 0, 31, 104, 1, 0, 0, 0, 33, 107, 1, 0, 0, 0, 35, 110, 1, 0, 0, 0, 37, 113, 1, 0, 0, 0, 39, 116, 1, 0, 0, 0, 41, 120, 1, 0, 0, 0, 43, 122, 1, 0, 0, 0, 45, 125, 1, 0, 0, 0, 47, 128, 1, 0, 0, 0, 49, 133, 1, 0, 0, 0, 51, 138, 1, 0, 0, 0, 53, 147, 1, 0, 0, 0, 55, 151, 1, 0, 0, 0, 57, 162, 1, 0, 0, 0, 59, 164, 1, 0, 0, 0, 61, 167, 1, 0, 0, 0, 63, 64, 5, 100, 0, 0, 64, 65, 5, 101, 0, 0, 65, 66, 5, 102, 0, 0, 66, 2, 1, 0, 0, 0, 67, 68, 5, 40, 0, 0, 68, 4, 1, 0, 0, 0, 69, 70, 5, 44, 0, 0, 70, 6, 1, 0, 0, 0, 71, 72, 5, 41, 0, 0, 72, 8, 1, 0, 0, 0, 73, 74, 5, 58, 0, 0, 74, 10, 1, 0, 0, 0, 75, 76, 5, 116, 0, 0, 76, 77, 5, 114, 0, 0, 77, 78, 5, 117, 0, 0, 78, 79, 5, 101, 0, 0, 79, 12, 1, 0, 0, 0, 80, 81, 5, 102, 0, 0, 81, 82, 5, 97, 0, 0, 82, 83, 5, 108, 0, 0, 83, 84, 5, 115, 0, 0, 84, 85, 5, 101, 0, 0, 85, 14, 1, 0, 0, 0, 86, 87, 5, 43, 0, 0, 87, 16, 1, 0, 0, 0, 88, 89, 5, 45, 0, 0, 89, 18, 1, 0, 0, 0, 90, 91, 5, 42, 0, 0, 91, 20, 1, 0, 0, 0, 92, 93, 5, 47, 0, 0, 93, 22, 1, 0, 0, 0, 94, 95, 5, 62, 0, 0, 95, 24, 1, 0, 0, 0, 96, 97, 5, 60, 0, 0, 97, 26, 1, 0, 0, 0, 98, 99, 5, 61, 0, 0, 99, 100, 5, 61, 0, 0, 100, 28, 1, 0, 0, 0, 101, 102, 5, 60, 0, 0, 102, 103, 5, 60, 0, 0, 103, 30, 1, 0, 0, 0, 104, 105, 5, 62, 0, 0, 105, 106, 5, 62, 0, 0, 106, 32, 1, 0, 0, 0, 107, 108, 5, 38, 0, 0, 108, 109, 5, 38, 0, 0, 109, 34, 1, 0, 0, 0, 110, 111, 5, 124, 0, 0, 111, 112, 5, 124, 0, 0, 112, 36, 1, 0, 0, 0, 113, 114, 5, 94, 0, 0, 114, 115, 5, 94, 0, 0, 115, 38, 1, 0, 0, 0, 116, 117, 5, 108, 0, 0, 117, 118, 5, 101, 0, 0, 118, 119, 5, 116, 0, 0, 119, 40, 1, 0, 0, 0, 120, 121, 5, 61, 0, 0, 121, 42, 1, 0, 0, 0, 122, 123, 5, 105, 0, 0, 123, 124, 5, 110, 0, 0, 124, 44, 1, 0, 0, 0, 125, 126, 5, 105, 0, 0, 126, 127, 5, 102, 0, 0, 127, 46, 1, 0, 0, 0, 128, 129, 5, 116, 0, 0, 129, 130, 5, 104, 0, 0, 130, 131, 5, 101, 0, 0, 131, 132, 5, 110, 0, 0, 132, 48, 1, 0, 0, 0, 133, 134, 5, 101, 0, 0, 134, 135, 5, 108, 0, 0, 135, 136, 5, 115, 0, 0, 136, 137, 5, 101, 0, 0, 137, 50, 1, 0, 0, 0, 138, 143, 3, 57, 28, 0, 139, 142, 3, 57, 28, 0, 140, 142, 3, 59, 29, 0, 141, 139, 1, 0, 0, 0, 141, 140, 1, 0, 0, 0, 142, 145, 1, 0, 0, 0, 143, 141, 1, 0, 0, 0, 143, 144, 1, 0, 0, 0, 144, 52, 1, 0, 0, 0, 145, 143, 1, 0, 0, 0, 146, 148, 3, 59, 29, 0, 147, 146, 1, 0, 0, 0, 148, 149, 1, 0, 0, 0, 149, 147, 1, 0, 0, 0, 149, 150, 1, 0, 0, 0, 150, 54, 1, 0, 0, 0, 151, 157, 5, 34, 0, 0, 152, 156, 7, 0, 0, 0, 153, 154, 5, 92, 0, 0, 154, 156, 9, 0, 0, 0, 155, 152, 1, 0, 0, 0, 155, 153, 1, 0, 0, 0, 156, 159, 1, 0, 0, 0, 157, 155, 1, 0, 0, 0, 157, 158, 1, 0, 0, 0, 158, 160, 1, 0, 0, 0, 159, 157, 1, 0, 0, 0, 160, 161, 5, 34, 0, 0, 161, 56, 1, 0, 0, 0, 162, 163, 7, 1, 0, 0, 163, 58, 1, 0, 0, 0, 164, 165, 2, 48, 57, 0, 165, 60, 1, 0, 0, 0, 166, 168, 7, 2, 0, 0, 167, 166, 1, 0, 0, 0, 168, 169, 1, 0, 0, 0, 169, 167, 1, 0, 0, 0, 169, 170, 1, 0, 0, 0, 170, 171, 1, 0, 0, 0, 171, 172, 6, 30, 0, 0, 172, 62, 1, 0, 0, 0, 7, 0, 141, 143, 149, 155, 157, 169, 1, 6, 0, 0]+ \ No newline at end of file diff --git a/gen/ANFLexer.py b/gen/ANFLexer.py @@ -10,63 +10,65 @@ else: def serializedATN(): return [ - 4,0,28,167,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, + 4,0,29,173,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,2, - 26,7,26,2,27,7,27,2,28,7,28,2,29,7,29,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,1,22,1, - 22,1,22,1,22,1,22,1,23,1,23,1,23,1,23,1,23,1,24,1,24,1,24,5,24,136, - 8,24,10,24,12,24,139,9,24,1,25,4,25,142,8,25,11,25,12,25,143,1,26, - 1,26,1,26,1,26,5,26,150,8,26,10,26,12,26,153,9,26,1,26,1,26,1,27, - 1,27,1,28,1,28,1,29,4,29,162,8,29,11,29,12,29,163,1,29,1,29,0,0, - 30,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, - 24,49,25,51,26,53,27,55,0,57,0,59,28,1,0,3,2,0,34,34,94,94,2,0,65, - 90,97,122,3,0,9,10,13,13,32,32,170,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,47,1,0,0,0,0,49,1,0,0,0,0,51,1,0,0,0,0,53,1,0,0,0,0,59,1,0, - 0,0,1,61,1,0,0,0,3,66,1,0,0,0,5,72,1,0,0,0,7,74,1,0,0,0,9,76,1,0, - 0,0,11,78,1,0,0,0,13,80,1,0,0,0,15,82,1,0,0,0,17,84,1,0,0,0,19,86, - 1,0,0,0,21,88,1,0,0,0,23,91,1,0,0,0,25,94,1,0,0,0,27,97,1,0,0,0, - 29,100,1,0,0,0,31,103,1,0,0,0,33,106,1,0,0,0,35,108,1,0,0,0,37,110, - 1,0,0,0,39,114,1,0,0,0,41,116,1,0,0,0,43,119,1,0,0,0,45,122,1,0, - 0,0,47,127,1,0,0,0,49,132,1,0,0,0,51,141,1,0,0,0,53,145,1,0,0,0, - 55,156,1,0,0,0,57,158,1,0,0,0,59,161,1,0,0,0,61,62,5,116,0,0,62, - 63,5,114,0,0,63,64,5,117,0,0,64,65,5,101,0,0,65,2,1,0,0,0,66,67, - 5,102,0,0,67,68,5,97,0,0,68,69,5,108,0,0,69,70,5,115,0,0,70,71,5, - 101,0,0,71,4,1,0,0,0,72,73,5,40,0,0,73,6,1,0,0,0,74,75,5,43,0,0, - 75,8,1,0,0,0,76,77,5,41,0,0,77,10,1,0,0,0,78,79,5,45,0,0,79,12,1, - 0,0,0,80,81,5,42,0,0,81,14,1,0,0,0,82,83,5,47,0,0,83,16,1,0,0,0, - 84,85,5,62,0,0,85,18,1,0,0,0,86,87,5,60,0,0,87,20,1,0,0,0,88,89, - 5,61,0,0,89,90,5,61,0,0,90,22,1,0,0,0,91,92,5,60,0,0,92,93,5,60, - 0,0,93,24,1,0,0,0,94,95,5,62,0,0,95,96,5,62,0,0,96,26,1,0,0,0,97, - 98,5,38,0,0,98,99,5,38,0,0,99,28,1,0,0,0,100,101,5,124,0,0,101,102, - 5,124,0,0,102,30,1,0,0,0,103,104,5,94,0,0,104,105,5,94,0,0,105,32, - 1,0,0,0,106,107,5,44,0,0,107,34,1,0,0,0,108,109,5,58,0,0,109,36, - 1,0,0,0,110,111,5,108,0,0,111,112,5,101,0,0,112,113,5,116,0,0,113, - 38,1,0,0,0,114,115,5,61,0,0,115,40,1,0,0,0,116,117,5,105,0,0,117, - 118,5,110,0,0,118,42,1,0,0,0,119,120,5,105,0,0,120,121,5,102,0,0, - 121,44,1,0,0,0,122,123,5,116,0,0,123,124,5,104,0,0,124,125,5,101, - 0,0,125,126,5,110,0,0,126,46,1,0,0,0,127,128,5,101,0,0,128,129,5, - 108,0,0,129,130,5,115,0,0,130,131,5,101,0,0,131,48,1,0,0,0,132,137, - 3,55,27,0,133,136,3,55,27,0,134,136,3,57,28,0,135,133,1,0,0,0,135, - 134,1,0,0,0,136,139,1,0,0,0,137,135,1,0,0,0,137,138,1,0,0,0,138, - 50,1,0,0,0,139,137,1,0,0,0,140,142,3,57,28,0,141,140,1,0,0,0,142, - 143,1,0,0,0,143,141,1,0,0,0,143,144,1,0,0,0,144,52,1,0,0,0,145,151, - 5,34,0,0,146,150,7,0,0,0,147,148,5,92,0,0,148,150,9,0,0,0,149,146, - 1,0,0,0,149,147,1,0,0,0,150,153,1,0,0,0,151,149,1,0,0,0,151,152, - 1,0,0,0,152,154,1,0,0,0,153,151,1,0,0,0,154,155,5,34,0,0,155,54, - 1,0,0,0,156,157,7,1,0,0,157,56,1,0,0,0,158,159,2,48,57,0,159,58, - 1,0,0,0,160,162,7,2,0,0,161,160,1,0,0,0,162,163,1,0,0,0,163,161, - 1,0,0,0,163,164,1,0,0,0,164,165,1,0,0,0,165,166,6,29,0,0,166,60, - 1,0,0,0,7,0,135,137,143,149,151,163,1,6,0,0 + 26,7,26,2,27,7,27,2,28,7,28,2,29,7,29,2,30,7,30,1,0,1,0,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,5,1,5,1,5,1,6,1,6,1,6, + 1,6,1,6,1,6,1,7,1,7,1,8,1,8,1,9,1,9,1,10,1,10,1,11,1,11,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,16,1,17, + 1,17,1,17,1,18,1,18,1,18,1,19,1,19,1,19,1,19,1,20,1,20,1,21,1,21, + 1,21,1,22,1,22,1,22,1,23,1,23,1,23,1,23,1,23,1,24,1,24,1,24,1,24, + 1,24,1,25,1,25,1,25,5,25,142,8,25,10,25,12,25,145,9,25,1,26,4,26, + 148,8,26,11,26,12,26,149,1,27,1,27,1,27,1,27,5,27,156,8,27,10,27, + 12,27,159,9,27,1,27,1,27,1,28,1,28,1,29,1,29,1,30,4,30,168,8,30, + 11,30,12,30,169,1,30,1,30,0,0,31,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,24,49,25,51,26,53,27,55,28,57,0,59, + 0,61,29,1,0,3,2,0,34,34,94,94,2,0,65,90,97,122,3,0,9,10,13,13,32, + 32,176,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,47,1,0,0,0,0,49,1,0,0, + 0,0,51,1,0,0,0,0,53,1,0,0,0,0,55,1,0,0,0,0,61,1,0,0,0,1,63,1,0,0, + 0,3,67,1,0,0,0,5,69,1,0,0,0,7,71,1,0,0,0,9,73,1,0,0,0,11,75,1,0, + 0,0,13,80,1,0,0,0,15,86,1,0,0,0,17,88,1,0,0,0,19,90,1,0,0,0,21,92, + 1,0,0,0,23,94,1,0,0,0,25,96,1,0,0,0,27,98,1,0,0,0,29,101,1,0,0,0, + 31,104,1,0,0,0,33,107,1,0,0,0,35,110,1,0,0,0,37,113,1,0,0,0,39,116, + 1,0,0,0,41,120,1,0,0,0,43,122,1,0,0,0,45,125,1,0,0,0,47,128,1,0, + 0,0,49,133,1,0,0,0,51,138,1,0,0,0,53,147,1,0,0,0,55,151,1,0,0,0, + 57,162,1,0,0,0,59,164,1,0,0,0,61,167,1,0,0,0,63,64,5,100,0,0,64, + 65,5,101,0,0,65,66,5,102,0,0,66,2,1,0,0,0,67,68,5,40,0,0,68,4,1, + 0,0,0,69,70,5,44,0,0,70,6,1,0,0,0,71,72,5,41,0,0,72,8,1,0,0,0,73, + 74,5,58,0,0,74,10,1,0,0,0,75,76,5,116,0,0,76,77,5,114,0,0,77,78, + 5,117,0,0,78,79,5,101,0,0,79,12,1,0,0,0,80,81,5,102,0,0,81,82,5, + 97,0,0,82,83,5,108,0,0,83,84,5,115,0,0,84,85,5,101,0,0,85,14,1,0, + 0,0,86,87,5,43,0,0,87,16,1,0,0,0,88,89,5,45,0,0,89,18,1,0,0,0,90, + 91,5,42,0,0,91,20,1,0,0,0,92,93,5,47,0,0,93,22,1,0,0,0,94,95,5,62, + 0,0,95,24,1,0,0,0,96,97,5,60,0,0,97,26,1,0,0,0,98,99,5,61,0,0,99, + 100,5,61,0,0,100,28,1,0,0,0,101,102,5,60,0,0,102,103,5,60,0,0,103, + 30,1,0,0,0,104,105,5,62,0,0,105,106,5,62,0,0,106,32,1,0,0,0,107, + 108,5,38,0,0,108,109,5,38,0,0,109,34,1,0,0,0,110,111,5,124,0,0,111, + 112,5,124,0,0,112,36,1,0,0,0,113,114,5,94,0,0,114,115,5,94,0,0,115, + 38,1,0,0,0,116,117,5,108,0,0,117,118,5,101,0,0,118,119,5,116,0,0, + 119,40,1,0,0,0,120,121,5,61,0,0,121,42,1,0,0,0,122,123,5,105,0,0, + 123,124,5,110,0,0,124,44,1,0,0,0,125,126,5,105,0,0,126,127,5,102, + 0,0,127,46,1,0,0,0,128,129,5,116,0,0,129,130,5,104,0,0,130,131,5, + 101,0,0,131,132,5,110,0,0,132,48,1,0,0,0,133,134,5,101,0,0,134,135, + 5,108,0,0,135,136,5,115,0,0,136,137,5,101,0,0,137,50,1,0,0,0,138, + 143,3,57,28,0,139,142,3,57,28,0,140,142,3,59,29,0,141,139,1,0,0, + 0,141,140,1,0,0,0,142,145,1,0,0,0,143,141,1,0,0,0,143,144,1,0,0, + 0,144,52,1,0,0,0,145,143,1,0,0,0,146,148,3,59,29,0,147,146,1,0,0, + 0,148,149,1,0,0,0,149,147,1,0,0,0,149,150,1,0,0,0,150,54,1,0,0,0, + 151,157,5,34,0,0,152,156,7,0,0,0,153,154,5,92,0,0,154,156,9,0,0, + 0,155,152,1,0,0,0,155,153,1,0,0,0,156,159,1,0,0,0,157,155,1,0,0, + 0,157,158,1,0,0,0,158,160,1,0,0,0,159,157,1,0,0,0,160,161,5,34,0, + 0,161,56,1,0,0,0,162,163,7,1,0,0,163,58,1,0,0,0,164,165,2,48,57, + 0,165,60,1,0,0,0,166,168,7,2,0,0,167,166,1,0,0,0,168,169,1,0,0,0, + 169,167,1,0,0,0,169,170,1,0,0,0,170,171,1,0,0,0,171,172,6,30,0,0, + 172,62,1,0,0,0,7,0,141,143,149,155,157,169,1,6,0,0 ] class ANFLexer(Lexer): @@ -99,19 +101,20 @@ class ANFLexer(Lexer): T__21 = 22 T__22 = 23 T__23 = 24 - IDENT = 25 - NUMBER = 26 - STRING = 27 - WS = 28 + T__24 = 25 + IDENT = 26 + NUMBER = 27 + STRING = 28 + WS = 29 channelNames = [ u"DEFAULT_TOKEN_CHANNEL", u"HIDDEN" ] modeNames = [ "DEFAULT_MODE" ] literalNames = [ "<INVALID>", - "'true'", "'false'", "'('", "'+'", "')'", "'-'", "'*'", "'/'", - "'>'", "'<'", "'=='", "'<<'", "'>>'", "'&&'", "'||'", "'^^'", - "','", "':'", "'let'", "'='", "'in'", "'if'", "'then'", "'else'" ] + "'def'", "'('", "','", "')'", "':'", "'true'", "'false'", "'+'", + "'-'", "'*'", "'/'", "'>'", "'<'", "'=='", "'<<'", "'>>'", "'&&'", + "'||'", "'^^'", "'let'", "'='", "'in'", "'if'", "'then'", "'else'" ] symbolicNames = [ "<INVALID>", "IDENT", "NUMBER", "STRING", "WS" ] @@ -119,8 +122,8 @@ class ANFLexer(Lexer): ruleNames = [ "T__0", "T__1", "T__2", "T__3", "T__4", "T__5", "T__6", "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", "T__21", "T__22", "T__23", "IDENT", "NUMBER", - "STRING", "Letter", "Digit", "WS" ] + "T__20", "T__21", "T__22", "T__23", "T__24", "IDENT", + "NUMBER", "STRING", "Letter", "Digit", "WS" ] grammarFileName = "ANF.g4" diff --git a/gen/ANFLexer.tokens b/gen/ANFLexer.tokens @@ -22,31 +22,33 @@ T__20=21 T__21=22 T__22=23 T__23=24 -IDENT=25 -NUMBER=26 -STRING=27 -WS=28 -'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 -'if'=22 -'then'=23 -'else'=24 +T__24=25 +IDENT=26 +NUMBER=27 +STRING=28 +WS=29 +'def'=1 +'('=2 +','=3 +')'=4 +':'=5 +'true'=6 +'false'=7 +'+'=8 +'-'=9 +'*'=10 +'/'=11 +'>'=12 +'<'=13 +'=='=14 +'<<'=15 +'>>'=16 +'&&'=17 +'||'=18 +'^^'=19 +'let'=20 +'='=21 +'in'=22 +'if'=23 +'then'=24 +'else'=25 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#prog. + def enterProg(self, ctx:ANFParser.ProgContext): + pass + + # Exit a parse tree produced by ANFParser#prog. + def exitProg(self, ctx:ANFParser.ProgContext): + pass + + + # Enter a parse tree produced by ANFParser#def. + def enterDef(self, ctx:ANFParser.DefContext): + pass + + # Exit a parse tree produced by ANFParser#def. + def exitDef(self, ctx:ANFParser.DefContext): + pass + + # Enter a parse tree produced by ANFParser#true. def enterTrue(self, ctx:ANFParser.TrueContext): pass @@ -44,6 +62,15 @@ class ANFListener(ParseTreeListener): pass + # Enter a parse tree produced by ANFParser#str. + def enterStr(self, ctx:ANFParser.StrContext): + pass + + # Exit a parse tree produced by ANFParser#str. + def exitStr(self, ctx:ANFParser.StrContext): + pass + + # Enter a parse tree produced by ANFParser#add. def enterAdd(self, ctx:ANFParser.AddContext): pass diff --git a/gen/ANFParser.py b/gen/ANFParser.py @@ -10,49 +10,59 @@ else: def serializedATN(): return [ - 4,1,28,130,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,5,0,87,8,0,10,0,12,0,90,9,0,1, - 0,1,0,1,0,1,0,3,0,96,8,0,1,1,1,1,1,1,1,1,1,1,5,1,103,8,1,10,1,12, - 1,106,9,1,1,1,1,1,1,1,3,1,111,8,1,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1, - 2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,3,2,128,8,2,1,2,0,0,3,0,2,4,0,0,147, - 0,95,1,0,0,0,2,110,1,0,0,0,4,127,1,0,0,0,6,96,5,1,0,0,7,96,5,2,0, - 0,8,96,5,25,0,0,9,96,5,26,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,96,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,96,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,96,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,96,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,96,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,96,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,96,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,96,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,96,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,96,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,96,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, - 96,1,0,0,0,82,83,5,3,0,0,83,88,5,25,0,0,84,85,5,17,0,0,85,87,5,25, - 0,0,86,84,1,0,0,0,87,90,1,0,0,0,88,86,1,0,0,0,88,89,1,0,0,0,89,91, - 1,0,0,0,90,88,1,0,0,0,91,92,5,18,0,0,92,93,3,4,2,0,93,94,5,5,0,0, - 94,96,1,0,0,0,95,6,1,0,0,0,95,7,1,0,0,0,95,8,1,0,0,0,95,9,1,0,0, - 0,95,10,1,0,0,0,95,16,1,0,0,0,95,22,1,0,0,0,95,28,1,0,0,0,95,34, - 1,0,0,0,95,40,1,0,0,0,95,46,1,0,0,0,95,52,1,0,0,0,95,58,1,0,0,0, - 95,64,1,0,0,0,95,70,1,0,0,0,95,76,1,0,0,0,95,82,1,0,0,0,96,1,1,0, - 0,0,97,98,5,25,0,0,98,99,5,3,0,0,99,104,3,0,0,0,100,101,5,17,0,0, - 101,103,3,0,0,0,102,100,1,0,0,0,103,106,1,0,0,0,104,102,1,0,0,0, - 104,105,1,0,0,0,105,107,1,0,0,0,106,104,1,0,0,0,107,108,5,5,0,0, - 108,111,1,0,0,0,109,111,3,0,0,0,110,97,1,0,0,0,110,109,1,0,0,0,111, - 3,1,0,0,0,112,113,5,19,0,0,113,114,5,25,0,0,114,115,5,20,0,0,115, - 116,3,2,1,0,116,117,5,21,0,0,117,118,3,4,2,0,118,128,1,0,0,0,119, - 120,5,22,0,0,120,121,3,0,0,0,121,122,5,23,0,0,122,123,3,4,2,0,123, - 124,5,24,0,0,124,125,3,4,2,0,125,128,1,0,0,0,126,128,3,2,1,0,127, - 112,1,0,0,0,127,119,1,0,0,0,127,126,1,0,0,0,128,5,1,0,0,0,5,88,95, - 104,110,127 + 4,1,29,157,2,0,7,0,2,1,7,1,2,2,7,2,2,3,7,3,2,4,7,4,1,0,4,0,12,8, + 0,11,0,12,0,13,1,1,1,1,1,1,1,1,1,1,1,1,5,1,22,8,1,10,1,12,1,25,9, + 1,3,1,27,8,1,1,1,1,1,1,1,1,1,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2, + 1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2, + 1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2, + 1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2, + 1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2, + 1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,5,2,114,8,2,10,2,12,2,117,9,2,1, + 2,1,2,1,2,1,2,3,2,123,8,2,1,3,1,3,1,3,1,3,1,3,5,3,130,8,3,10,3,12, + 3,133,9,3,1,3,1,3,1,3,3,3,138,8,3,1,4,1,4,1,4,1,4,1,4,1,4,1,4,1, + 4,1,4,1,4,1,4,1,4,1,4,1,4,1,4,3,4,155,8,4,1,4,0,0,5,0,2,4,6,8,0, + 0,176,0,11,1,0,0,0,2,15,1,0,0,0,4,122,1,0,0,0,6,137,1,0,0,0,8,154, + 1,0,0,0,10,12,3,2,1,0,11,10,1,0,0,0,12,13,1,0,0,0,13,11,1,0,0,0, + 13,14,1,0,0,0,14,1,1,0,0,0,15,16,5,1,0,0,16,17,5,26,0,0,17,26,5, + 2,0,0,18,23,5,26,0,0,19,20,5,3,0,0,20,22,5,26,0,0,21,19,1,0,0,0, + 22,25,1,0,0,0,23,21,1,0,0,0,23,24,1,0,0,0,24,27,1,0,0,0,25,23,1, + 0,0,0,26,18,1,0,0,0,26,27,1,0,0,0,27,28,1,0,0,0,28,29,5,4,0,0,29, + 30,5,5,0,0,30,31,3,8,4,0,31,3,1,0,0,0,32,123,5,6,0,0,33,123,5,7, + 0,0,34,123,5,26,0,0,35,123,5,27,0,0,36,123,5,28,0,0,37,38,5,2,0, + 0,38,39,3,4,2,0,39,40,5,8,0,0,40,41,3,4,2,0,41,42,5,4,0,0,42,123, + 1,0,0,0,43,44,5,2,0,0,44,45,3,4,2,0,45,46,5,9,0,0,46,47,3,4,2,0, + 47,48,5,4,0,0,48,123,1,0,0,0,49,50,5,2,0,0,50,51,3,4,2,0,51,52,5, + 10,0,0,52,53,3,4,2,0,53,54,5,4,0,0,54,123,1,0,0,0,55,56,5,2,0,0, + 56,57,3,4,2,0,57,58,5,11,0,0,58,59,3,4,2,0,59,60,5,4,0,0,60,123, + 1,0,0,0,61,62,5,2,0,0,62,63,3,4,2,0,63,64,5,12,0,0,64,65,3,4,2,0, + 65,66,5,4,0,0,66,123,1,0,0,0,67,68,5,2,0,0,68,69,3,4,2,0,69,70,5, + 13,0,0,70,71,3,4,2,0,71,72,5,4,0,0,72,123,1,0,0,0,73,74,5,2,0,0, + 74,75,3,4,2,0,75,76,5,14,0,0,76,77,3,4,2,0,77,78,5,4,0,0,78,123, + 1,0,0,0,79,80,5,2,0,0,80,81,3,4,2,0,81,82,5,15,0,0,82,83,3,4,2,0, + 83,84,5,4,0,0,84,123,1,0,0,0,85,86,5,2,0,0,86,87,3,4,2,0,87,88,5, + 16,0,0,88,89,3,4,2,0,89,90,5,4,0,0,90,123,1,0,0,0,91,92,5,2,0,0, + 92,93,3,4,2,0,93,94,5,17,0,0,94,95,3,4,2,0,95,96,5,4,0,0,96,123, + 1,0,0,0,97,98,5,2,0,0,98,99,3,4,2,0,99,100,5,18,0,0,100,101,3,4, + 2,0,101,102,5,4,0,0,102,123,1,0,0,0,103,104,5,2,0,0,104,105,3,4, + 2,0,105,106,5,19,0,0,106,107,3,4,2,0,107,108,5,4,0,0,108,123,1,0, + 0,0,109,110,5,2,0,0,110,115,5,26,0,0,111,112,5,3,0,0,112,114,5,26, + 0,0,113,111,1,0,0,0,114,117,1,0,0,0,115,113,1,0,0,0,115,116,1,0, + 0,0,116,118,1,0,0,0,117,115,1,0,0,0,118,119,5,5,0,0,119,120,3,8, + 4,0,120,121,5,4,0,0,121,123,1,0,0,0,122,32,1,0,0,0,122,33,1,0,0, + 0,122,34,1,0,0,0,122,35,1,0,0,0,122,36,1,0,0,0,122,37,1,0,0,0,122, + 43,1,0,0,0,122,49,1,0,0,0,122,55,1,0,0,0,122,61,1,0,0,0,122,67,1, + 0,0,0,122,73,1,0,0,0,122,79,1,0,0,0,122,85,1,0,0,0,122,91,1,0,0, + 0,122,97,1,0,0,0,122,103,1,0,0,0,122,109,1,0,0,0,123,5,1,0,0,0,124, + 125,5,26,0,0,125,126,5,2,0,0,126,131,3,4,2,0,127,128,5,3,0,0,128, + 130,3,4,2,0,129,127,1,0,0,0,130,133,1,0,0,0,131,129,1,0,0,0,131, + 132,1,0,0,0,132,134,1,0,0,0,133,131,1,0,0,0,134,135,5,4,0,0,135, + 138,1,0,0,0,136,138,3,4,2,0,137,124,1,0,0,0,137,136,1,0,0,0,138, + 7,1,0,0,0,139,140,5,20,0,0,140,141,5,26,0,0,141,142,5,21,0,0,142, + 143,3,6,3,0,143,144,5,22,0,0,144,145,3,8,4,0,145,155,1,0,0,0,146, + 147,5,23,0,0,147,148,3,4,2,0,148,149,5,24,0,0,149,150,3,8,4,0,150, + 151,5,25,0,0,151,152,3,8,4,0,152,155,1,0,0,0,153,155,3,6,3,0,154, + 139,1,0,0,0,154,146,1,0,0,0,154,153,1,0,0,0,155,9,1,0,0,0,8,13,23, + 26,115,122,131,137,154 ] class ANFParser ( Parser ): @@ -65,9 +75,9 @@ class ANFParser ( Parser ): sharedContextCache = PredictionContextCache() - literalNames = [ "<INVALID>", "'true'", "'false'", "'('", "'+'", "')'", - "'-'", "'*'", "'/'", "'>'", "'<'", "'=='", "'<<'", - "'>>'", "'&&'", "'||'", "'^^'", "','", "':'", "'let'", + literalNames = [ "<INVALID>", "'def'", "'('", "','", "')'", "':'", "'true'", + "'false'", "'+'", "'-'", "'*'", "'/'", "'>'", "'<'", + "'=='", "'<<'", "'>>'", "'&&'", "'||'", "'^^'", "'let'", "'='", "'in'", "'if'", "'then'", "'else'" ] symbolicNames = [ "<INVALID>", "<INVALID>", "<INVALID>", "<INVALID>", @@ -76,13 +86,16 @@ class ANFParser ( Parser ): "<INVALID>", "<INVALID>", "<INVALID>", "<INVALID>", "<INVALID>", "<INVALID>", "<INVALID>", "<INVALID>", "<INVALID>", "<INVALID>", "<INVALID>", "<INVALID>", - "<INVALID>", "IDENT", "NUMBER", "STRING", "WS" ] + "<INVALID>", "<INVALID>", "IDENT", "NUMBER", "STRING", + "WS" ] - RULE_aexp = 0 - RULE_funcall = 1 - RULE_cexp = 2 + RULE_prog = 0 + RULE_def = 1 + RULE_aexp = 2 + RULE_funcall = 3 + RULE_cexp = 4 - ruleNames = [ "aexp", "funcall", "cexp" ] + ruleNames = [ "prog", "def", "aexp", "funcall", "cexp" ] EOF = Token.EOF T__0=1 @@ -109,10 +122,11 @@ class ANFParser ( Parser ): T__21=22 T__22=23 T__23=24 - IDENT=25 - NUMBER=26 - STRING=27 - WS=28 + T__24=25 + IDENT=26 + NUMBER=27 + STRING=28 + WS=29 def __init__(self, input:TokenStream, output:TextIO = sys.stdout): super().__init__(input, output) @@ -123,6 +137,153 @@ class ANFParser ( Parser ): + class ProgContext(ParserRuleContext): + __slots__ = 'parser' + + def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1): + super().__init__(parent, invokingState) + self.parser = parser + + def def_(self, i:int=None): + if i is None: + return self.getTypedRuleContexts(ANFParser.DefContext) + else: + return self.getTypedRuleContext(ANFParser.DefContext,i) + + + def getRuleIndex(self): + return ANFParser.RULE_prog + + def enterRule(self, listener:ParseTreeListener): + if hasattr( listener, "enterProg" ): + listener.enterProg(self) + + def exitRule(self, listener:ParseTreeListener): + if hasattr( listener, "exitProg" ): + listener.exitProg(self) + + def accept(self, visitor:ParseTreeVisitor): + if hasattr( visitor, "visitProg" ): + return visitor.visitProg(self) + else: + return visitor.visitChildren(self) + + + + + def prog(self): + + localctx = ANFParser.ProgContext(self, self._ctx, self.state) + self.enterRule(localctx, 0, self.RULE_prog) + self._la = 0 # Token type + try: + self.enterOuterAlt(localctx, 1) + self.state = 11 + self._errHandler.sync(self) + _la = self._input.LA(1) + while True: + self.state = 10 + self.def_() + self.state = 13 + self._errHandler.sync(self) + _la = self._input.LA(1) + if not (_la==1): + break + + except RecognitionException as re: + localctx.exception = re + self._errHandler.reportError(self, re) + self._errHandler.recover(self, re) + finally: + self.exitRule() + return localctx + + + class DefContext(ParserRuleContext): + __slots__ = 'parser' + + def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1): + super().__init__(parent, invokingState) + self.parser = parser + + def IDENT(self, i:int=None): + if i is None: + return self.getTokens(ANFParser.IDENT) + else: + return self.getToken(ANFParser.IDENT, i) + + def cexp(self): + return self.getTypedRuleContext(ANFParser.CexpContext,0) + + + def getRuleIndex(self): + return ANFParser.RULE_def + + def enterRule(self, listener:ParseTreeListener): + if hasattr( listener, "enterDef" ): + listener.enterDef(self) + + def exitRule(self, listener:ParseTreeListener): + if hasattr( listener, "exitDef" ): + listener.exitDef(self) + + def accept(self, visitor:ParseTreeVisitor): + if hasattr( visitor, "visitDef" ): + return visitor.visitDef(self) + else: + return visitor.visitChildren(self) + + + + + def def_(self): + + localctx = ANFParser.DefContext(self, self._ctx, self.state) + self.enterRule(localctx, 2, self.RULE_def) + self._la = 0 # Token type + try: + self.enterOuterAlt(localctx, 1) + self.state = 15 + self.match(ANFParser.T__0) + self.state = 16 + self.match(ANFParser.IDENT) + self.state = 17 + self.match(ANFParser.T__1) + self.state = 26 + self._errHandler.sync(self) + _la = self._input.LA(1) + if _la==26: + self.state = 18 + self.match(ANFParser.IDENT) + self.state = 23 + self._errHandler.sync(self) + _la = self._input.LA(1) + while _la==3: + self.state = 19 + self.match(ANFParser.T__2) + self.state = 20 + self.match(ANFParser.IDENT) + self.state = 25 + self._errHandler.sync(self) + _la = self._input.LA(1) + + + + self.state = 28 + self.match(ANFParser.T__3) + self.state = 29 + self.match(ANFParser.T__4) + self.state = 30 + self.cexp() + except RecognitionException as re: + localctx.exception = re + self._errHandler.reportError(self, re) + self._errHandler.recover(self, re) + finally: + self.exitRule() + return localctx + + class AexpContext(ParserRuleContext): __slots__ = 'parser' @@ -434,6 +595,30 @@ class ANFParser ( Parser ): return visitor.visitChildren(self) + class StrContext(AexpContext): + + def __init__(self, parser, ctx:ParserRuleContext): # actually a ANFParser.AexpContext + super().__init__(parser) + self.copyFrom(ctx) + + def STRING(self): + return self.getToken(ANFParser.STRING, 0) + + def enterRule(self, listener:ParseTreeListener): + if hasattr( listener, "enterStr" ): + listener.enterStr(self) + + def exitRule(self, listener:ParseTreeListener): + if hasattr( listener, "exitStr" ): + listener.exitStr(self) + + def accept(self, visitor:ParseTreeVisitor): + if hasattr( visitor, "visitStr" ): + return visitor.visitStr(self) + else: + return visitor.visitChildren(self) + + class DivContext(AexpContext): def __init__(self, parser, ctx:ParserRuleContext): # actually a ANFParser.AexpContext @@ -602,245 +787,252 @@ class ANFParser ( Parser ): def aexp(self): localctx = ANFParser.AexpContext(self, self._ctx, self.state) - self.enterRule(localctx, 0, self.RULE_aexp) + self.enterRule(localctx, 4, self.RULE_aexp) self._la = 0 # Token type try: - self.state = 95 + self.state = 122 self._errHandler.sync(self) - la_ = self._interp.adaptivePredict(self._input,1,self._ctx) + la_ = self._interp.adaptivePredict(self._input,4,self._ctx) if la_ == 1: localctx = ANFParser.TrueContext(self, localctx) self.enterOuterAlt(localctx, 1) - self.state = 6 - self.match(ANFParser.T__0) + self.state = 32 + self.match(ANFParser.T__5) pass elif la_ == 2: localctx = ANFParser.FalseContext(self, localctx) self.enterOuterAlt(localctx, 2) - self.state = 7 - self.match(ANFParser.T__1) + self.state = 33 + self.match(ANFParser.T__6) pass elif la_ == 3: localctx = ANFParser.VarContext(self, localctx) self.enterOuterAlt(localctx, 3) - self.state = 8 + self.state = 34 self.match(ANFParser.IDENT) pass elif la_ == 4: localctx = ANFParser.NumContext(self, localctx) self.enterOuterAlt(localctx, 4) - self.state = 9 + self.state = 35 self.match(ANFParser.NUMBER) pass elif la_ == 5: - localctx = ANFParser.AddContext(self, localctx) + localctx = ANFParser.StrContext(self, localctx) self.enterOuterAlt(localctx, 5) - self.state = 10 - self.match(ANFParser.T__2) - self.state = 11 - self.aexp() - self.state = 12 - self.match(ANFParser.T__3) - self.state = 13 - self.aexp() - self.state = 14 - self.match(ANFParser.T__4) + self.state = 36 + self.match(ANFParser.STRING) pass elif la_ == 6: - localctx = ANFParser.SubContext(self, localctx) + localctx = ANFParser.AddContext(self, localctx) self.enterOuterAlt(localctx, 6) - self.state = 16 - self.match(ANFParser.T__2) - self.state = 17 + self.state = 37 + self.match(ANFParser.T__1) + self.state = 38 self.aexp() - self.state = 18 - self.match(ANFParser.T__5) - self.state = 19 + self.state = 39 + self.match(ANFParser.T__7) + self.state = 40 self.aexp() - self.state = 20 - self.match(ANFParser.T__4) + self.state = 41 + self.match(ANFParser.T__3) pass elif la_ == 7: - localctx = ANFParser.MulContext(self, localctx) + localctx = ANFParser.SubContext(self, localctx) self.enterOuterAlt(localctx, 7) - self.state = 22 - self.match(ANFParser.T__2) - self.state = 23 + self.state = 43 + self.match(ANFParser.T__1) + self.state = 44 self.aexp() - self.state = 24 - self.match(ANFParser.T__6) - self.state = 25 + self.state = 45 + self.match(ANFParser.T__8) + self.state = 46 self.aexp() - self.state = 26 - self.match(ANFParser.T__4) + self.state = 47 + self.match(ANFParser.T__3) pass elif la_ == 8: - localctx = ANFParser.DivContext(self, localctx) + localctx = ANFParser.MulContext(self, localctx) self.enterOuterAlt(localctx, 8) - self.state = 28 - self.match(ANFParser.T__2) - self.state = 29 + self.state = 49 + self.match(ANFParser.T__1) + self.state = 50 self.aexp() - self.state = 30 - self.match(ANFParser.T__7) - self.state = 31 + self.state = 51 + self.match(ANFParser.T__9) + self.state = 52 self.aexp() - self.state = 32 - self.match(ANFParser.T__4) + self.state = 53 + self.match(ANFParser.T__3) pass elif la_ == 9: - localctx = ANFParser.GtContext(self, localctx) + localctx = ANFParser.DivContext(self, localctx) self.enterOuterAlt(localctx, 9) - self.state = 34 - self.match(ANFParser.T__2) - self.state = 35 + self.state = 55 + self.match(ANFParser.T__1) + self.state = 56 self.aexp() - self.state = 36 - self.match(ANFParser.T__8) - self.state = 37 + self.state = 57 + self.match(ANFParser.T__10) + self.state = 58 self.aexp() - self.state = 38 - self.match(ANFParser.T__4) + self.state = 59 + self.match(ANFParser.T__3) pass elif la_ == 10: - localctx = ANFParser.LtContext(self, localctx) + localctx = ANFParser.GtContext(self, localctx) self.enterOuterAlt(localctx, 10) - self.state = 40 - self.match(ANFParser.T__2) - self.state = 41 + self.state = 61 + self.match(ANFParser.T__1) + self.state = 62 self.aexp() - self.state = 42 - self.match(ANFParser.T__9) - self.state = 43 + self.state = 63 + self.match(ANFParser.T__11) + self.state = 64 self.aexp() - self.state = 44 - self.match(ANFParser.T__4) + self.state = 65 + self.match(ANFParser.T__3) pass elif la_ == 11: - localctx = ANFParser.EqContext(self, localctx) + localctx = ANFParser.LtContext(self, localctx) self.enterOuterAlt(localctx, 11) - self.state = 46 - self.match(ANFParser.T__2) - self.state = 47 + self.state = 67 + self.match(ANFParser.T__1) + self.state = 68 self.aexp() - self.state = 48 - self.match(ANFParser.T__10) - self.state = 49 + self.state = 69 + self.match(ANFParser.T__12) + self.state = 70 self.aexp() - self.state = 50 - self.match(ANFParser.T__4) + self.state = 71 + self.match(ANFParser.T__3) pass elif la_ == 12: - localctx = ANFParser.BslContext(self, localctx) + localctx = ANFParser.EqContext(self, localctx) self.enterOuterAlt(localctx, 12) - self.state = 52 - self.match(ANFParser.T__2) - self.state = 53 + self.state = 73 + self.match(ANFParser.T__1) + self.state = 74 self.aexp() - self.state = 54 - self.match(ANFParser.T__11) - self.state = 55 + self.state = 75 + self.match(ANFParser.T__13) + self.state = 76 self.aexp() - self.state = 56 - self.match(ANFParser.T__4) + self.state = 77 + self.match(ANFParser.T__3) pass elif la_ == 13: - localctx = ANFParser.BsrContext(self, localctx) + localctx = ANFParser.BslContext(self, localctx) self.enterOuterAlt(localctx, 13) - self.state = 58 - self.match(ANFParser.T__2) - self.state = 59 + self.state = 79 + self.match(ANFParser.T__1) + self.state = 80 self.aexp() - self.state = 60 - self.match(ANFParser.T__12) - self.state = 61 + self.state = 81 + self.match(ANFParser.T__14) + self.state = 82 self.aexp() - self.state = 62 - self.match(ANFParser.T__4) + self.state = 83 + self.match(ANFParser.T__3) pass elif la_ == 14: - localctx = ANFParser.AndContext(self, localctx) + localctx = ANFParser.BsrContext(self, localctx) self.enterOuterAlt(localctx, 14) - self.state = 64 - self.match(ANFParser.T__2) - self.state = 65 + self.state = 85 + self.match(ANFParser.T__1) + self.state = 86 self.aexp() - self.state = 66 - self.match(ANFParser.T__13) - self.state = 67 + self.state = 87 + self.match(ANFParser.T__15) + self.state = 88 self.aexp() - self.state = 68 - self.match(ANFParser.T__4) + self.state = 89 + self.match(ANFParser.T__3) pass elif la_ == 15: - localctx = ANFParser.OrContext(self, localctx) + localctx = ANFParser.AndContext(self, localctx) self.enterOuterAlt(localctx, 15) - self.state = 70 - self.match(ANFParser.T__2) - self.state = 71 + self.state = 91 + self.match(ANFParser.T__1) + self.state = 92 self.aexp() - self.state = 72 - self.match(ANFParser.T__14) - self.state = 73 + self.state = 93 + self.match(ANFParser.T__16) + self.state = 94 self.aexp() - self.state = 74 - self.match(ANFParser.T__4) + self.state = 95 + self.match(ANFParser.T__3) pass elif la_ == 16: - localctx = ANFParser.XorContext(self, localctx) + localctx = ANFParser.OrContext(self, localctx) self.enterOuterAlt(localctx, 16) - self.state = 76 - self.match(ANFParser.T__2) - self.state = 77 + self.state = 97 + self.match(ANFParser.T__1) + self.state = 98 self.aexp() - self.state = 78 - self.match(ANFParser.T__15) - self.state = 79 + self.state = 99 + self.match(ANFParser.T__17) + self.state = 100 self.aexp() - self.state = 80 - self.match(ANFParser.T__4) + self.state = 101 + self.match(ANFParser.T__3) pass elif la_ == 17: - localctx = ANFParser.LamContext(self, localctx) + localctx = ANFParser.XorContext(self, localctx) self.enterOuterAlt(localctx, 17) - self.state = 82 - self.match(ANFParser.T__2) - self.state = 83 + self.state = 103 + self.match(ANFParser.T__1) + self.state = 104 + self.aexp() + self.state = 105 + self.match(ANFParser.T__18) + self.state = 106 + self.aexp() + self.state = 107 + self.match(ANFParser.T__3) + pass + + elif la_ == 18: + localctx = ANFParser.LamContext(self, localctx) + self.enterOuterAlt(localctx, 18) + self.state = 109 + self.match(ANFParser.T__1) + self.state = 110 self.match(ANFParser.IDENT) - self.state = 88 + self.state = 115 self._errHandler.sync(self) _la = self._input.LA(1) - while _la==17: - self.state = 84 - self.match(ANFParser.T__16) - self.state = 85 + while _la==3: + self.state = 111 + self.match(ANFParser.T__2) + self.state = 112 self.match(ANFParser.IDENT) - self.state = 90 + self.state = 117 self._errHandler.sync(self) _la = self._input.LA(1) - self.state = 91 - self.match(ANFParser.T__17) - self.state = 92 - self.cexp() - self.state = 93 + self.state = 118 self.match(ANFParser.T__4) + self.state = 119 + self.cexp() + self.state = 120 + self.match(ANFParser.T__3) pass @@ -929,41 +1121,41 @@ class ANFParser ( Parser ): def funcall(self): localctx = ANFParser.FuncallContext(self, self._ctx, self.state) - self.enterRule(localctx, 2, self.RULE_funcall) + self.enterRule(localctx, 6, self.RULE_funcall) self._la = 0 # Token type try: - self.state = 110 + self.state = 137 self._errHandler.sync(self) - la_ = self._interp.adaptivePredict(self._input,3,self._ctx) + la_ = self._interp.adaptivePredict(self._input,6,self._ctx) if la_ == 1: localctx = ANFParser.CallContext(self, localctx) self.enterOuterAlt(localctx, 1) - self.state = 97 + self.state = 124 self.match(ANFParser.IDENT) - self.state = 98 - self.match(ANFParser.T__2) - self.state = 99 + self.state = 125 + self.match(ANFParser.T__1) + self.state = 126 self.aexp() - self.state = 104 + self.state = 131 self._errHandler.sync(self) _la = self._input.LA(1) - while _la==17: - self.state = 100 - self.match(ANFParser.T__16) - self.state = 101 + while _la==3: + self.state = 127 + self.match(ANFParser.T__2) + self.state = 128 self.aexp() - self.state = 106 + self.state = 133 self._errHandler.sync(self) _la = self._input.LA(1) - self.state = 107 - self.match(ANFParser.T__4) + self.state = 134 + self.match(ANFParser.T__3) pass elif la_ == 2: localctx = ANFParser.AtomContext(self, localctx) self.enterOuterAlt(localctx, 2) - self.state = 109 + self.state = 136 self.aexp() pass @@ -1084,47 +1276,47 @@ class ANFParser ( Parser ): def cexp(self): localctx = ANFParser.CexpContext(self, self._ctx, self.state) - self.enterRule(localctx, 4, self.RULE_cexp) + self.enterRule(localctx, 8, self.RULE_cexp) try: - self.state = 127 + self.state = 154 self._errHandler.sync(self) token = self._input.LA(1) - if token in [19]: + if token in [20]: localctx = ANFParser.LetContext(self, localctx) self.enterOuterAlt(localctx, 1) - self.state = 112 - self.match(ANFParser.T__18) - self.state = 113 - self.match(ANFParser.IDENT) - self.state = 114 + self.state = 139 self.match(ANFParser.T__19) - self.state = 115 - self.funcall() - self.state = 116 + self.state = 140 + self.match(ANFParser.IDENT) + self.state = 141 self.match(ANFParser.T__20) - self.state = 117 + self.state = 142 + self.funcall() + self.state = 143 + self.match(ANFParser.T__21) + self.state = 144 self.cexp() pass - elif token in [22]: + elif token in [23]: localctx = ANFParser.IfContext(self, localctx) self.enterOuterAlt(localctx, 2) - self.state = 119 - self.match(ANFParser.T__21) - self.state = 120 - self.aexp() - self.state = 121 + self.state = 146 self.match(ANFParser.T__22) - self.state = 122 - self.cexp() - self.state = 123 + self.state = 147 + self.aexp() + self.state = 148 self.match(ANFParser.T__23) - self.state = 124 + self.state = 149 + self.cexp() + self.state = 150 + self.match(ANFParser.T__24) + self.state = 151 self.cexp() pass - elif token in [1, 2, 3, 25, 26]: + elif token in [2, 6, 7, 26, 27, 28]: localctx = ANFParser.FcContext(self, localctx) self.enterOuterAlt(localctx, 3) - self.state = 126 + self.state = 153 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#prog. + def visitProg(self, ctx:ANFParser.ProgContext): + return self.visitChildren(ctx) + + + # Visit a parse tree produced by ANFParser#def. + def visitDef(self, ctx:ANFParser.DefContext): + return self.visitChildren(ctx) + + # Visit a parse tree produced by ANFParser#true. def visitTrue(self, ctx:ANFParser.TrueContext): return self.visitChildren(ctx) @@ -29,6 +39,11 @@ class ANFVisitor(ParseTreeVisitor): return self.visitChildren(ctx) + # Visit a parse tree produced by ANFParser#str. + def visitStr(self, ctx:ANFParser.StrContext): + return self.visitChildren(ctx) + + # Visit a parse tree produced by ANFParser#add. def visitAdd(self, ctx:ANFParser.AddContext): return self.visitChildren(ctx) diff --git a/grammar/ANF.g4 b/grammar/ANF.g4 @@ -1,5 +1,9 @@ grammar ANF; +prog: def+; + +def: 'def' IDENT '('(IDENT (',' IDENT)*)? ')' ':' cexp; + aexp : 'true' #true | 'false' # false @@ -31,6 +35,7 @@ cexp | funcall #fc ; + IDENT: Letter (Letter | Digit)*; NUMBER: Digit+; STRING: '"' ([^"]|'\\'.)* '"';