From 9c70666d776e10fb51b6db22fefa65d13e6c9245 Mon Sep 17 00:00:00 2001 From: hayesall Date: Thu, 5 Aug 2021 14:24:29 -0400 Subject: [PATCH 1/2] =?UTF-8?q?=E2=9C=85=20Add=20test=20cases=20for=20regr?= =?UTF-8?q?ession=20task?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- examples/neg/{neg1.txt => neg01.txt} | 0 examples/neg/{neg2.txt => neg02.txt} | 0 examples/neg/{neg3.txt => neg03.txt} | 0 examples/neg/{neg4.txt => neg04.txt} | 0 examples/neg/{neg5.txt => neg05.txt} | 0 examples/neg/{neg6.txt => neg06.txt} | 0 examples/neg/{neg7.txt => neg07.txt} | 0 examples/neg/neg08.txt | 1 + examples/neg/neg09.txt | 3 +++ examples/neg/neg10.txt | 3 +++ examples/pos/{pos1.txt => pos01.txt} | 0 examples/pos/{pos2.txt => pos02.txt} | 0 examples/pos/{pos3.txt => pos03.txt} | 0 examples/pos/pos04.txt | 10 ++++++++++ 14 files changed, 17 insertions(+) rename examples/neg/{neg1.txt => neg01.txt} (100%) rename examples/neg/{neg2.txt => neg02.txt} (100%) rename examples/neg/{neg3.txt => neg03.txt} (100%) rename examples/neg/{neg4.txt => neg04.txt} (100%) rename examples/neg/{neg5.txt => neg05.txt} (100%) rename examples/neg/{neg6.txt => neg06.txt} (100%) rename examples/neg/{neg7.txt => neg07.txt} (100%) create mode 100644 examples/neg/neg08.txt create mode 100644 examples/neg/neg09.txt create mode 100644 examples/neg/neg10.txt rename examples/pos/{pos1.txt => pos01.txt} (100%) rename examples/pos/{pos2.txt => pos02.txt} (100%) rename examples/pos/{pos3.txt => pos03.txt} (100%) create mode 100644 examples/pos/pos04.txt diff --git a/examples/neg/neg1.txt b/examples/neg/neg01.txt similarity index 100% rename from examples/neg/neg1.txt rename to examples/neg/neg01.txt diff --git a/examples/neg/neg2.txt b/examples/neg/neg02.txt similarity index 100% rename from examples/neg/neg2.txt rename to examples/neg/neg02.txt diff --git a/examples/neg/neg3.txt b/examples/neg/neg03.txt similarity index 100% rename from examples/neg/neg3.txt rename to examples/neg/neg03.txt diff --git a/examples/neg/neg4.txt b/examples/neg/neg04.txt similarity index 100% rename from examples/neg/neg4.txt rename to examples/neg/neg04.txt diff --git a/examples/neg/neg5.txt b/examples/neg/neg05.txt similarity index 100% rename from examples/neg/neg5.txt rename to examples/neg/neg05.txt diff --git a/examples/neg/neg6.txt b/examples/neg/neg06.txt similarity index 100% rename from examples/neg/neg6.txt rename to examples/neg/neg06.txt diff --git a/examples/neg/neg7.txt b/examples/neg/neg07.txt similarity index 100% rename from examples/neg/neg7.txt rename to examples/neg/neg07.txt diff --git a/examples/neg/neg08.txt b/examples/neg/neg08.txt new file mode 100644 index 0000000..4a6565c --- /dev/null +++ b/examples/neg/neg08.txt @@ -0,0 +1 @@ +medv(id248,20.5). diff --git a/examples/neg/neg09.txt b/examples/neg/neg09.txt new file mode 100644 index 0000000..23233a0 --- /dev/null +++ b/examples/neg/neg09.txt @@ -0,0 +1,3 @@ +regressionExample(medv(id159),24.3). +regressionExample(medv(id56),35.4). +medv(id36,5). diff --git a/examples/neg/neg10.txt b/examples/neg/neg10.txt new file mode 100644 index 0000000..1b9fb9b --- /dev/null +++ b/examples/neg/neg10.txt @@ -0,0 +1,3 @@ +medv(id36,5). +regressionExample(medv(id159),24.3). +regressionExample(medv(id56),35.4). diff --git a/examples/pos/pos1.txt b/examples/pos/pos01.txt similarity index 100% rename from examples/pos/pos1.txt rename to examples/pos/pos01.txt diff --git a/examples/pos/pos2.txt b/examples/pos/pos02.txt similarity index 100% rename from examples/pos/pos2.txt rename to examples/pos/pos02.txt diff --git a/examples/pos/pos3.txt b/examples/pos/pos03.txt similarity index 100% rename from examples/pos/pos3.txt rename to examples/pos/pos03.txt diff --git a/examples/pos/pos04.txt b/examples/pos/pos04.txt new file mode 100644 index 0000000..ac4f193 --- /dev/null +++ b/examples/pos/pos04.txt @@ -0,0 +1,10 @@ +regressionExample(medv(id139),13.3). +regressionExample(medv(id433),16.1). +regressionExample(medv(id95),20.6). +regressionExample(medv(id336),21.1). +regressionExample(medv(id23),15.2). +regressionExample(medv(id438),8.7). +regressionExample(medv(id65),33). +regressionExample(medv(id248),20.5). +regressionExample(medv(id159),24.3). +regressionExample(medv(id56),35.4). From c6395b34ac99bc6545c75960b41180cc1fe807a9 Mon Sep 17 00:00:00 2001 From: hayesall Date: Thu, 5 Aug 2021 14:27:05 -0400 Subject: [PATCH 2/2] =?UTF-8?q?=E2=9C=A8=20Add=20parser=20support=20for=20?= =?UTF-8?q?regression/classification?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cmd/ILPLang.g4 | 11 +- cmd/parser/ILPLang.interp | 11 +- cmd/parser/ILPLang.tokens | 24 +- cmd/parser/ILPLangLexer.interp | 11 +- cmd/parser/ILPLangLexer.tokens | 24 +- cmd/parser/ilplang_base_listener.go | 18 + cmd/parser/ilplang_lexer.go | 77 ++-- cmd/parser/ilplang_listener.go | 18 + cmd/parser/ilplang_parser.go | 555 +++++++++++++++++++++++++--- 9 files changed, 645 insertions(+), 104 deletions(-) diff --git a/cmd/ILPLang.g4 b/cmd/ILPLang.g4 index f056135..20bedd2 100644 --- a/cmd/ILPLang.g4 +++ b/cmd/ILPLang.g4 @@ -48,13 +48,20 @@ fragment ALPHANUMERIC | '_' ; +FLOAT: (DIGIT)* PERIOD (DIGIT)+ ; +INTEGER: (DIGIT)+ ; + start - : (term)* EOF + : (classification_task | regression_task) EOF ; +classification_task: (term)* ; +regression_task: (regression_term)* ; + // This recognizes both relations and entities. // The grammar would be more generally useful if this recognized entities and // relations on those entities. OBJECT: (ALPHANUMERIC)+; -term: OBJECT LPAREN OBJECT (COMMA OBJECT)* RPAREN PERIOD NEWLINE; +term: OBJECT LPAREN OBJECT (COMMA (OBJECT | INTEGER))* RPAREN PERIOD NEWLINE; +regression_term: 'regressionExample' LPAREN OBJECT LPAREN OBJECT RPAREN COMMA (FLOAT | INTEGER) RPAREN PERIOD NEWLINE; diff --git a/cmd/parser/ILPLang.interp b/cmd/parser/ILPLang.interp index 09c8be8..221f6c7 100644 --- a/cmd/parser/ILPLang.interp +++ b/cmd/parser/ILPLang.interp @@ -1,25 +1,34 @@ token literal names: null +'regressionExample' '(' ')' ',' '.' null null +null +null token symbolic names: null +null LPAREN RPAREN COMMA PERIOD NEWLINE +FLOAT +INTEGER OBJECT rule names: start +classification_task +regression_task term +regression_term atn: -[3, 24715, 42794, 33075, 47597, 16764, 15335, 30598, 22884, 3, 8, 29, 4, 2, 9, 2, 4, 3, 9, 3, 3, 2, 7, 2, 8, 10, 2, 12, 2, 14, 2, 11, 11, 2, 3, 2, 3, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 7, 3, 20, 10, 3, 12, 3, 14, 3, 23, 11, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 2, 4, 2, 4, 2, 2, 2, 28, 2, 9, 3, 2, 2, 2, 4, 14, 3, 2, 2, 2, 6, 8, 5, 4, 3, 2, 7, 6, 3, 2, 2, 2, 8, 11, 3, 2, 2, 2, 9, 7, 3, 2, 2, 2, 9, 10, 3, 2, 2, 2, 10, 12, 3, 2, 2, 2, 11, 9, 3, 2, 2, 2, 12, 13, 7, 2, 2, 3, 13, 3, 3, 2, 2, 2, 14, 15, 7, 8, 2, 2, 15, 16, 7, 3, 2, 2, 16, 21, 7, 8, 2, 2, 17, 18, 7, 5, 2, 2, 18, 20, 7, 8, 2, 2, 19, 17, 3, 2, 2, 2, 20, 23, 3, 2, 2, 2, 21, 19, 3, 2, 2, 2, 21, 22, 3, 2, 2, 2, 22, 24, 3, 2, 2, 2, 23, 21, 3, 2, 2, 2, 24, 25, 7, 4, 2, 2, 25, 26, 7, 6, 2, 2, 26, 27, 7, 7, 2, 2, 27, 5, 3, 2, 2, 2, 4, 9, 21] \ No newline at end of file +[3, 24715, 42794, 33075, 47597, 16764, 15335, 30598, 22884, 3,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2, 2, 37, 38, 3, 2, 2, 2, 38, 40, 3, 2, 2, 2, 39, 37, 3, 2, 2, 2, 40, 41, 7, 5, 2, 2, 41, 42, 7, 7, 2, 2, 42, 43, 7, 8, 2, 2, 43, 9, 3, 2, 2, 2, 44, 45, 7, 3, 2, 2, 45, 46, 7, 4, 2, 2, 46, 47, 7, 11, 2, 2, 47, 48, 7, 4, 2, 2, 48, 49, 7, 11, 2, 2, 49, 50, 7, 5, 2, 2, 50, 51, 7, 6, 2, 2, 51, 52, 9, 3, 2, 2, 52, 53, 7, 5, 2, 2, 53, 54, 7, 7, 2, 2, 54, 55, 7, 8, 2, 2, 55, 11, 3, 2, 2, 2, 6, 14, 21, 27, 37] \ No newline at end of file diff --git a/cmd/parser/ILPLang.tokens b/cmd/parser/ILPLang.tokens index c5cf234..daef71f 100644 --- a/cmd/parser/ILPLang.tokens +++ b/cmd/parser/ILPLang.tokens @@ -1,10 +1,14 @@ -LPAREN=1 -RPAREN=2 -COMMA=3 -PERIOD=4 -NEWLINE=5 -OBJECT=6 -'('=1 -')'=2 -','=3 -'.'=4 +T__0=1 +LPAREN=2 +RPAREN=3 +COMMA=4 +PERIOD=5 +NEWLINE=6 +FLOAT=7 +INTEGER=8 +OBJECT=9 +'regressionExample'=1 +'('=2 +')'=3 +','=4 +'.'=5 diff --git a/cmd/parser/ILPLangLexer.interp b/cmd/parser/ILPLangLexer.interp index ee09c99..5219c30 100644 --- a/cmd/parser/ILPLangLexer.interp +++ b/cmd/parser/ILPLangLexer.interp @@ -1,22 +1,29 @@ token literal names: null +'regressionExample' '(' ')' ',' '.' null null +null +null token symbolic names: null +null LPAREN RPAREN COMMA PERIOD NEWLINE +FLOAT +INTEGER OBJECT rule names: +T__0 LPAREN RPAREN COMMA @@ -25,6 +32,8 @@ NEWLINE DIGIT SMALL_LETTER ALPHANUMERIC +FLOAT +INTEGER OBJECT channel names: @@ -35,4 +44,4 @@ mode names: DEFAULT_MODE atn: -[3, 24715, 42794, 33075, 47597, 16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, 2, 2, 2, 39, 18, 3, 2, 2, 2, 40, 42, 5, 17, 9, 2, 41, 40, 3, 2, 2, 2, 42, 43, 3, 2, 2, 2, 43, 41, 3, 2, 2, 2, 43, 44, 3, 2, 2, 2, 44, 20, 3, 2, 2, 2, 5, 2, 38, 43, 2] \ No newline at end of file +[3, 24715, 42794, 33075, 47597, 16764, 15335, 30598, 22884, 2, 11, 86, 8, 1, 4, 2, 9, 2, 4, 3, 9, 3, 4, 4, 9, 4, 4, 5, 9, 5, 4, 6, 9, 6, 4, 7, 9, 7, 4, 8, 9, 8, 4, 9, 9, 9, 4, 10, 9, 10, 4, 11, 9, 11, 4, 12, 9, 12, 4, 13, 9, 13, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 3, 3, 3, 3, 4, 3, 4, 3, 5, 3, 5, 3, 6, 3, 6, 3, 7, 3, 7, 3, 8, 3, 8, 3, 9, 3, 9, 3, 10, 3, 10, 3, 10, 5, 10, 63, 10, 10, 3, 11, 7, 11, 66, 10, 11, 12, 11, 14, 11, 69, 11, 11, 3, 11, 3, 11, 6, 11, 73, 10, 11, 13, 11, 14, 11, 74, 3, 12, 6, 12, 78, 10, 12, 13, 12, 14, 12, 79, 3, 13, 6, 13, 83, 10, 13, 13, 13, 14, 13, 84, 2, 2, 14, 3, 3, 5, 4, 7, 5, 9, 6, 11, 7, 13, 8, 15, 2, 17, 2, 19, 2, 21, 9, 23, 10, 25, 11, 3, 2, 5, 3, 2, 12, 12, 3, 2, 50, 59, 3, 2, 99, 124, 2, 88, 2, 3, 3, 2, 2, 2, 2, 5, 3, 2, 2, 2, 2, 7, 3, 2, 2, 2, 2, 9, 3, 2, 2, 2, 2, 11, 3, 2, 2, 2, 2, 13, 3, 2, 2, 2, 2, 21, 3, 2, 2, 2, 2, 23, 3, 2, 2, 2, 2, 25, 3, 2, 2, 2, 3, 27, 3, 2, 2, 2, 5, 45, 3, 2, 2, 2, 7, 47, 3, 2, 2, 2, 9, 49, 3, 2, 2, 2, 11, 51, 3, 2, 2, 2, 13, 53, 3, 2, 2, 2, 15, 55, 3, 2, 2, 2, 17, 57, 3, 2, 2, 2, 19, 62, 3, 2, 2, 2, 21, 67, 3, 2, 2, 2, 23, 77, 3, 2, 2, 2, 25, 82, 3, 2, 2, 2, 27, 28, 7, 116, 2, 2, 28, 29, 7, 103, 2, 2, 29, 30, 7, 105, 2, 2, 30, 31, 7, 116, 2, 2, 31, 32, 7, 103, 2, 2, 32, 33, 7, 117, 2, 2, 33, 34, 7, 117, 2, 2, 34, 35, 7, 107, 2, 2, 35, 36, 7, 113, 2, 2, 36, 37, 7, 112, 2, 2, 37, 38, 7, 71, 2, 2, 38, 39, 7, 122, 2, 2, 39, 40, 7, 99, 2, 2, 40, 41, 7, 111, 2, 2, 41, 42, 7, 114, 2, 2, 42, 43, 7, 110, 2, 2, 43, 44, 7, 103, 2, 2, 44, 4, 3, 2, 2, 2, 45, 46, 7, 42, 2, 2, 46, 6, 3, 2, 2, 2, 47, 48, 7, 43, 2, 2, 48, 8, 3, 2, 2, 2, 49, 50, 7, 46, 2, 2, 50, 10, 3, 2, 2, 2, 51, 52, 7, 48, 2, 2, 52, 12, 3, 2, 2, 2, 53, 54, 9, 2, 2, 2, 54, 14, 3, 2, 2, 2, 55, 56, 9, 3, 2, 2, 56, 16, 3, 2, 2, 2, 57, 58, 9, 4, 2, 2, 58, 18, 3, 2, 2, 2, 59, 63, 5, 17, 9, 2, 60, 63, 5, 15, 8, 2, 61, 63, 7, 97, 2, 2, 62, 59, 3, 2, 2, 2, 62, 60, 3, 2, 2, 2, 62, 61, 3, 2, 2, 2, 63, 20, 3, 2, 2, 2, 64, 66, 5, 15, 8, 2, 65, 64, 3, 2, 2, 2, 66, 69, 3, 2, 2, 2, 67, 65, 3, 2, 2, 2, 67, 68, 3, 2, 2, 2, 68, 70, 3, 2, 2, 2, 69, 67, 3, 2, 2, 2, 70, 72, 5, 11, 6, 2, 71, 73, 5, 15, 8, 2, 72, 71, 3, 2, 2, 2, 73, 74, 3, 2, 2, 2, 74, 72, 3, 2, 2, 2, 74, 75, 3, 2, 2, 2, 75, 22, 3, 2, 2, 2, 76, 78, 5, 15, 8, 2, 77, 76, 3, 2, 2, 2, 78, 79, 3, 2, 2, 2, 79, 77, 3, 2, 2, 2, 79, 80, 3, 2, 2, 2, 80, 24, 3, 2, 2, 2, 81, 83, 5, 19, 10, 2, 82, 81, 3, 2, 2, 2, 83, 84, 3, 2, 2, 2, 84, 82, 3, 2, 2, 2, 84, 85, 3, 2, 2, 2, 85, 26, 3, 2, 2, 2, 8, 2, 62, 67, 74, 79, 84, 2] \ No newline at end of file diff --git a/cmd/parser/ILPLangLexer.tokens b/cmd/parser/ILPLangLexer.tokens index c5cf234..daef71f 100644 --- a/cmd/parser/ILPLangLexer.tokens +++ b/cmd/parser/ILPLangLexer.tokens @@ -1,10 +1,14 @@ -LPAREN=1 -RPAREN=2 -COMMA=3 -PERIOD=4 -NEWLINE=5 -OBJECT=6 -'('=1 -')'=2 -','=3 -'.'=4 +T__0=1 +LPAREN=2 +RPAREN=3 +COMMA=4 +PERIOD=5 +NEWLINE=6 +FLOAT=7 +INTEGER=8 +OBJECT=9 +'regressionExample'=1 +'('=2 +')'=3 +','=4 +'.'=5 diff --git a/cmd/parser/ilplang_base_listener.go b/cmd/parser/ilplang_base_listener.go index 6c8803a..19228be 100644 --- a/cmd/parser/ilplang_base_listener.go +++ b/cmd/parser/ilplang_base_listener.go @@ -27,8 +27,26 @@ func (s *BaseILPLangListener) EnterStart(ctx *StartContext) {} // ExitStart is called when production start is exited. func (s *BaseILPLangListener) ExitStart(ctx *StartContext) {} +// EnterClassification_task is called when production classification_task is entered. +func (s *BaseILPLangListener) EnterClassification_task(ctx *Classification_taskContext) {} + +// ExitClassification_task is called when production classification_task is exited. +func (s *BaseILPLangListener) ExitClassification_task(ctx *Classification_taskContext) {} + +// EnterRegression_task is called when production regression_task is entered. +func (s *BaseILPLangListener) EnterRegression_task(ctx *Regression_taskContext) {} + +// ExitRegression_task is called when production regression_task is exited. +func (s *BaseILPLangListener) ExitRegression_task(ctx *Regression_taskContext) {} + // EnterTerm is called when production term is entered. func (s *BaseILPLangListener) EnterTerm(ctx *TermContext) {} // ExitTerm is called when production term is exited. func (s *BaseILPLangListener) ExitTerm(ctx *TermContext) {} + +// EnterRegression_term is called when production regression_term is entered. +func (s *BaseILPLangListener) EnterRegression_term(ctx *Regression_termContext) {} + +// ExitRegression_term is called when production regression_term is exited. +func (s *BaseILPLangListener) ExitRegression_term(ctx *Regression_termContext) {} diff --git a/cmd/parser/ilplang_lexer.go b/cmd/parser/ilplang_lexer.go index a5a866a..4bad72b 100644 --- a/cmd/parser/ilplang_lexer.go +++ b/cmd/parser/ilplang_lexer.go @@ -14,25 +14,42 @@ var _ = fmt.Printf var _ = unicode.IsLetter var serializedLexerAtn = []uint16{ - 3, 24715, 42794, 33075, 47597, 16764, 15335, 30598, 22884, 2, 8, 45, 8, + 3, 24715, 42794, 33075, 47597, 16764, 15335, 30598, 22884, 2, 11, 86, 8, 1, 4, 2, 9, 2, 4, 3, 9, 3, 4, 4, 9, 4, 4, 5, 9, 5, 4, 6, 9, 6, 4, 7, 9, - 7, 4, 8, 9, 8, 4, 9, 9, 9, 4, 10, 9, 10, 3, 2, 3, 2, 3, 3, 3, 3, 3, 4, - 3, 4, 3, 5, 3, 5, 3, 6, 3, 6, 3, 7, 3, 7, 3, 8, 3, 8, 3, 9, 3, 9, 3, 9, - 5, 9, 39, 10, 9, 3, 10, 6, 10, 42, 10, 10, 13, 10, 14, 10, 43, 2, 2, 11, - 3, 3, 5, 4, 7, 5, 9, 6, 11, 7, 13, 2, 15, 2, 17, 2, 19, 8, 3, 2, 5, 3, - 2, 12, 12, 3, 2, 50, 59, 3, 2, 99, 124, 2, 44, 2, 3, 3, 2, 2, 2, 2, 5, - 3, 2,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3, 10, 3, 10, + 3, 10, 5, 10, 63, 10, 10, 3, 11, 7, 11, 66, 10, 11, 12, 11, 14, 11, 69, + 11, 11, 3, 11, 3, 11, 6, 11, 73, 10, 11, 13, 11, 14, 11, 74, 3, 12, 6, + 12, 78, 10, 12, 13, 12, 14, 12, 79, 3, 13, 6, 13, 83, 10, 13, 13, 13, 14, + 13, 84, 2, 2, 14, 3, 3, 5, 4, 7, 5, 9, 6, 11, 7, 13, 8, 15, 2, 17, 2, 19, + 2, 21, 9, 23, 10, 25, 11, 3, 2, 5, 3, 2, 12, 12, 3, 2, 50, 59, 3, 2, 99, + 124, 2, 88, 2, 3, 3, 2, 2, 2, 2, 5, 3, 2, 2, 2, 2, 7, 3, 2, 2, 2, 2, 9, + 3, 2, 2, 2, 2, 11, 3, 2, 2, 2, 2, 13, 3, 2, 2, 2, 2, 21, 3, 2, 2, 2, 2, + 23, 3, 2, 2, 2, 2, 25, 3, 2, 2, 2, 3, 27, 3, 2, 2, 2, 5, 45, 3, 2, 2, 2, + 7, 47, 3, 2, 2, 2, 9, 49, 3, 2, 2, 2, 11, 51, 3, 2, 2, 2, 13, 53, 3, 2, + 2, 2, 15, 55, 3, 2, 2, 2, 17, 57, 3, 2, 2, 2, 19, 62, 3, 2, 2, 2, 21, 67, + 3, 2, 2, 2, 23, 77, 3, 2, 2, 2, 25, 82, 3, 2, 2, 2, 27, 28, 7, 116, 2, + 2, 28, 29, 7, 103, 2, 2, 29, 30, 7, 105, 2, 2, 30, 31, 7, 116, 2, 2, 31, + 32, 7, 103, 2, 2, 32, 33, 7, 117, 2, 2, 33, 34, 7, 117, 2, 2, 34, 35, 7, + 107, 2, 2, 35, 36, 7, 113, 2, 2, 36, 37, 7, 112, 2, 2, 37, 38, 7, 71, 2, + 2, 38, 39, 7, 122, 2, 2, 39, 40, 7, 99, 2, 2, 40, 41, 7, 111, 2, 2, 41, + 42, 7, 114, 2, 2, 42, 43, 7, 110, 2, 2, 43, 44, 7, 103, 2, 2, 44, 4, 3, + 2, 2, 2, 45, 46, 7, 42, 2, 2, 46, 6, 3, 2, 2, 2, 47, 48, 7, 43, 2, 2, 48, + 8, 3, 2, 2, 2, 49, 50, 7, 46, 2, 2, 50, 10, 3, 2, 2, 2, 51, 52, 7, 48, + 2, 2, 52, 12, 3, 2, 2, 2, 53, 54, 9, 2, 2, 2, 54, 14, 3, 2, 2, 2, 55, 56, + 9, 3, 2, 2, 56, 16, 3, 2, 2, 2, 57, 58, 9, 4, 2, 2, 58, 18, 3, 2, 2, 2, + 59, 63, 5, 17, 9, 2, 60, 63, 5, 15, 8, 2, 61, 63, 7, 97, 2, 2, 62, 59, + 3, 2, 2, 2, 62, 60, 3, 2, 2, 2, 62, 61, 3, 2, 2, 2, 63, 20, 3, 2, 2, 2, + 64, 66, 5, 15, 8, 2, 65, 64, 3, 2, 2, 2, 66, 69, 3, 2, 2, 2, 67, 65, 3, + 2, 2, 2, 67, 68, 3, 2, 2, 2, 68, 70, 3, 2, 2, 2, 69, 67, 3, 2, 2, 2, 70, + 72, 5, 11, 6, 2, 71, 73, 5, 15, 8, 2, 72, 71, 3, 2, 2, 2, 73, 74, 3, 2, + 2, 2, 74, 72, 3, 2, 2, 2, 74, 75, 3, 2, 2, 2, 75, 22, 3, 2, 2, 2, 76, 78, + 5, 15, 8, 2, 77, 76, 3, 2, 2, 2, 78, 79, 3, 2, 2, 2, 79, 77, 3, 2, 2, 2, + 79, 80, 3, 2, 2, 2, 80, 24, 3, 2, 2, 2, 81, 83, 5, 19, 10, 2, 82, 81, 3, + 2, 2, 2, 83, 84, 3, 2, 2, 2, 84, 82, 3, 2, 2, 2, 84, 85, 3, 2, 2, 2, 85, + 26, 3, 2, 2, 2, 8, 2, 62, 67, 74, 79, 84, 2, } var lexerDeserializer = antlr.NewATNDeserializer(nil) @@ -47,16 +64,17 @@ var lexerModeNames = []string{ } var lexerLiteralNames = []string{ - "", "'('", "')'", "','", "'.'", + "", "'regressionExample'", "'('", "')'", "','", "'.'", } var lexerSymbolicNames = []string{ - "", "LPAREN", "RPAREN", "COMMA", "PERIOD", "NEWLINE", "OBJECT", + "", "", "LPAREN", "RPAREN", "COMMA", "PERIOD", "NEWLINE", "FLOAT", "INTEGER", + "OBJECT", } var lexerRuleNames = []string{ - "LPAREN", "RPAREN", "COMMA", "PERIOD", "NEWLINE", "DIGIT", "SMALL_LETTER", - "ALPHANUMERIC", "OBJECT", + "T__0", "LPAREN", "RPAREN", "COMMA", "PERIOD", "NEWLINE", "DIGIT", "SMALL_LETTER", + "ALPHANUMERIC", "FLOAT", "INTEGER", "OBJECT", } type ILPLangLexer struct { @@ -94,10 +112,13 @@ func NewILPLangLexer(input antlr.CharStream) *ILPLangLexer { // ILPLangLexer tokens. const ( - ILPLangLexerLPAREN = 1 - ILPLangLexerRPAREN = 2 - ILPLangLexerCOMMA = 3 - ILPLangLexerPERIOD = 4 - ILPLangLexerNEWLINE = 5 - ILPLangLexerOBJECT = 6 + ILPLangLexerT__0 = 1 + ILPLangLexerLPAREN = 2 + ILPLangLexerRPAREN = 3 + ILPLangLexerCOMMA = 4 + ILPLangLexerPERIOD = 5 + ILPLangLexerNEWLINE = 6 + ILPLangLexerFLOAT = 7 + ILPLangLexerINTEGER = 8 + ILPLangLexerOBJECT = 9 ) diff --git a/cmd/parser/ilplang_listener.go b/cmd/parser/ilplang_listener.go index 21eea3c..2204d35 100644 --- a/cmd/parser/ilplang_listener.go +++ b/cmd/parser/ilplang_listener.go @@ -11,12 +11,30 @@ type ILPLangListener interface { // EnterStart is called when entering the start production. EnterStart(c *StartContext) + // EnterClassification_task is called when entering the classification_task production. + EnterClassification_task(c *Classification_taskContext) + + // EnterRegression_task is called when entering the regression_task production. + EnterRegression_task(c *Regression_taskContext) + // EnterTerm is called when entering the term production. EnterTerm(c *TermContext) + // EnterRegression_term is called when entering the regression_term production. + EnterRegression_term(c *Regression_termContext) + // ExitStart is called when exiting the start production. ExitStart(c *StartContext) + // ExitClassification_task is called when exiting the classification_task production. + ExitClassification_task(c *Classification_taskContext) + + // ExitRegression_task is called when exiting the regression_task production. + ExitRegression_task(c *Regression_taskContext) + // ExitTerm is called when exiting the term production. ExitTerm(c *TermContext) + + // ExitRegression_term is called when exiting the regression_term production. + ExitRegression_term(c *Regression_termContext) } diff --git a/cmd/parser/ilplang_parser.go b/cmd/parser/ilplang_parser.go index 8f5b1af..8f5a7ea 100644 --- a/cmd/parser/ilplang_parser.go +++ b/cmd/parser/ilplang_parser.go @@ -16,31 +16,42 @@ var _ = reflect.Copy var _ = strconv.Itoa var parserATN = []uint16{ - 3, 24715, 42794, 33075, 47597, 16764, 15335, 30598, 22884, 3, 8, 29, 4, - 2, 9, 2, 4, 3, 9, 3, 3, 2, 7, 2, 8, 10, 2, 12, 2, 14, 2, 11, 11, 2, 3, - 2, 3, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 7, 3, 20, 10, 3, 12, 3, 14, 3, 23, - 11, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 2, 4, 2, 4, 2, 2, 2, 28, 2, 9, - 3, 2, 2, 2, 4, 14, 3, 2, 2, 2, 6, 8, 5, 4, 3, 2, 7, 6, 3, 2, 2, 2, 8, 11, - 3, 2, 2, 2, 9, 7, 3, 2, 2, 2, 9, 10, 3, 2, 2, 2, 10, 12, 3, 2, 2, 2, 11, - 9, 3, 2, 2, 2, 12, 13, 7, 2, 2, 3, 13, 3, 3, 2, 2, 2, 14, 15, 7, 8, 2, - 2, 15, 16, 7, 3, 2, 2, 16, 21, 7, 8, 2, 2, 17, 18, 7, 5, 2, 2, 18, 20, - 7, 8, 2, 2, 19, 17, 3, 2, 2, 2, 20, 23, 3, 2, 2, 2, 21, 19, 3, 2, 2, 2, - 21, 22, 3, 2, 2, 2, 22, 24, 3, 2, 2, 2, 23, 21, 3, 2, 2, 2, 24, 25, 7, - 4, 2, 2, 25, 26, 7, 6, 2, 2, 26, 27, 7, 7, 2, 2, 27, 5, 3, 2, 2, 2, 4, - 9, 21, + 3, 24715, 42794, 33075, 47597, 16764, 15335, 30598, 22884, 3, 11, 57, 4, + 2, 9, 2, 4, 3, 9, 3, 4, 4, 9, 4, 4, 5, 9, 5, 4, 6, 9, 6, 3, 2, 3, 2, 5, + 2, 15, 10, 2, 3, 2, 3, 2, 3, 3, 7, 3, 20, 10, 3, 12, 3, 14, 3, 23, 11, + 3, 3, 4, 7, 4, 26, 10, 4, 12, 4, 14, 4, 29, 11, 4, 3, 5, 3, 5, 3, 5, 3, + 5, 3, 5, 7, 5, 36, 10, 5, 12, 5, 14, 5, 39, 11, 5, 3, 5, 3, 5, 3, 5, 3, + 5, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, + 6, 3, 6, 2, 2, 7, 2, 4, 6, 8, 10, 2, 4, 3, 2, 10, 11, 3, 2, 9, 10, 2, 55, + 2, 14, 3, 2, 2, 2, 4, 21, 3, 2, 2, 2, 6, 27, 3, 2, 2, 2, 8, 30, 3, 2, 2, + 2, 10, 44, 3, 2, 2, 2, 12, 15, 5, 4, 3, 2, 13, 15, 5, 6, 4, 2, 14, 12, + 3, 2, 2, 2, 14, 13, 3, 2, 2, 2, 15, 16, 3, 2, 2, 2, 16, 17, 7, 2, 2, 3, + 17, 3, 3, 2, 2, 2, 18, 20, 5, 8, 5, 2, 19, 18, 3, 2, 2, 2, 20, 23, 3, 2, + 2, 2, 21, 19, 3, 2, 2, 2, 21, 22, 3, 2, 2, 2, 22, 5, 3, 2, 2, 2, 23, 21, + 3, 2, 2, 2, 24, 26, 5, 10, 6, 2, 25, 24, 3, 2, 2, 2, 26, 29, 3, 2, 2, 2, + 27, 25, 3, 2, 2, 2, 27, 28, 3, 2, 2, 2, 28, 7, 3, 2, 2, 2, 29, 27, 3, 2, + 2, 2, 30, 31, 7, 11, 2, 2, 31, 32, 7, 4, 2, 2, 32, 37, 7, 11, 2, 2, 33, + 34, 7, 6, 2, 2, 34, 36, 9, 2, 2, 2, 35, 33, 3, 2, 2, 2, 36, 39, 3, 2, 2, + 2, 37, 35, 3, 2, 2, 2, 37, 38, 3, 2, 2, 2, 38, 40, 3, 2, 2, 2, 39, 37, + 3, 2, 2, 2, 40, 41, 7, 5, 2, 2, 41, 42, 7, 7, 2, 2, 42, 43, 7, 8, 2, 2, + 43, 9, 3, 2, 2, 2, 44, 45, 7, 3, 2, 2, 45, 46, 7, 4, 2, 2, 46, 47, 7, 11, + 2, 2, 47, 48, 7, 4, 2, 2, 48, 49, 7, 11, 2, 2, 49, 50, 7, 5, 2, 2, 50, + 51, 7, 6, 2, 2, 51, 52, 9, 3, 2, 2, 52, 53, 7, 5, 2, 2, 53, 54, 7, 7, 2, + 2, 54, 55, 7, 8, 2, 2, 55, 11, 3, 2, 2, 2, 6, 14, 21, 27, 37, } var deserializer = antlr.NewATNDeserializer(nil) var deserializedATN = deserializer.DeserializeFromUInt16(parserATN) var literalNames = []string{ - "", "'('", "')'", "','", "'.'", + "", "'regressionExample'", "'('", "')'", "','", "'.'", } var symbolicNames = []string{ - "", "LPAREN", "RPAREN", "COMMA", "PERIOD", "NEWLINE", "OBJECT", + "", "", "LPAREN", "RPAREN", "COMMA", "PERIOD", "NEWLINE", "FLOAT", "INTEGER", + "OBJECT", } var ruleNames = []string{ - "start", "term", + "start", "classification_task", "regression_task", "term", "regression_term", } var decisionToDFA = make([]*antlr.DFA, len(deserializedATN.DecisionToState)) @@ -71,18 +82,24 @@ func NewILPLangParser(input antlr.TokenStream) *ILPLangParser { // ILPLangParser tokens. const ( ILPLangParserEOF = antlr.TokenEOF - ILPLangParserLPAREN = 1 - ILPLangParserRPAREN = 2 - ILPLangParserCOMMA = 3 - ILPLangParserPERIOD = 4 - ILPLangParserNEWLINE = 5 - ILPLangParserOBJECT = 6 + ILPLangParserT__0 = 1 + ILPLangParserLPAREN = 2 + ILPLangParserRPAREN = 3 + ILPLangParserCOMMA = 4 + ILPLangParserPERIOD = 5 + ILPLangParserNEWLINE = 6 + ILPLangParserFLOAT = 7 + ILPLangParserINTEGER = 8 + ILPLangParserOBJECT = 9 ) // ILPLangParser rules. const ( - ILPLangParserRULE_start = 0 - ILPLangParserRULE_term = 1 + ILPLangParserRULE_start = 0 + ILPLangParserRULE_classification_task = 1 + ILPLangParserRULE_regression_task = 2 + ILPLangParserRULE_term = 3 + ILPLangParserRULE_regression_term = 4 ) // IStartContext is an interface to support dynamic dispatch. @@ -127,27 +144,24 @@ func (s *StartContext) EOF() antlr.TerminalNode { return s.GetToken(ILPLangParserEOF, 0) } -func (s *StartContext) AllTerm() []ITermContext { - var ts = s.GetTypedRuleContexts(reflect.TypeOf((*ITermContext)(nil)).Elem()) - var tst = make([]ITermContext, len(ts)) +func (s *StartContext) Classification_task() IClassification_taskContext { + var t = s.GetTypedRuleContext(reflect.TypeOf((*IClassification_taskContext)(nil)).Elem(), 0) - for i, t := range ts { - if t != nil { - tst[i] = t.(ITermContext) - } + if t == nil { + return nil } - return tst + return t.(IClassification_taskContext) } -func (s *StartContext) Term(i int) ITermContext { - var t = s.GetTypedRuleContext(reflect.TypeOf((*ITermContext)(nil)).Elem(), i) +func (s *StartContext) Regression_task() IRegression_taskContext { + var t = s.GetTypedRuleContext(reflect.TypeOf((*IRegression_taskContext)(nil)).Elem(), 0) if t == nil { return nil } - return t.(ITermContext) + return t.(IRegression_taskContext) } func (s *StartContext) GetRuleContext() antlr.RuleContext { @@ -173,6 +187,132 @@ func (s *StartContext) ExitRule(listener antlr.ParseTreeListener) { func (p *ILPLangParser) Start() (localctx IStartContext) { localctx = NewStartContext(p, p.GetParserRuleContext(), p.GetState()) p.EnterRule(localctx, 0, ILPLangParserRULE_start) + + defer func() { + p.ExitRule() + }() + + defer func() { + if err := recover(); err != nil { + if v, ok := err.(antlr.RecognitionException); ok { + localctx.SetException(v) + p.GetErrorHandler().ReportError(p, v) + p.GetErrorHandler().Recover(p, v) + } else { + panic(err) + } + } + }() + + p.EnterOuterAlt(localctx, 1) + p.SetState(12) + p.GetErrorHandler().Sync(p) + switch p.GetInterpreter().AdaptivePredict(p.GetTokenStream(), 0, p.GetParserRuleContext()) { + case 1: + { + p.SetState(10) + p.Classification_task() + } + + case 2: + { + p.SetState(11) + p.Regression_task() + } + + } + { + p.SetState(14) + p.Match(ILPLangParserEOF) + } + + return localctx +} + +// IClassification_taskContext is an interface to support dynamic dispatch. +type IClassification_taskContext interface { + antlr.ParserRuleContext + + // GetParser returns the parser. + GetParser() antlr.Parser + + // IsClassification_taskContext differentiates from other interfaces. + IsClassification_taskContext() +} + +type Classification_taskContext struct { + *antlr.BaseParserRuleContext + parser antlr.Parser +} + +func NewEmptyClassification_taskContext() *Classification_taskContext { + var p = new(Classification_taskContext) + p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1) + p.RuleIndex = ILPLangParserRULE_classification_task + return p +} + +func (*Classification_taskContext) IsClassification_taskContext() {} + +func NewClassification_taskContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *Classification_taskContext { + var p = new(Classification_taskContext) + + p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState) + + p.parser = parser + p.RuleIndex = ILPLangParserRULE_classification_task + + return p +} + +func (s *Classification_taskContext) GetParser() antlr.Parser { return s.parser } + +func (s *Classification_taskContext) AllTerm() []ITermContext { + var ts = s.GetTypedRuleContexts(reflect.TypeOf((*ITermContext)(nil)).Elem()) + var tst = make([]ITermContext, len(ts)) + + for i, t := range ts { + if t != nil { + tst[i] = t.(ITermContext) + } + } + + return tst +} + +func (s *Classification_taskContext) Term(i int) ITermContext { + var t = s.GetTypedRuleContext(reflect.TypeOf((*ITermContext)(nil)).Elem(), i) + + if t == nil { + return nil + } + + return t.(ITermContext) +} + +func (s *Classification_taskContext) GetRuleContext() antlr.RuleContext { + return s +} + +func (s *Classification_taskContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string { + return antlr.TreesStringTree(s, ruleNames, recog) +} + +func (s *Classification_taskContext) EnterRule(listener antlr.ParseTreeListener) { + if listenerT, ok := listener.(ILPLangListener); ok { + listenerT.EnterClassification_task(s) + } +} + +func (s *Classification_taskContext) ExitRule(listener antlr.ParseTreeListener) { + if listenerT, ok := listener.(ILPLangListener); ok { + listenerT.ExitClassification_task(s) + } +} + +func (p *ILPLangParser) Classification_task() (localctx IClassification_taskContext) { + localctx = NewClassification_taskContext(p, p.GetParserRuleContext(), p.GetState()) + p.EnterRule(localctx, 2, ILPLangParserRULE_classification_task) var _la int defer func() { @@ -192,23 +332,140 @@ func (p *ILPLangParser) Start() (localctx IStartContext) { }() p.EnterOuterAlt(localctx, 1) - p.SetState(7) + p.SetState(19) p.GetErrorHandler().Sync(p) _la = p.GetTokenStream().LA(1) for _la == ILPLangParserOBJECT { { - p.SetState(4) + p.SetState(16) p.Term() } - p.SetState(9) + p.SetState(21) p.GetErrorHandler().Sync(p) _la = p.GetTokenStream().LA(1) } - { - p.SetState(10) - p.Match(ILPLangParserEOF) + + return localctx +} + +// IRegression_taskContext is an interface to support dynamic dispatch. +type IRegression_taskContext interface { + antlr.ParserRuleContext + + // GetParser returns the parser. + GetParser() antlr.Parser + + // IsRegression_taskContext differentiates from other interfaces. + IsRegression_taskContext() +} + +type Regression_taskContext struct { + *antlr.BaseParserRuleContext + parser antlr.Parser +} + +func NewEmptyRegression_taskContext() *Regression_taskContext { + var p = new(Regression_taskContext) + p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1) + p.RuleIndex = ILPLangParserRULE_regression_task + return p +} + +func (*Regression_taskContext) IsRegression_taskContext() {} + +func NewRegression_taskContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *Regression_taskContext { + var p = new(Regression_taskContext) + + p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState) + + p.parser = parser + p.RuleIndex = ILPLangParserRULE_regression_task + + return p +} + +func (s *Regression_taskContext) GetParser() antlr.Parser { return s.parser } + +func (s *Regression_taskContext) AllRegression_term() []IRegression_termContext { + var ts = s.GetTypedRuleContexts(reflect.TypeOf((*IRegression_termContext)(nil)).Elem()) + var tst = make([]IRegression_termContext, len(ts)) + + for i, t := range ts { + if t != nil { + tst[i] = t.(IRegression_termContext) + } + } + + return tst +} + +func (s *Regression_taskContext) Regression_term(i int) IRegression_termContext { + var t = s.GetTypedRuleContext(reflect.TypeOf((*IRegression_termContext)(nil)).Elem(), i) + + if t == nil { + return nil + } + + return t.(IRegression_termContext) +} + +func (s *Regression_taskContext) GetRuleContext() antlr.RuleContext { + return s +} + +func (s *Regression_taskContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string { + return antlr.TreesStringTree(s, ruleNames, recog) +} + +func (s *Regression_taskContext) EnterRule(listener antlr.ParseTreeListener) { + if listenerT, ok := listener.(ILPLangListener); ok { + listenerT.EnterRegression_task(s) + } +} + +func (s *Regression_taskContext) ExitRule(listener antlr.ParseTreeListener) { + if listenerT, ok := listener.(ILPLangListener); ok { + listenerT.ExitRegression_task(s) + } +} + +func (p *ILPLangParser) Regression_task() (localctx IRegression_taskContext) { + localctx = NewRegression_taskContext(p, p.GetParserRuleContext(), p.GetState()) + p.EnterRule(localctx, 4, ILPLangParserRULE_regression_task) + var _la int + + defer func() { + p.ExitRule() + }() + + defer func() { + if err := recover(); err != nil { + if v, ok := err.(antlr.RecognitionException); ok { + localctx.SetException(v) + p.GetErrorHandler().ReportError(p, v) + p.GetErrorHandler().Recover(p, v) + } else { + panic(err) + } + } + }() + + p.EnterOuterAlt(localctx, 1) + p.SetState(25) + p.GetErrorHandler().Sync(p) + _la = p.GetTokenStream().LA(1) + + for _la == ILPLangParserT__0 { + { + p.SetState(22) + p.Regression_term() + } + + p.SetState(27) + p.GetErrorHandler().Sync(p) + _la = p.GetTokenStream().LA(1) } return localctx @@ -284,6 +541,14 @@ func (s *TermContext) COMMA(i int) antlr.TerminalNode { return s.GetToken(ILPLangParserCOMMA, i) } +func (s *TermContext) AllINTEGER() []antlr.TerminalNode { + return s.GetTokens(ILPLangParserINTEGER) +} + +func (s *TermContext) INTEGER(i int) antlr.TerminalNode { + return s.GetToken(ILPLangParserINTEGER, i) +} + func (s *TermContext) GetRuleContext() antlr.RuleContext { return s } @@ -306,7 +571,7 @@ func (s *TermContext) ExitRule(listener antlr.ParseTreeListener) { func (p *ILPLangParser) Term() (localctx ITermContext) { localctx = NewTermContext(p, p.GetParserRuleContext(), p.GetState()) - p.EnterRule(localctx, 2, ILPLangParserRULE_term) + p.EnterRule(localctx, 6, ILPLangParserRULE_term) var _la int defer func() { @@ -327,45 +592,231 @@ func (p *ILPLangParser) Term() (localctx ITermContext) { p.EnterOuterAlt(localctx, 1) { - p.SetState(12) + p.SetState(28) p.Match(ILPLangParserOBJECT) } { - p.SetState(13) + p.SetState(29) p.Match(ILPLangParserLPAREN) } { - p.SetState(14) + p.SetState(30) p.Match(ILPLangParserOBJECT) } - p.SetState(19) + p.SetState(35) p.GetErrorHandler().Sync(p) _la = p.GetTokenStream().LA(1) for _la == ILPLangParserCOMMA { { - p.SetState(15) + p.SetState(31) p.Match(ILPLangParserCOMMA) } { - p.SetState(16) - p.Match(ILPLangParserOBJECT) + p.SetState(32) + _la = p.GetTokenStream().LA(1) + + if !(_la == ILPLangParserINTEGER || _la == ILPLangParserOBJECT) { + p.GetErrorHandler().RecoverInline(p) + } else { + p.GetErrorHandler().ReportMatch(p) + p.Consume() + } } - p.SetState(21) + p.SetState(37) p.GetErrorHandler().Sync(p) _la = p.GetTokenStream().LA(1) } { - p.SetState(22) + p.SetState(38) + p.Match(ILPLangParserRPAREN) + } + { + p.SetState(39) + p.Match(ILPLangParserPERIOD) + } + { + p.SetState(40) + p.Match(ILPLangParserNEWLINE) + } + + return localctx +} + +// IRegression_termContext is an interface to support dynamic dispatch. +type IRegression_termContext interface { + antlr.ParserRuleContext + + // GetParser returns the parser. + GetParser() antlr.Parser + + // IsRegression_termContext differentiates from other interfaces. + IsRegression_termContext() +} + +type Regression_termContext struct { + *antlr.BaseParserRuleContext + parser antlr.Parser +} + +func NewEmptyRegression_termContext() *Regression_termContext { + var p = new(Regression_termContext) + p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1) + p.RuleIndex = ILPLangParserRULE_regression_term + return p +} + +func (*Regression_termContext) IsRegression_termContext() {} + +func NewRegression_termContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *Regression_termContext { + var p = new(Regression_termContext) + + p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState) + + p.parser = parser + p.RuleIndex = ILPLangParserRULE_regression_term + + return p +} + +func (s *Regression_termContext) GetParser() antlr.Parser { return s.parser } + +func (s *Regression_termContext) AllLPAREN() []antlr.TerminalNode { + return s.GetTokens(ILPLangParserLPAREN) +} + +func (s *Regression_termContext) LPAREN(i int) antlr.TerminalNode { + return s.GetToken(ILPLangParserLPAREN, i) +} + +func (s *Regression_termContext) AllOBJECT() []antlr.TerminalNode { + return s.GetTokens(ILPLangParserOBJECT) +} + +func (s *Regression_termContext) OBJECT(i int) antlr.TerminalNode { + return s.GetToken(ILPLangParserOBJECT, i) +} + +func (s *Regression_termContext) AllRPAREN() []antlr.TerminalNode { + return s.GetTokens(ILPLangParserRPAREN) +} + +func (s *Regression_termContext) RPAREN(i int) antlr.TerminalNode { + return s.GetToken(ILPLangParserRPAREN, i) +} + +func (s *Regression_termContext) COMMA() antlr.TerminalNode { + return s.GetToken(ILPLangParserCOMMA, 0) +} + +func (s *Regression_termContext) PERIOD() antlr.TerminalNode { + return s.GetToken(ILPLangParserPERIOD, 0) +} + +func (s *Regression_termContext) NEWLINE() antlr.TerminalNode { + return s.GetToken(ILPLangParserNEWLINE, 0) +} + +func (s *Regression_termContext) FLOAT() antlr.TerminalNode { + return s.GetToken(ILPLangParserFLOAT, 0) +} + +func (s *Regression_termContext) INTEGER() antlr.TerminalNode { + return s.GetToken(ILPLangParserINTEGER, 0) +} + +func (s *Regression_termContext) GetRuleContext() antlr.RuleContext { + return s +} + +func (s *Regression_termContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string { + return antlr.TreesStringTree(s, ruleNames, recog) +} + +func (s *Regression_termContext) EnterRule(listener antlr.ParseTreeListener) { + if listenerT, ok := listener.(ILPLangListener); ok { + listenerT.EnterRegression_term(s) + } +} + +func (s *Regression_termContext) ExitRule(listener antlr.ParseTreeListener) { + if listenerT, ok := listener.(ILPLangListener); ok { + listenerT.ExitRegression_term(s) + } +} + +func (p *ILPLangParser) Regression_term() (localctx IRegression_termContext) { + localctx = NewRegression_termContext(p, p.GetParserRuleContext(), p.GetState()) + p.EnterRule(localctx, 8, ILPLangParserRULE_regression_term) + var _la int + + defer func() { + p.ExitRule() + }() + + defer func() { + if err := recover(); err != nil { + if v, ok := err.(antlr.RecognitionException); ok { + localctx.SetException(v) + p.GetErrorHandler().ReportError(p, v) + p.GetErrorHandler().Recover(p, v) + } else { + panic(err) + } + } + }() + + p.EnterOuterAlt(localctx, 1) + { + p.SetState(42) + p.Match(ILPLangParserT__0) + } + { + p.SetState(43) + p.Match(ILPLangParserLPAREN) + } + { + p.SetState(44) + p.Match(ILPLangParserOBJECT) + } + { + p.SetState(45) + p.Match(ILPLangParserLPAREN) + } + { + p.SetState(46) + p.Match(ILPLangParserOBJECT) + } + { + p.SetState(47) + p.Match(ILPLangParserRPAREN) + } + { + p.SetState(48) + p.Match(ILPLangParserCOMMA) + } + { + p.SetState(49) + _la = p.GetTokenStream().LA(1) + + if !(_la == ILPLangParserFLOAT || _la == ILPLangParserINTEGER) { + p.GetErrorHandler().RecoverInline(p) + } else { + p.GetErrorHandler().ReportMatch(p) + p.Consume() + } + } + { + p.SetState(50) p.Match(ILPLangParserRPAREN) } { - p.SetState(23) + p.SetState(51) p.Match(ILPLangParserPERIOD) } { - p.SetState(24) + p.SetState(52) p.Match(ILPLangParserNEWLINE) }