Updated grammar to support single and multiline comments

- Fixed bugged type parsing
- Added optional function return type
- Comments don't require proper indentation right now, but should they?
This commit is contained in:
The other zerg 2022-09-26 12:31:22 +02:00
parent 23f34bf885
commit fed9cc4a29
13 changed files with 687 additions and 358 deletions

View File

@ -31,8 +31,6 @@ var lexer = new Waifu2Lexer(inputStream);
var tokens = new CommonTokenStream(lexer);
var parser = new Waifu2Parser(tokens);
parser.BuildParseTree = true;
var listener = new BaseErrorListener();
IParseTree tree = parser.waifuFile();
Console.WriteLine(tree.GetText());

View File

@ -1,9 +1,9 @@
(x1 :#) f2
# 333 + 433
# x2 <- x1 * 2
# -x2
# () f
# a <- 5
333 + 433
x2 <- x1 * 2
-x2
() f
a <- 5
# aa + ba
# ca <- aa + ba
# print ca
ca <- aa + ba
print ca

View File

@ -1,23 +1,23 @@
grammar Waifu2;
WS: ' ';
NL: '\u000A';
NL: '\n';
ID
: (Letter | '_') (Letter | '_' | DEC_DIGIT)*
: (Letter | '_') (Letter | '_' | DEC_DIGIT)*
;
INDENT: ' ';
fragment Letter: [a-zA-Z] ;
// comments
MultiLineComment
: '##' ( MultiLineComment | . )*? '##'
-> channel(HIDDEN)
;
SingleLineComment
: '#' ~[\u000A]*
-> channel(HIDDEN)
;
// operators
@ -35,6 +35,8 @@ LPAREN: '(' ;
RPAREN: ')' ;
COLON: ':' ;
HASH: '#';
// numerics
fragment DEC_DIGIT:
[0-9]
@ -43,19 +45,22 @@ INT: DEC_DIGIT+ ;
DEC: DEC_DIGIT* '.' DEC_DIGIT+ ;
BOOL: [01] ;
num: INT | DEC | BOOL;
STR: '\'' .*? '\'' ;
waifuFile
: NL* func* NL* EOF
;
// todo not right
type: COLON '#' ;
TYPE: COLON .+? ;
sign
: ADD
| SUB
;
value: DEC | INT | BOOL | STR ;
operator: SUB | ADD | MULT | DIV | MOD ;
@ -64,17 +69,20 @@ literal: INT | DEC | BOOL | STR ;
// func
func: functionDeclaration NL functionBody ;
functionDeclaration: LPAREN functionParam RPAREN WS type? WS ID NL ;
functionParam: ID WS type ;
functionBody: (expr NL+)+ ;
functionDeclaration: LPAREN functionParam* RPAREN (WS TYPE)? WS ID;
functionParam: ID WS TYPE ;
functionBody: ((INDENT expr | SingleLineComment | MultiLineComment) NL)+ ;
functionCall: ID WS expr (WS expr)* ;
// expr
expr: literal
| ID
| DEC
| expr WS operator WS expr
| sign expr
| SUB (ID | num)
| ID WS ASSIGN WS expr
| MultiLineComment
| SingleLineComment
| functionCall
;

View File

@ -1,9 +1,9 @@
token literal names:
null
'#'
' '
'\u000A'
'\n'
null
' '
null
null
'*'
@ -15,6 +15,8 @@ null
'('
')'
':'
'#'
null
null
null
null
@ -22,10 +24,10 @@ null
token symbolic names:
null
null
WS
NL
ID
INDENT
MultiLineComment
SingleLineComment
MULT
@ -37,23 +39,27 @@ ASSIGN
LPAREN
RPAREN
COLON
HASH
INT
DEC
BOOL
STR
TYPE
rule names:
num
waifuFile
type
sign
value
operator
literal
func
functionDeclaration
functionParam
functionBody
functionCall
expr
atn:
[4, 1, 19, 100, 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, 1, 0, 5, 0, 22, 8, 0, 10, 0, 12, 0, 25, 9, 0, 1, 0, 5, 0, 28, 8, 0, 10, 0, 12, 0, 31, 9, 0, 1, 0, 5, 0, 34, 8, 0, 10, 0, 12, 0, 37, 9, 0, 1, 0, 1, 0, 1, 1, 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, 6, 1, 6, 1, 6, 1, 6, 1, 6, 3, 6, 59, 8, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 7, 1, 7, 1, 7, 1, 7, 1, 8, 1, 8, 4, 8, 71, 8, 8, 11, 8, 12, 8, 72, 4, 8, 75, 8, 8, 11, 8, 12, 8, 76, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 3, 9, 87, 8, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 5, 9, 95, 8, 9, 10, 9, 12, 9, 98, 9, 9, 1, 9, 0, 1, 18, 10, 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 0, 3, 1, 0, 10, 11, 1, 0, 7, 11, 1, 0, 16, 19, 100, 0, 23, 1, 0, 0, 0, 2, 40, 1, 0, 0, 0, 4, 43, 1, 0, 0, 0, 6, 45, 1, 0, 0, 0, 8, 47, 1, 0, 0, 0, 10, 49, 1, 0, 0, 0, 12, 53, 1, 0, 0, 0, 14, 64, 1, 0, 0, 0, 16, 74, 1, 0, 0, 0, 18, 86, 1, 0, 0, 0, 20, 22, 5, 3, 0, 0, 21, 20, 1, 0, 0, 0, 22, 25, 1, 0, 0, 0, 23, 21, 1, 0, 0, 0, 23, 24, 1, 0, 0, 0, 24, 29, 1, 0, 0, 0, 25, 23, 1, 0, 0, 0, 26, 28, 3, 10, 5, 0, 27, 26, 1, 0, 0, 0, 28, 31, 1, 0, 0, 0, 29, 27, 1, 0, 0, 0, 29, 30, 1, 0, 0, 0, 30, 35, 1, 0, 0, 0, 31, 29, 1, 0, 0, 0, 32, 34, 5, 3, 0, 0, 33, 32, 1, 0, 0, 0, 34, 37, 1, 0, 0, 0, 35, 33, 1, 0, 0, 0, 35, 36, 1, 0, 0, 0, 36, 38, 1, 0, 0, 0, 37, 35, 1, 0, 0, 0, 38, 39, 5, 0, 0, 1, 39, 1, 1, 0, 0, 0, 40, 41, 5, 15, 0, 0, 41, 42, 5, 1, 0, 0, 42, 3, 1, 0, 0, 0, 43, 44, 7, 0, 0, 0, 44, 5, 1, 0, 0, 0, 45, 46, 7, 1, 0, 0, 46, 7, 1, 0, 0, 0, 47, 48, 7, 2, 0, 0, 48, 9, 1, 0, 0, 0, 49, 50, 3, 12, 6, 0, 50, 51, 5, 3, 0, 0, 51, 52, 3, 16, 8, 0, 52, 11, 1, 0, 0, 0, 53, 54, 5, 13, 0, 0, 54, 55, 3, 14, 7, 0, 55, 56, 5, 14, 0, 0, 56, 58, 5, 2, 0, 0, 57, 59, 3, 2, 1, 0, 58, 57, 1, 0, 0, 0, 58, 59, 1, 0, 0, 0, 59, 60, 1, 0, 0, 0, 60, 61, 5, 2, 0, 0, 61, 62, 5, 4, 0, 0, 62, 63, 5, 3, 0, 0, 63, 13, 1, 0, 0, 0, 64, 65, 5, 4, 0, 0, 65, 66, 5, 2, 0, 0, 66, 67, 3, 2, 1, 0, 67, 15, 1, 0, 0, 0, 68, 70, 3, 18, 9, 0, 69, 71, 5, 3, 0, 0, 70, 69, 1, 0, 0, 0, 71, 72, 1, 0, 0, 0, 72, 70, 1, 0, 0, 0, 72, 73, 1, 0, 0, 0, 73, 75, 1, 0, 0, 0, 74, 68, 1, 0, 0, 0, 75, 76, 1, 0, 0, 0, 76, 74, 1, 0, 0, 0, 76, 77, 1, 0, 0, 0, 77, 17, 1, 0, 0, 0, 78, 79, 6, 9, -1, 0, 79, 87, 3, 8, 4, 0, 80, 87, 5, 4, 0, 0, 81, 82, 3, 4, 2, 0, 82, 83, 3, 18, 9, 3, 83, 87, 1, 0, 0, 0, 84, 87, 5, 5, 0, 0, 85, 87, 5, 6, 0, 0, 86, 78, 1, 0, 0, 0, 86, 80, 1, 0, 0, 0, 86, 81, 1, 0, 0, 0, 86, 84, 1, 0, 0, 0, 86, 85, 1, 0, 0, 0, 87, 96, 1, 0, 0, 0, 88, 89, 10, 4, 0, 0, 89, 90, 5, 2, 0, 0, 90, 91, 3, 6, 3, 0, 91, 92, 5, 2, 0, 0, 92, 93, 3, 18, 9, 5, 93, 95, 1, 0, 0, 0, 94, 88, 1, 0, 0, 0, 95, 98, 1, 0, 0, 0, 96, 94, 1, 0, 0, 0, 96, 97, 1, 0, 0, 0, 97, 19, 1, 0, 0, 0, 98, 96, 1, 0, 0, 0, 8, 23, 29, 35, 58, 72, 76, 86, 96]
[4, 1, 21, 129, 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, 1, 0, 1, 0, 1, 1, 5, 1, 28, 8, 1, 10, 1, 12, 1, 31, 9, 1, 1, 1, 5, 1, 34, 8, 1, 10, 1, 12, 1, 37, 9, 1, 1, 1, 5, 1, 40, 8, 1, 10, 1, 12, 1, 43, 9, 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, 6, 1, 6, 1, 7, 1, 7, 5, 7, 61, 8, 7, 10, 7, 12, 7, 64, 9, 7, 1, 7, 1, 7, 1, 7, 3, 7, 69, 8, 7, 1, 7, 1, 7, 1, 7, 1, 8, 1, 8, 1, 8, 1, 8, 1, 9, 1, 9, 1, 9, 1, 9, 3, 9, 82, 8, 9, 1, 9, 4, 9, 85, 8, 9, 11, 9, 12, 9, 86, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 5, 10, 94, 8, 10, 10, 10, 12, 10, 97, 9, 10, 1, 11, 1, 11, 1, 11, 1, 11, 1, 11, 1, 11, 1, 11, 3, 11, 106, 8, 11, 1, 11, 1, 11, 1, 11, 1, 11, 1, 11, 1, 11, 1, 11, 1, 11, 3, 11, 116, 8, 11, 1, 11, 1, 11, 1, 11, 1, 11, 1, 11, 1, 11, 5, 11, 124, 8, 11, 10, 11, 12, 11, 127, 9, 11, 1, 11, 0, 1, 22, 12, 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 0, 4, 1, 0, 17, 19, 1, 0, 10, 11, 1, 0, 17, 20, 1, 0, 7, 11, 134, 0, 24, 1, 0, 0, 0, 2, 29, 1, 0, 0, 0, 4, 46, 1, 0, 0, 0, 6, 48, 1, 0, 0, 0, 8, 50, 1, 0, 0, 0, 10, 52, 1, 0, 0, 0, 12, 54, 1, 0, 0, 0, 14, 58, 1, 0, 0, 0, 16, 73, 1, 0, 0, 0, 18, 84, 1, 0, 0, 0, 20, 88, 1, 0, 0, 0, 22, 115, 1, 0, 0, 0, 24, 25, 7, 0, 0, 0, 25, 1, 1, 0, 0, 0, 26, 28, 5, 2, 0, 0, 27, 26, 1, 0, 0, 0, 28, 31, 1, 0, 0, 0, 29, 27, 1, 0, 0, 0, 29, 30, 1, 0, 0, 0, 30, 35, 1, 0, 0, 0, 31, 29, 1, 0, 0, 0, 32, 34, 3, 12, 6, 0, 33, 32, 1, 0, 0, 0, 34, 37, 1, 0, 0, 0, 35, 33, 1, 0, 0, 0, 35, 36, 1, 0, 0, 0, 36, 41, 1, 0, 0, 0, 37, 35, 1, 0, 0, 0, 38, 40, 5, 2, 0, 0, 39, 38, 1, 0, 0, 0, 40, 43, 1, 0, 0, 0, 41, 39, 1, 0, 0, 0, 41, 42, 1, 0, 0, 0, 42, 44, 1, 0, 0, 0, 43, 41, 1, 0, 0, 0, 44, 45, 5, 0, 0, 1, 45, 3, 1, 0, 0, 0, 46, 47, 7, 1, 0, 0, 47, 5, 1, 0, 0, 0, 48, 49, 7, 2, 0, 0, 49, 7, 1, 0, 0, 0, 50, 51, 7, 3, 0, 0, 51, 9, 1, 0, 0, 0, 52, 53, 7, 2, 0, 0, 53, 11, 1, 0, 0, 0, 54, 55, 3, 14, 7, 0, 55, 56, 5, 2, 0, 0, 56, 57, 3, 18, 9, 0, 57, 13, 1, 0, 0, 0, 58, 62, 5, 13, 0, 0, 59, 61, 3, 16, 8, 0, 60, 59, 1, 0, 0, 0, 61, 64, 1, 0, 0, 0, 62, 60, 1, 0, 0, 0, 62, 63, 1, 0, 0, 0, 63, 65, 1, 0, 0, 0, 64, 62, 1, 0, 0, 0, 65, 68, 5, 14, 0, 0, 66, 67, 5, 1, 0, 0, 67, 69, 5, 21, 0, 0, 68, 66, 1, 0, 0, 0, 68, 69, 1, 0, 0, 0, 69, 70, 1, 0, 0, 0, 70, 71, 5, 1, 0, 0, 71, 72, 5, 3, 0, 0, 72, 15, 1, 0, 0, 0, 73, 74, 5, 3, 0, 0, 74, 75, 5, 1, 0, 0, 75, 76, 5, 21, 0, 0, 76, 17, 1, 0, 0, 0, 77, 78, 5, 4, 0, 0, 78, 82, 3, 22, 11, 0, 79, 82, 5, 6, 0, 0, 80, 82, 5, 5, 0, 0, 81, 77, 1, 0, 0, 0, 81, 79, 1, 0, 0, 0, 81, 80, 1, 0, 0, 0, 82, 83, 1, 0, 0, 0, 83, 85, 5, 2, 0, 0, 84, 81, 1, 0, 0, 0, 85, 86, 1, 0, 0, 0, 86, 84, 1, 0, 0, 0, 86, 87, 1, 0, 0, 0, 87, 19, 1, 0, 0, 0, 88, 89, 5, 3, 0, 0, 89, 90, 5, 1, 0, 0, 90, 95, 3, 22, 11, 0, 91, 92, 5, 1, 0, 0, 92, 94, 3, 22, 11, 0, 93, 91, 1, 0, 0, 0, 94, 97, 1, 0, 0, 0, 95, 93, 1, 0, 0, 0, 95, 96, 1, 0, 0, 0, 96, 21, 1, 0, 0, 0, 97, 95, 1, 0, 0, 0, 98, 99, 6, 11, -1, 0, 99, 116, 3, 10, 5, 0, 100, 116, 5, 3, 0, 0, 101, 116, 5, 18, 0, 0, 102, 105, 5, 11, 0, 0, 103, 106, 5, 3, 0, 0, 104, 106, 3, 0, 0, 0, 105, 103, 1, 0, 0, 0, 105, 104, 1, 0, 0, 0, 106, 116, 1, 0, 0, 0, 107, 108, 5, 3, 0, 0, 108, 109, 5, 1, 0, 0, 109, 110, 5, 12, 0, 0, 110, 111, 5, 1, 0, 0, 111, 116, 3, 22, 11, 4, 112, 116, 5, 5, 0, 0, 113, 116, 5, 6, 0, 0, 114, 116, 3, 20, 10, 0, 115, 98, 1, 0, 0, 0, 115, 100, 1, 0, 0, 0, 115, 101, 1, 0, 0, 0, 115, 102, 1, 0, 0, 0, 115, 107, 1, 0, 0, 0, 115, 112, 1, 0, 0, 0, 115, 113, 1, 0, 0, 0, 115, 114, 1, 0, 0, 0, 116, 125, 1, 0, 0, 0, 117, 118, 10, 6, 0, 0, 118, 119, 5, 1, 0, 0, 119, 120, 3, 8, 4, 0, 120, 121, 5, 1, 0, 0, 121, 122, 3, 22, 11, 7, 122, 124, 1, 0, 0, 0, 123, 117, 1, 0, 0, 0, 124, 127, 1, 0, 0, 0, 125, 123, 1, 0, 0, 0, 125, 126, 1, 0, 0, 0, 126, 23, 1, 0, 0, 0, 127, 125, 1, 0, 0, 0, 11, 29, 35, 41, 62, 68, 81, 86, 95, 105, 115, 125]

View File

@ -1,7 +1,7 @@
T__0=1
WS=2
NL=3
ID=4
WS=1
NL=2
ID=3
INDENT=4
MultiLineComment=5
SingleLineComment=6
MULT=7
@ -13,13 +13,15 @@ ASSIGN=12
LPAREN=13
RPAREN=14
COLON=15
INT=16
DEC=17
BOOL=18
STR=19
'#'=1
' '=2
'\u000A'=3
HASH=16
INT=17
DEC=18
BOOL=19
STR=20
TYPE=21
' '=1
'\n'=2
' '=4
'*'=7
'%'=8
'/'=9
@ -29,3 +31,4 @@ STR=19
'('=13
')'=14
':'=15
'#'=16

View File

@ -36,6 +36,18 @@ using ParserRuleContext = Antlr4.Runtime.ParserRuleContext;
[System.Diagnostics.DebuggerNonUserCode]
[System.CLSCompliant(false)]
public partial class Waifu2BaseListener : IWaifu2Listener {
/// <summary>
/// Enter a parse tree produced by <see cref="Waifu2Parser.num"/>.
/// <para>The default implementation does nothing.</para>
/// </summary>
/// <param name="context">The parse tree.</param>
public virtual void EnterNum([NotNull] Waifu2Parser.NumContext context) { }
/// <summary>
/// Exit a parse tree produced by <see cref="Waifu2Parser.num"/>.
/// <para>The default implementation does nothing.</para>
/// </summary>
/// <param name="context">The parse tree.</param>
public virtual void ExitNum([NotNull] Waifu2Parser.NumContext context) { }
/// <summary>
/// Enter a parse tree produced by <see cref="Waifu2Parser.waifuFile"/>.
/// <para>The default implementation does nothing.</para>
@ -49,18 +61,6 @@ public partial class Waifu2BaseListener : IWaifu2Listener {
/// <param name="context">The parse tree.</param>
public virtual void ExitWaifuFile([NotNull] Waifu2Parser.WaifuFileContext context) { }
/// <summary>
/// Enter a parse tree produced by <see cref="Waifu2Parser.type"/>.
/// <para>The default implementation does nothing.</para>
/// </summary>
/// <param name="context">The parse tree.</param>
public virtual void EnterType([NotNull] Waifu2Parser.TypeContext context) { }
/// <summary>
/// Exit a parse tree produced by <see cref="Waifu2Parser.type"/>.
/// <para>The default implementation does nothing.</para>
/// </summary>
/// <param name="context">The parse tree.</param>
public virtual void ExitType([NotNull] Waifu2Parser.TypeContext context) { }
/// <summary>
/// Enter a parse tree produced by <see cref="Waifu2Parser.sign"/>.
/// <para>The default implementation does nothing.</para>
/// </summary>
@ -73,6 +73,18 @@ public partial class Waifu2BaseListener : IWaifu2Listener {
/// <param name="context">The parse tree.</param>
public virtual void ExitSign([NotNull] Waifu2Parser.SignContext context) { }
/// <summary>
/// Enter a parse tree produced by <see cref="Waifu2Parser.value"/>.
/// <para>The default implementation does nothing.</para>
/// </summary>
/// <param name="context">The parse tree.</param>
public virtual void EnterValue([NotNull] Waifu2Parser.ValueContext context) { }
/// <summary>
/// Exit a parse tree produced by <see cref="Waifu2Parser.value"/>.
/// <para>The default implementation does nothing.</para>
/// </summary>
/// <param name="context">The parse tree.</param>
public virtual void ExitValue([NotNull] Waifu2Parser.ValueContext context) { }
/// <summary>
/// Enter a parse tree produced by <see cref="Waifu2Parser.operator"/>.
/// <para>The default implementation does nothing.</para>
/// </summary>
@ -145,6 +157,18 @@ public partial class Waifu2BaseListener : IWaifu2Listener {
/// <param name="context">The parse tree.</param>
public virtual void ExitFunctionBody([NotNull] Waifu2Parser.FunctionBodyContext context) { }
/// <summary>
/// Enter a parse tree produced by <see cref="Waifu2Parser.functionCall"/>.
/// <para>The default implementation does nothing.</para>
/// </summary>
/// <param name="context">The parse tree.</param>
public virtual void EnterFunctionCall([NotNull] Waifu2Parser.FunctionCallContext context) { }
/// <summary>
/// Exit a parse tree produced by <see cref="Waifu2Parser.functionCall"/>.
/// <para>The default implementation does nothing.</para>
/// </summary>
/// <param name="context">The parse tree.</param>
public virtual void ExitFunctionCall([NotNull] Waifu2Parser.FunctionCallContext context) { }
/// <summary>
/// Enter a parse tree produced by <see cref="Waifu2Parser.expr"/>.
/// <para>The default implementation does nothing.</para>
/// </summary>

View File

@ -35,6 +35,16 @@ using ParserRuleContext = Antlr4.Runtime.ParserRuleContext;
[System.Diagnostics.DebuggerNonUserCode]
[System.CLSCompliant(false)]
public partial class Waifu2BaseVisitor<Result> : AbstractParseTreeVisitor<Result>, IWaifu2Visitor<Result> {
/// <summary>
/// Visit a parse tree produced by <see cref="Waifu2Parser.num"/>.
/// <para>
/// The default implementation returns the result of calling <see cref="AbstractParseTreeVisitor{Result}.VisitChildren(IRuleNode)"/>
/// on <paramref name="context"/>.
/// </para>
/// </summary>
/// <param name="context">The parse tree.</param>
/// <return>The visitor result.</return>
public virtual Result VisitNum([NotNull] Waifu2Parser.NumContext context) { return VisitChildren(context); }
/// <summary>
/// Visit a parse tree produced by <see cref="Waifu2Parser.waifuFile"/>.
/// <para>
@ -46,16 +56,6 @@ public partial class Waifu2BaseVisitor<Result> : AbstractParseTreeVisitor<Result
/// <return>The visitor result.</return>
public virtual Result VisitWaifuFile([NotNull] Waifu2Parser.WaifuFileContext context) { return VisitChildren(context); }
/// <summary>
/// Visit a parse tree produced by <see cref="Waifu2Parser.type"/>.
/// <para>
/// The default implementation returns the result of calling <see cref="AbstractParseTreeVisitor{Result}.VisitChildren(IRuleNode)"/>
/// on <paramref name="context"/>.
/// </para>
/// </summary>
/// <param name="context">The parse tree.</param>
/// <return>The visitor result.</return>
public virtual Result VisitType([NotNull] Waifu2Parser.TypeContext context) { return VisitChildren(context); }
/// <summary>
/// Visit a parse tree produced by <see cref="Waifu2Parser.sign"/>.
/// <para>
/// The default implementation returns the result of calling <see cref="AbstractParseTreeVisitor{Result}.VisitChildren(IRuleNode)"/>
@ -66,6 +66,16 @@ public partial class Waifu2BaseVisitor<Result> : AbstractParseTreeVisitor<Result
/// <return>The visitor result.</return>
public virtual Result VisitSign([NotNull] Waifu2Parser.SignContext context) { return VisitChildren(context); }
/// <summary>
/// Visit a parse tree produced by <see cref="Waifu2Parser.value"/>.
/// <para>
/// The default implementation returns the result of calling <see cref="AbstractParseTreeVisitor{Result}.VisitChildren(IRuleNode)"/>
/// on <paramref name="context"/>.
/// </para>
/// </summary>
/// <param name="context">The parse tree.</param>
/// <return>The visitor result.</return>
public virtual Result VisitValue([NotNull] Waifu2Parser.ValueContext context) { return VisitChildren(context); }
/// <summary>
/// Visit a parse tree produced by <see cref="Waifu2Parser.operator"/>.
/// <para>
/// The default implementation returns the result of calling <see cref="AbstractParseTreeVisitor{Result}.VisitChildren(IRuleNode)"/>
@ -126,6 +136,16 @@ public partial class Waifu2BaseVisitor<Result> : AbstractParseTreeVisitor<Result
/// <return>The visitor result.</return>
public virtual Result VisitFunctionBody([NotNull] Waifu2Parser.FunctionBodyContext context) { return VisitChildren(context); }
/// <summary>
/// Visit a parse tree produced by <see cref="Waifu2Parser.functionCall"/>.
/// <para>
/// The default implementation returns the result of calling <see cref="AbstractParseTreeVisitor{Result}.VisitChildren(IRuleNode)"/>
/// on <paramref name="context"/>.
/// </para>
/// </summary>
/// <param name="context">The parse tree.</param>
/// <return>The visitor result.</return>
public virtual Result VisitFunctionCall([NotNull] Waifu2Parser.FunctionCallContext context) { return VisitChildren(context); }
/// <summary>
/// Visit a parse tree produced by <see cref="Waifu2Parser.expr"/>.
/// <para>
/// The default implementation returns the result of calling <see cref="AbstractParseTreeVisitor{Result}.VisitChildren(IRuleNode)"/>

View File

@ -34,9 +34,9 @@ public partial class Waifu2Lexer : Lexer {
protected static DFA[] decisionToDFA;
protected static PredictionContextCache sharedContextCache = new PredictionContextCache();
public const int
T__0=1, WS=2, NL=3, ID=4, MultiLineComment=5, SingleLineComment=6, MULT=7,
WS=1, NL=2, ID=3, INDENT=4, MultiLineComment=5, SingleLineComment=6, MULT=7,
MOD=8, DIV=9, ADD=10, SUB=11, ASSIGN=12, LPAREN=13, RPAREN=14, COLON=15,
INT=16, DEC=17, BOOL=18, STR=19;
HASH=16, INT=17, DEC=18, BOOL=19, STR=20, TYPE=21;
public static string[] channelNames = {
"DEFAULT_TOKEN_CHANNEL", "HIDDEN"
};
@ -46,9 +46,9 @@ public partial class Waifu2Lexer : Lexer {
};
public static readonly string[] ruleNames = {
"T__0", "WS", "NL", "ID", "Letter", "MultiLineComment", "SingleLineComment",
"WS", "NL", "ID", "INDENT", "Letter", "MultiLineComment", "SingleLineComment",
"MULT", "MOD", "DIV", "ADD", "SUB", "ASSIGN", "LPAREN", "RPAREN", "COLON",
"DEC_DIGIT", "INT", "DEC", "BOOL", "STR"
"HASH", "DEC_DIGIT", "INT", "DEC", "BOOL", "STR", "TYPE"
};
@ -62,13 +62,13 @@ public partial class Waifu2Lexer : Lexer {
}
private static readonly string[] _LiteralNames = {
null, "'#'", "' '", "'\\u000A'", null, null, null, "'*'", "'%'", "'/'",
"'+'", "'-'", "'<-'", "'('", "')'", "':'"
null, "' '", "'\\n'", null, "' '", null, null, "'*'", "'%'", "'/'", "'+'",
"'-'", "'<-'", "'('", "')'", "':'", "'#'"
};
private static readonly string[] _SymbolicNames = {
null, null, "WS", "NL", "ID", "MultiLineComment", "SingleLineComment",
null, "WS", "NL", "ID", "INDENT", "MultiLineComment", "SingleLineComment",
"MULT", "MOD", "DIV", "ADD", "SUB", "ASSIGN", "LPAREN", "RPAREN", "COLON",
"INT", "DEC", "BOOL", "STR"
"HASH", "INT", "DEC", "BOOL", "STR", "TYPE"
};
public static readonly IVocabulary DefaultVocabulary = new Vocabulary(_LiteralNames, _SymbolicNames);
@ -98,49 +98,52 @@ public partial class Waifu2Lexer : Lexer {
}
}
private static int[] _serializedATN = {
4,0,19,136,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,
4,0,21,145,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,1,0,1,
0,1,1,1,1,1,2,1,2,1,3,1,3,3,3,52,8,3,1,3,1,3,1,3,5,3,57,8,3,10,3,12,3,
60,9,3,1,4,1,4,1,5,1,5,1,5,1,5,1,5,5,5,69,8,5,10,5,12,5,72,9,5,1,5,1,5,
1,5,1,5,1,5,1,6,1,6,5,6,81,8,6,10,6,12,6,84,9,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,12,1,13,1,13,1,14,1,14,1,15,
1,15,1,16,1,16,1,17,4,17,110,8,17,11,17,12,17,111,1,18,5,18,115,8,18,10,
18,12,18,118,9,18,1,18,1,18,4,18,122,8,18,11,18,12,18,123,1,19,1,19,1,
20,1,20,5,20,130,8,20,10,20,12,20,133,9,20,1,20,1,20,2,70,131,0,21,1,1,
3,2,5,3,7,4,9,0,11,5,13,6,15,7,17,8,19,9,21,10,23,11,25,12,27,13,29,14,
31,15,33,0,35,16,37,17,39,18,41,19,1,0,4,2,0,65,90,97,122,1,0,10,10,1,
0,48,57,1,0,48,49,144,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,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,
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,1,0,1,0,1,1,1,1,1,2,1,2,3,2,54,8,2,1,2,1,2,1,2,5,2,59,8,
2,10,2,12,2,62,9,2,1,3,1,3,1,3,1,4,1,4,1,5,1,5,1,5,1,5,1,5,5,5,74,8,5,
10,5,12,5,77,9,5,1,5,1,5,1,5,1,6,1,6,5,6,84,8,6,10,6,12,6,87,9,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,12,1,13,1,13,1,14,1,
14,1,15,1,15,1,16,1,16,1,17,1,17,1,18,4,18,113,8,18,11,18,12,18,114,1,
19,5,19,118,8,19,10,19,12,19,121,9,19,1,19,1,19,4,19,125,8,19,11,19,12,
19,126,1,20,1,20,1,21,1,21,5,21,133,8,21,10,21,12,21,136,9,21,1,21,1,21,
1,22,1,22,4,22,142,8,22,11,22,12,22,143,3,75,134,143,0,23,1,1,3,2,5,3,
7,4,9,0,11,5,13,6,15,7,17,8,19,9,21,10,23,11,25,12,27,13,29,14,31,15,33,
16,35,0,37,17,39,18,41,19,43,20,45,21,1,0,4,2,0,65,90,97,122,1,0,10,10,
1,0,48,57,1,0,48,49,154,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,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,35,1,0,0,0,0,37,1,0,0,0,0,39,1,0,0,0,0,41,1,0,0,0,1,43,1,0,0,0,3,45,
1,0,0,0,5,47,1,0,0,0,7,51,1,0,0,0,9,61,1,0,0,0,11,63,1,0,0,0,13,78,1,0,
0,0,15,87,1,0,0,0,17,89,1,0,0,0,19,91,1,0,0,0,21,93,1,0,0,0,23,95,1,0,
0,0,25,97,1,0,0,0,27,100,1,0,0,0,29,102,1,0,0,0,31,104,1,0,0,0,33,106,
1,0,0,0,35,109,1,0,0,0,37,116,1,0,0,0,39,125,1,0,0,0,41,127,1,0,0,0,43,
44,5,35,0,0,44,2,1,0,0,0,45,46,5,32,0,0,46,4,1,0,0,0,47,48,5,10,0,0,48,
6,1,0,0,0,49,52,3,9,4,0,50,52,5,95,0,0,51,49,1,0,0,0,51,50,1,0,0,0,52,
58,1,0,0,0,53,57,3,9,4,0,54,57,5,95,0,0,55,57,3,33,16,0,56,53,1,0,0,0,
56,54,1,0,0,0,56,55,1,0,0,0,57,60,1,0,0,0,58,56,1,0,0,0,58,59,1,0,0,0,
59,8,1,0,0,0,60,58,1,0,0,0,61,62,7,0,0,0,62,10,1,0,0,0,63,64,5,35,0,0,
64,65,5,35,0,0,65,70,1,0,0,0,66,69,3,11,5,0,67,69,9,0,0,0,68,66,1,0,0,
0,68,67,1,0,0,0,69,72,1,0,0,0,70,71,1,0,0,0,70,68,1,0,0,0,71,73,1,0,0,
0,72,70,1,0,0,0,73,74,5,35,0,0,74,75,5,35,0,0,75,76,1,0,0,0,76,77,6,5,
0,0,77,12,1,0,0,0,78,82,5,35,0,0,79,81,8,1,0,0,80,79,1,0,0,0,81,84,1,0,
0,0,82,80,1,0,0,0,82,83,1,0,0,0,83,85,1,0,0,0,84,82,1,0,0,0,85,86,6,6,
0,0,86,14,1,0,0,0,87,88,5,42,0,0,88,16,1,0,0,0,89,90,5,37,0,0,90,18,1,
0,0,0,91,92,5,47,0,0,92,20,1,0,0,0,93,94,5,43,0,0,94,22,1,0,0,0,95,96,
5,45,0,0,96,24,1,0,0,0,97,98,5,60,0,0,98,99,5,45,0,0,99,26,1,0,0,0,100,
101,5,40,0,0,101,28,1,0,0,0,102,103,5,41,0,0,103,30,1,0,0,0,104,105,5,
58,0,0,105,32,1,0,0,0,106,107,7,2,0,0,107,34,1,0,0,0,108,110,3,33,16,0,
109,108,1,0,0,0,110,111,1,0,0,0,111,109,1,0,0,0,111,112,1,0,0,0,112,36,
1,0,0,0,113,115,3,33,16,0,114,113,1,0,0,0,115,118,1,0,0,0,116,114,1,0,
0,0,116,117,1,0,0,0,117,119,1,0,0,0,118,116,1,0,0,0,119,121,5,46,0,0,120,
122,3,33,16,0,121,120,1,0,0,0,122,123,1,0,0,0,123,121,1,0,0,0,123,124,
1,0,0,0,124,38,1,0,0,0,125,126,7,3,0,0,126,40,1,0,0,0,127,131,5,39,0,0,
128,130,9,0,0,0,129,128,1,0,0,0,130,133,1,0,0,0,131,132,1,0,0,0,131,129,
1,0,0,0,132,134,1,0,0,0,133,131,1,0,0,0,134,135,5,39,0,0,135,42,1,0,0,
0,11,0,51,56,58,68,70,82,111,116,123,131,1,0,1,0
0,0,33,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,1,47,1,0,0,0,3,49,1,0,0,0,5,53,1,0,0,0,7,63,1,0,0,0,9,66,1,0,0,
0,11,68,1,0,0,0,13,81,1,0,0,0,15,88,1,0,0,0,17,90,1,0,0,0,19,92,1,0,0,
0,21,94,1,0,0,0,23,96,1,0,0,0,25,98,1,0,0,0,27,101,1,0,0,0,29,103,1,0,
0,0,31,105,1,0,0,0,33,107,1,0,0,0,35,109,1,0,0,0,37,112,1,0,0,0,39,119,
1,0,0,0,41,128,1,0,0,0,43,130,1,0,0,0,45,139,1,0,0,0,47,48,5,32,0,0,48,
2,1,0,0,0,49,50,5,10,0,0,50,4,1,0,0,0,51,54,3,9,4,0,52,54,5,95,0,0,53,
51,1,0,0,0,53,52,1,0,0,0,54,60,1,0,0,0,55,59,3,9,4,0,56,59,5,95,0,0,57,
59,3,35,17,0,58,55,1,0,0,0,58,56,1,0,0,0,58,57,1,0,0,0,59,62,1,0,0,0,60,
58,1,0,0,0,60,61,1,0,0,0,61,6,1,0,0,0,62,60,1,0,0,0,63,64,5,32,0,0,64,
65,5,32,0,0,65,8,1,0,0,0,66,67,7,0,0,0,67,10,1,0,0,0,68,69,5,35,0,0,69,
70,5,35,0,0,70,75,1,0,0,0,71,74,3,11,5,0,72,74,9,0,0,0,73,71,1,0,0,0,73,
72,1,0,0,0,74,77,1,0,0,0,75,76,1,0,0,0,75,73,1,0,0,0,76,78,1,0,0,0,77,
75,1,0,0,0,78,79,5,35,0,0,79,80,5,35,0,0,80,12,1,0,0,0,81,85,5,35,0,0,
82,84,8,1,0,0,83,82,1,0,0,0,84,87,1,0,0,0,85,83,1,0,0,0,85,86,1,0,0,0,
86,14,1,0,0,0,87,85,1,0,0,0,88,89,5,42,0,0,89,16,1,0,0,0,90,91,5,37,0,
0,91,18,1,0,0,0,92,93,5,47,0,0,93,20,1,0,0,0,94,95,5,43,0,0,95,22,1,0,
0,0,96,97,5,45,0,0,97,24,1,0,0,0,98,99,5,60,0,0,99,100,5,45,0,0,100,26,
1,0,0,0,101,102,5,40,0,0,102,28,1,0,0,0,103,104,5,41,0,0,104,30,1,0,0,
0,105,106,5,58,0,0,106,32,1,0,0,0,107,108,5,35,0,0,108,34,1,0,0,0,109,
110,7,2,0,0,110,36,1,0,0,0,111,113,3,35,17,0,112,111,1,0,0,0,113,114,1,
0,0,0,114,112,1,0,0,0,114,115,1,0,0,0,115,38,1,0,0,0,116,118,3,35,17,0,
117,116,1,0,0,0,118,121,1,0,0,0,119,117,1,0,0,0,119,120,1,0,0,0,120,122,
1,0,0,0,121,119,1,0,0,0,122,124,5,46,0,0,123,125,3,35,17,0,124,123,1,0,
0,0,125,126,1,0,0,0,126,124,1,0,0,0,126,127,1,0,0,0,127,40,1,0,0,0,128,
129,7,3,0,0,129,42,1,0,0,0,130,134,5,39,0,0,131,133,9,0,0,0,132,131,1,
0,0,0,133,136,1,0,0,0,134,135,1,0,0,0,134,132,1,0,0,0,135,137,1,0,0,0,
136,134,1,0,0,0,137,138,5,39,0,0,138,44,1,0,0,0,139,141,3,31,15,0,140,
142,9,0,0,0,141,140,1,0,0,0,142,143,1,0,0,0,143,144,1,0,0,0,143,141,1,
0,0,0,144,46,1,0,0,0,12,0,53,58,60,73,75,85,114,119,126,134,143,0
};
public static readonly ATN _ATN =

View File

@ -1,9 +1,9 @@
token literal names:
null
'#'
' '
'\u000A'
'\n'
null
' '
null
null
'*'
@ -15,6 +15,8 @@ null
'('
')'
':'
'#'
null
null
null
null
@ -22,10 +24,10 @@ null
token symbolic names:
null
null
WS
NL
ID
INDENT
MultiLineComment
SingleLineComment
MULT
@ -37,16 +39,18 @@ ASSIGN
LPAREN
RPAREN
COLON
HASH
INT
DEC
BOOL
STR
TYPE
rule names:
T__0
WS
NL
ID
INDENT
Letter
MultiLineComment
SingleLineComment
@ -59,11 +63,13 @@ ASSIGN
LPAREN
RPAREN
COLON
HASH
DEC_DIGIT
INT
DEC
BOOL
STR
TYPE
channel names:
DEFAULT_TOKEN_CHANNEL
@ -73,4 +79,4 @@ mode names:
DEFAULT_MODE
atn:
[4, 0, 19, 136, 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, 1, 0, 1, 0, 1, 1, 1, 1, 1, 2, 1, 2, 1, 3, 1, 3, 3, 3, 52, 8, 3, 1, 3, 1, 3, 1, 3, 5, 3, 57, 8, 3, 10, 3, 12, 3, 60, 9, 3, 1, 4, 1, 4, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 5, 5, 69, 8, 5, 10, 5, 12, 5, 72, 9, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 6, 1, 6, 5, 6, 81, 8, 6, 10, 6, 12, 6, 84, 9, 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, 12, 1, 13, 1, 13, 1, 14, 1, 14, 1, 15, 1, 15, 1, 16, 1, 16, 1, 17, 4, 17, 110, 8, 17, 11, 17, 12, 17, 111, 1, 18, 5, 18, 115, 8, 18, 10, 18, 12, 18, 118, 9, 18, 1, 18, 1, 18, 4, 18, 122, 8, 18, 11, 18, 12, 18, 123, 1, 19, 1, 19, 1, 20, 1, 20, 5, 20, 130, 8, 20, 10, 20, 12, 20, 133, 9, 20, 1, 20, 1, 20, 2, 70, 131, 0, 21, 1, 1, 3, 2, 5, 3, 7, 4, 9, 0, 11, 5, 13, 6, 15, 7, 17, 8, 19, 9, 21, 10, 23, 11, 25, 12, 27, 13, 29, 14, 31, 15, 33, 0, 35, 16, 37, 17, 39, 18, 41, 19, 1, 0, 4, 2, 0, 65, 90, 97, 122, 1, 0, 10, 10, 1, 0, 48, 57, 1, 0, 48, 49, 144, 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, 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, 35, 1, 0, 0, 0, 0, 37, 1, 0, 0, 0, 0, 39, 1, 0, 0, 0, 0, 41, 1, 0, 0, 0, 1, 43, 1, 0, 0, 0, 3, 45, 1, 0, 0, 0, 5, 47, 1, 0, 0, 0, 7, 51, 1, 0, 0, 0, 9, 61, 1, 0, 0, 0, 11, 63, 1, 0, 0, 0, 13, 78, 1, 0, 0, 0, 15, 87, 1, 0, 0, 0, 17, 89, 1, 0, 0, 0, 19, 91, 1, 0, 0, 0, 21, 93, 1, 0, 0, 0, 23, 95, 1, 0, 0, 0, 25, 97, 1, 0, 0, 0, 27, 100, 1, 0, 0, 0, 29, 102, 1, 0, 0, 0, 31, 104, 1, 0, 0, 0, 33, 106, 1, 0, 0, 0, 35, 109, 1, 0, 0, 0, 37, 116, 1, 0, 0, 0, 39, 125, 1, 0, 0, 0, 41, 127, 1, 0, 0, 0, 43, 44, 5, 35, 0, 0, 44, 2, 1, 0, 0, 0, 45, 46, 5, 32, 0, 0, 46, 4, 1, 0, 0, 0, 47, 48, 5, 10, 0, 0, 48, 6, 1, 0, 0, 0, 49, 52, 3, 9, 4, 0, 50, 52, 5, 95, 0, 0, 51, 49, 1, 0, 0, 0, 51, 50, 1, 0, 0, 0, 52, 58, 1, 0, 0, 0, 53, 57, 3, 9, 4, 0, 54, 57, 5, 95, 0, 0, 55, 57, 3, 33, 16, 0, 56, 53, 1, 0, 0, 0, 56, 54, 1, 0, 0, 0, 56, 55, 1, 0, 0, 0, 57, 60, 1, 0, 0, 0, 58, 56, 1, 0, 0, 0, 58, 59, 1, 0, 0, 0, 59, 8, 1, 0, 0, 0, 60, 58, 1, 0, 0, 0, 61, 62, 7, 0, 0, 0, 62, 10, 1, 0, 0, 0, 63, 64, 5, 35, 0, 0, 64, 65, 5, 35, 0, 0, 65, 70, 1, 0, 0, 0, 66, 69, 3, 11, 5, 0, 67, 69, 9, 0, 0, 0, 68, 66, 1, 0, 0, 0, 68, 67, 1, 0, 0, 0, 69, 72, 1, 0, 0, 0, 70, 71, 1, 0, 0, 0, 70, 68, 1, 0, 0, 0, 71, 73, 1, 0, 0, 0, 72, 70, 1, 0, 0, 0, 73, 74, 5, 35, 0, 0, 74, 75, 5, 35, 0, 0, 75, 76, 1, 0, 0, 0, 76, 77, 6, 5, 0, 0, 77, 12, 1, 0, 0, 0, 78, 82, 5, 35, 0, 0, 79, 81, 8, 1, 0, 0, 80, 79, 1, 0, 0, 0, 81, 84, 1, 0, 0, 0, 82, 80, 1, 0, 0, 0, 82, 83, 1, 0, 0, 0, 83, 85, 1, 0, 0, 0, 84, 82, 1, 0, 0, 0, 85, 86, 6, 6, 0, 0, 86, 14, 1, 0, 0, 0, 87, 88, 5, 42, 0, 0, 88, 16, 1, 0, 0, 0, 89, 90, 5, 37, 0, 0, 90, 18, 1, 0, 0, 0, 91, 92, 5, 47, 0, 0, 92, 20, 1, 0, 0, 0, 93, 94, 5, 43, 0, 0, 94, 22, 1, 0, 0, 0, 95, 96, 5, 45, 0, 0, 96, 24, 1, 0, 0, 0, 97, 98, 5, 60, 0, 0, 98, 99, 5, 45, 0, 0, 99, 26, 1, 0, 0, 0, 100, 101, 5, 40, 0, 0, 101, 28, 1, 0, 0, 0, 102, 103, 5, 41, 0, 0, 103, 30, 1, 0, 0, 0, 104, 105, 5, 58, 0, 0, 105, 32, 1, 0, 0, 0, 106, 107, 7, 2, 0, 0, 107, 34, 1, 0, 0, 0, 108, 110, 3, 33, 16, 0, 109, 108, 1, 0, 0, 0, 110, 111, 1, 0, 0, 0, 111, 109, 1, 0, 0, 0, 111, 112, 1, 0, 0, 0, 112, 36, 1, 0, 0, 0, 113, 115, 3, 33, 16, 0, 114, 113, 1, 0, 0, 0, 115, 118, 1, 0, 0, 0, 116, 114, 1, 0, 0, 0, 116, 117, 1, 0, 0, 0, 117, 119, 1, 0, 0, 0, 118, 116, 1, 0, 0, 0, 119, 121, 5, 46, 0, 0, 120, 122, 3, 33, 16, 0, 121, 120, 1, 0, 0, 0, 122, 123, 1, 0, 0, 0, 123, 121, 1, 0, 0, 0, 123, 124, 1, 0, 0, 0, 124, 38, 1, 0, 0, 0, 125, 126, 7, 3, 0, 0, 126, 40, 1, 0, 0, 0, 127, 131, 5, 39, 0, 0, 128, 130, 9, 0, 0, 0, 129, 128, 1, 0, 0, 0, 130, 133, 1, 0, 0, 0, 131, 132, 1, 0, 0, 0, 131, 129, 1, 0, 0, 0, 132, 134, 1, 0, 0, 0, 133, 131, 1, 0, 0, 0, 134, 135, 5, 39, 0, 0, 135, 42, 1, 0, 0, 0, 11, 0, 51, 56, 58, 68, 70, 82, 111, 116, 123, 131, 1, 0, 1, 0]
[4, 0, 21, 145, 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, 1, 0, 1, 0, 1, 1, 1, 1, 1, 2, 1, 2, 3, 2, 54, 8, 2, 1, 2, 1, 2, 1, 2, 5, 2, 59, 8, 2, 10, 2, 12, 2, 62, 9, 2, 1, 3, 1, 3, 1, 3, 1, 4, 1, 4, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 5, 5, 74, 8, 5, 10, 5, 12, 5, 77, 9, 5, 1, 5, 1, 5, 1, 5, 1, 6, 1, 6, 5, 6, 84, 8, 6, 10, 6, 12, 6, 87, 9, 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, 12, 1, 13, 1, 13, 1, 14, 1, 14, 1, 15, 1, 15, 1, 16, 1, 16, 1, 17, 1, 17, 1, 18, 4, 18, 113, 8, 18, 11, 18, 12, 18, 114, 1, 19, 5, 19, 118, 8, 19, 10, 19, 12, 19, 121, 9, 19, 1, 19, 1, 19, 4, 19, 125, 8, 19, 11, 19, 12, 19, 126, 1, 20, 1, 20, 1, 21, 1, 21, 5, 21, 133, 8, 21, 10, 21, 12, 21, 136, 9, 21, 1, 21, 1, 21, 1, 22, 1, 22, 4, 22, 142, 8, 22, 11, 22, 12, 22, 143, 3, 75, 134, 143, 0, 23, 1, 1, 3, 2, 5, 3, 7, 4, 9, 0, 11, 5, 13, 6, 15, 7, 17, 8, 19, 9, 21, 10, 23, 11, 25, 12, 27, 13, 29, 14, 31, 15, 33, 16, 35, 0, 37, 17, 39, 18, 41, 19, 43, 20, 45, 21, 1, 0, 4, 2, 0, 65, 90, 97, 122, 1, 0, 10, 10, 1, 0, 48, 57, 1, 0, 48, 49, 154, 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, 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, 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, 1, 47, 1, 0, 0, 0, 3, 49, 1, 0, 0, 0, 5, 53, 1, 0, 0, 0, 7, 63, 1, 0, 0, 0, 9, 66, 1, 0, 0, 0, 11, 68, 1, 0, 0, 0, 13, 81, 1, 0, 0, 0, 15, 88, 1, 0, 0, 0, 17, 90, 1, 0, 0, 0, 19, 92, 1, 0, 0, 0, 21, 94, 1, 0, 0, 0, 23, 96, 1, 0, 0, 0, 25, 98, 1, 0, 0, 0, 27, 101, 1, 0, 0, 0, 29, 103, 1, 0, 0, 0, 31, 105, 1, 0, 0, 0, 33, 107, 1, 0, 0, 0, 35, 109, 1, 0, 0, 0, 37, 112, 1, 0, 0, 0, 39, 119, 1, 0, 0, 0, 41, 128, 1, 0, 0, 0, 43, 130, 1, 0, 0, 0, 45, 139, 1, 0, 0, 0, 47, 48, 5, 32, 0, 0, 48, 2, 1, 0, 0, 0, 49, 50, 5, 10, 0, 0, 50, 4, 1, 0, 0, 0, 51, 54, 3, 9, 4, 0, 52, 54, 5, 95, 0, 0, 53, 51, 1, 0, 0, 0, 53, 52, 1, 0, 0, 0, 54, 60, 1, 0, 0, 0, 55, 59, 3, 9, 4, 0, 56, 59, 5, 95, 0, 0, 57, 59, 3, 35, 17, 0, 58, 55, 1, 0, 0, 0, 58, 56, 1, 0, 0, 0, 58, 57, 1, 0, 0, 0, 59, 62, 1, 0, 0, 0, 60, 58, 1, 0, 0, 0, 60, 61, 1, 0, 0, 0, 61, 6, 1, 0, 0, 0, 62, 60, 1, 0, 0, 0, 63, 64, 5, 32, 0, 0, 64, 65, 5, 32, 0, 0, 65, 8, 1, 0, 0, 0, 66, 67, 7, 0, 0, 0, 67, 10, 1, 0, 0, 0, 68, 69, 5, 35, 0, 0, 69, 70, 5, 35, 0, 0, 70, 75, 1, 0, 0, 0, 71, 74, 3, 11, 5, 0, 72, 74, 9, 0, 0, 0, 73, 71, 1, 0, 0, 0, 73, 72, 1, 0, 0, 0, 74, 77, 1, 0, 0, 0, 75, 76, 1, 0, 0, 0, 75, 73, 1, 0, 0, 0, 76, 78, 1, 0, 0, 0, 77, 75, 1, 0, 0, 0, 78, 79, 5, 35, 0, 0, 79, 80, 5, 35, 0, 0, 80, 12, 1, 0, 0, 0, 81, 85, 5, 35, 0, 0, 82, 84, 8, 1, 0, 0, 83, 82, 1, 0, 0, 0, 84, 87, 1, 0, 0, 0, 85, 83, 1, 0, 0, 0, 85, 86, 1, 0, 0, 0, 86, 14, 1, 0, 0, 0, 87, 85, 1, 0, 0, 0, 88, 89, 5, 42, 0, 0, 89, 16, 1, 0, 0, 0, 90, 91, 5, 37, 0, 0, 91, 18, 1, 0, 0, 0, 92, 93, 5, 47, 0, 0, 93, 20, 1, 0, 0, 0, 94, 95, 5, 43, 0, 0, 95, 22, 1, 0, 0, 0, 96, 97, 5, 45, 0, 0, 97, 24, 1, 0, 0, 0, 98, 99, 5, 60, 0, 0, 99, 100, 5, 45, 0, 0, 100, 26, 1, 0, 0, 0, 101, 102, 5, 40, 0, 0, 102, 28, 1, 0, 0, 0, 103, 104, 5, 41, 0, 0, 104, 30, 1, 0, 0, 0, 105, 106, 5, 58, 0, 0, 106, 32, 1, 0, 0, 0, 107, 108, 5, 35, 0, 0, 108, 34, 1, 0, 0, 0, 109, 110, 7, 2, 0, 0, 110, 36, 1, 0, 0, 0, 111, 113, 3, 35, 17, 0, 112, 111, 1, 0, 0, 0, 113, 114, 1, 0, 0, 0, 114, 112, 1, 0, 0, 0, 114, 115, 1, 0, 0, 0, 115, 38, 1, 0, 0, 0, 116, 118, 3, 35, 17, 0, 117, 116, 1, 0, 0, 0, 118, 121, 1, 0, 0, 0, 119, 117, 1, 0, 0, 0, 119, 120, 1, 0, 0, 0, 120, 122, 1, 0, 0, 0, 121, 119, 1, 0, 0, 0, 122, 124, 5, 46, 0, 0, 123, 125, 3, 35, 17, 0, 124, 123, 1, 0, 0, 0, 125, 126, 1, 0, 0, 0, 126, 124, 1, 0, 0, 0, 126, 127, 1, 0, 0, 0, 127, 40, 1, 0, 0, 0, 128, 129, 7, 3, 0, 0, 129, 42, 1, 0, 0, 0, 130, 134, 5, 39, 0, 0, 131, 133, 9, 0, 0, 0, 132, 131, 1, 0, 0, 0, 133, 136, 1, 0, 0, 0, 134, 135, 1, 0, 0, 0, 134, 132, 1, 0, 0, 0, 135, 137, 1, 0, 0, 0, 136, 134, 1, 0, 0, 0, 137, 138, 5, 39, 0, 0, 138, 44, 1, 0, 0, 0, 139, 141, 3, 31, 15, 0, 140, 142, 9, 0, 0, 0, 141, 140, 1, 0, 0, 0, 142, 143, 1, 0, 0, 0, 143, 144, 1, 0, 0, 0, 143, 141, 1, 0, 0, 0, 144, 46, 1, 0, 0, 0, 12, 0, 53, 58, 60, 73, 75, 85, 114, 119, 126, 134, 143, 0]

View File

@ -1,7 +1,7 @@
T__0=1
WS=2
NL=3
ID=4
WS=1
NL=2
ID=3
INDENT=4
MultiLineComment=5
SingleLineComment=6
MULT=7
@ -13,13 +13,15 @@ ASSIGN=12
LPAREN=13
RPAREN=14
COLON=15
INT=16
DEC=17
BOOL=18
STR=19
'#'=1
' '=2
'\u000A'=3
HASH=16
INT=17
DEC=18
BOOL=19
STR=20
TYPE=21
' '=1
'\n'=2
' '=4
'*'=7
'%'=8
'/'=9
@ -29,3 +31,4 @@ STR=19
'('=13
')'=14
':'=15
'#'=16

View File

@ -31,6 +31,16 @@ using IToken = Antlr4.Runtime.IToken;
[System.CodeDom.Compiler.GeneratedCode("ANTLR", "4.10.1")]
[System.CLSCompliant(false)]
public interface IWaifu2Listener : IParseTreeListener {
/// <summary>
/// Enter a parse tree produced by <see cref="Waifu2Parser.num"/>.
/// </summary>
/// <param name="context">The parse tree.</param>
void EnterNum([NotNull] Waifu2Parser.NumContext context);
/// <summary>
/// Exit a parse tree produced by <see cref="Waifu2Parser.num"/>.
/// </summary>
/// <param name="context">The parse tree.</param>
void ExitNum([NotNull] Waifu2Parser.NumContext context);
/// <summary>
/// Enter a parse tree produced by <see cref="Waifu2Parser.waifuFile"/>.
/// </summary>
@ -42,16 +52,6 @@ public interface IWaifu2Listener : IParseTreeListener {
/// <param name="context">The parse tree.</param>
void ExitWaifuFile([NotNull] Waifu2Parser.WaifuFileContext context);
/// <summary>
/// Enter a parse tree produced by <see cref="Waifu2Parser.type"/>.
/// </summary>
/// <param name="context">The parse tree.</param>
void EnterType([NotNull] Waifu2Parser.TypeContext context);
/// <summary>
/// Exit a parse tree produced by <see cref="Waifu2Parser.type"/>.
/// </summary>
/// <param name="context">The parse tree.</param>
void ExitType([NotNull] Waifu2Parser.TypeContext context);
/// <summary>
/// Enter a parse tree produced by <see cref="Waifu2Parser.sign"/>.
/// </summary>
/// <param name="context">The parse tree.</param>
@ -62,6 +62,16 @@ public interface IWaifu2Listener : IParseTreeListener {
/// <param name="context">The parse tree.</param>
void ExitSign([NotNull] Waifu2Parser.SignContext context);
/// <summary>
/// Enter a parse tree produced by <see cref="Waifu2Parser.value"/>.
/// </summary>
/// <param name="context">The parse tree.</param>
void EnterValue([NotNull] Waifu2Parser.ValueContext context);
/// <summary>
/// Exit a parse tree produced by <see cref="Waifu2Parser.value"/>.
/// </summary>
/// <param name="context">The parse tree.</param>
void ExitValue([NotNull] Waifu2Parser.ValueContext context);
/// <summary>
/// Enter a parse tree produced by <see cref="Waifu2Parser.operator"/>.
/// </summary>
/// <param name="context">The parse tree.</param>
@ -122,6 +132,16 @@ public interface IWaifu2Listener : IParseTreeListener {
/// <param name="context">The parse tree.</param>
void ExitFunctionBody([NotNull] Waifu2Parser.FunctionBodyContext context);
/// <summary>
/// Enter a parse tree produced by <see cref="Waifu2Parser.functionCall"/>.
/// </summary>
/// <param name="context">The parse tree.</param>
void EnterFunctionCall([NotNull] Waifu2Parser.FunctionCallContext context);
/// <summary>
/// Exit a parse tree produced by <see cref="Waifu2Parser.functionCall"/>.
/// </summary>
/// <param name="context">The parse tree.</param>
void ExitFunctionCall([NotNull] Waifu2Parser.FunctionCallContext context);
/// <summary>
/// Enter a parse tree produced by <see cref="Waifu2Parser.expr"/>.
/// </summary>
/// <param name="context">The parse tree.</param>

View File

@ -37,26 +37,26 @@ public partial class Waifu2Parser : Parser {
protected static DFA[] decisionToDFA;
protected static PredictionContextCache sharedContextCache = new PredictionContextCache();
public const int
T__0=1, WS=2, NL=3, ID=4, MultiLineComment=5, SingleLineComment=6, MULT=7,
WS=1, NL=2, ID=3, INDENT=4, MultiLineComment=5, SingleLineComment=6, MULT=7,
MOD=8, DIV=9, ADD=10, SUB=11, ASSIGN=12, LPAREN=13, RPAREN=14, COLON=15,
INT=16, DEC=17, BOOL=18, STR=19;
HASH=16, INT=17, DEC=18, BOOL=19, STR=20, TYPE=21;
public const int
RULE_waifuFile = 0, RULE_type = 1, RULE_sign = 2, RULE_operator = 3, RULE_literal = 4,
RULE_func = 5, RULE_functionDeclaration = 6, RULE_functionParam = 7, RULE_functionBody = 8,
RULE_expr = 9;
RULE_num = 0, RULE_waifuFile = 1, RULE_sign = 2, RULE_value = 3, RULE_operator = 4,
RULE_literal = 5, RULE_func = 6, RULE_functionDeclaration = 7, RULE_functionParam = 8,
RULE_functionBody = 9, RULE_functionCall = 10, RULE_expr = 11;
public static readonly string[] ruleNames = {
"waifuFile", "type", "sign", "operator", "literal", "func", "functionDeclaration",
"functionParam", "functionBody", "expr"
"num", "waifuFile", "sign", "value", "operator", "literal", "func", "functionDeclaration",
"functionParam", "functionBody", "functionCall", "expr"
};
private static readonly string[] _LiteralNames = {
null, "'#'", "' '", "'\\u000A'", null, null, null, "'*'", "'%'", "'/'",
"'+'", "'-'", "'<-'", "'('", "')'", "':'"
null, "' '", "'\\n'", null, "' '", null, null, "'*'", "'%'", "'/'", "'+'",
"'-'", "'<-'", "'('", "')'", "':'", "'#'"
};
private static readonly string[] _SymbolicNames = {
null, null, "WS", "NL", "ID", "MultiLineComment", "SingleLineComment",
null, "WS", "NL", "ID", "INDENT", "MultiLineComment", "SingleLineComment",
"MULT", "MOD", "DIV", "ADD", "SUB", "ASSIGN", "LPAREN", "RPAREN", "COLON",
"INT", "DEC", "BOOL", "STR"
"HASH", "INT", "DEC", "BOOL", "STR", "TYPE"
};
public static readonly IVocabulary DefaultVocabulary = new Vocabulary(_LiteralNames, _SymbolicNames);
@ -90,6 +90,63 @@ public partial class Waifu2Parser : Parser {
Interpreter = new ParserATNSimulator(this, _ATN, decisionToDFA, sharedContextCache);
}
public partial class NumContext : ParserRuleContext {
[System.Diagnostics.DebuggerNonUserCode] public ITerminalNode INT() { return GetToken(Waifu2Parser.INT, 0); }
[System.Diagnostics.DebuggerNonUserCode] public ITerminalNode DEC() { return GetToken(Waifu2Parser.DEC, 0); }
[System.Diagnostics.DebuggerNonUserCode] public ITerminalNode BOOL() { return GetToken(Waifu2Parser.BOOL, 0); }
public NumContext(ParserRuleContext parent, int invokingState)
: base(parent, invokingState)
{
}
public override int RuleIndex { get { return RULE_num; } }
[System.Diagnostics.DebuggerNonUserCode]
public override void EnterRule(IParseTreeListener listener) {
IWaifu2Listener typedListener = listener as IWaifu2Listener;
if (typedListener != null) typedListener.EnterNum(this);
}
[System.Diagnostics.DebuggerNonUserCode]
public override void ExitRule(IParseTreeListener listener) {
IWaifu2Listener typedListener = listener as IWaifu2Listener;
if (typedListener != null) typedListener.ExitNum(this);
}
[System.Diagnostics.DebuggerNonUserCode]
public override TResult Accept<TResult>(IParseTreeVisitor<TResult> visitor) {
IWaifu2Visitor<TResult> typedVisitor = visitor as IWaifu2Visitor<TResult>;
if (typedVisitor != null) return typedVisitor.VisitNum(this);
else return visitor.VisitChildren(this);
}
}
[RuleVersion(0)]
public NumContext num() {
NumContext _localctx = new NumContext(Context, State);
EnterRule(_localctx, 0, RULE_num);
int _la;
try {
EnterOuterAlt(_localctx, 1);
{
State = 24;
_la = TokenStream.LA(1);
if ( !((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << INT) | (1L << DEC) | (1L << BOOL))) != 0)) ) {
ErrorHandler.RecoverInline(this);
}
else {
ErrorHandler.ReportMatch(this);
Consume();
}
}
}
catch (RecognitionException re) {
_localctx.exception = re;
ErrorHandler.ReportError(this, re);
ErrorHandler.Recover(this, re);
}
finally {
ExitRule();
}
return _localctx;
}
public partial class WaifuFileContext : ParserRuleContext {
[System.Diagnostics.DebuggerNonUserCode] public ITerminalNode Eof() { return GetToken(Waifu2Parser.Eof, 0); }
[System.Diagnostics.DebuggerNonUserCode] public ITerminalNode[] NL() { return GetTokens(Waifu2Parser.NL); }
@ -128,107 +185,58 @@ public partial class Waifu2Parser : Parser {
[RuleVersion(0)]
public WaifuFileContext waifuFile() {
WaifuFileContext _localctx = new WaifuFileContext(Context, State);
EnterRule(_localctx, 0, RULE_waifuFile);
EnterRule(_localctx, 2, RULE_waifuFile);
int _la;
try {
int _alt;
EnterOuterAlt(_localctx, 1);
{
State = 23;
State = 29;
ErrorHandler.Sync(this);
_alt = Interpreter.AdaptivePredict(TokenStream,0,Context);
while ( _alt!=2 && _alt!=global::Antlr4.Runtime.Atn.ATN.INVALID_ALT_NUMBER ) {
if ( _alt==1 ) {
{
{
State = 20;
State = 26;
Match(NL);
}
}
}
State = 25;
State = 31;
ErrorHandler.Sync(this);
_alt = Interpreter.AdaptivePredict(TokenStream,0,Context);
}
State = 29;
State = 35;
ErrorHandler.Sync(this);
_la = TokenStream.LA(1);
while (_la==LPAREN) {
{
{
State = 26;
func();
}
}
State = 31;
ErrorHandler.Sync(this);
_la = TokenStream.LA(1);
}
State = 35;
ErrorHandler.Sync(this);
_la = TokenStream.LA(1);
while (_la==NL) {
{
{
State = 32;
Match(NL);
func();
}
}
State = 37;
ErrorHandler.Sync(this);
_la = TokenStream.LA(1);
}
State = 38;
Match(Eof);
}
}
catch (RecognitionException re) {
_localctx.exception = re;
ErrorHandler.ReportError(this, re);
ErrorHandler.Recover(this, re);
}
finally {
ExitRule();
}
return _localctx;
}
public partial class TypeContext : ParserRuleContext {
[System.Diagnostics.DebuggerNonUserCode] public ITerminalNode COLON() { return GetToken(Waifu2Parser.COLON, 0); }
public TypeContext(ParserRuleContext parent, int invokingState)
: base(parent, invokingState)
{
}
public override int RuleIndex { get { return RULE_type; } }
[System.Diagnostics.DebuggerNonUserCode]
public override void EnterRule(IParseTreeListener listener) {
IWaifu2Listener typedListener = listener as IWaifu2Listener;
if (typedListener != null) typedListener.EnterType(this);
}
[System.Diagnostics.DebuggerNonUserCode]
public override void ExitRule(IParseTreeListener listener) {
IWaifu2Listener typedListener = listener as IWaifu2Listener;
if (typedListener != null) typedListener.ExitType(this);
}
[System.Diagnostics.DebuggerNonUserCode]
public override TResult Accept<TResult>(IParseTreeVisitor<TResult> visitor) {
IWaifu2Visitor<TResult> typedVisitor = visitor as IWaifu2Visitor<TResult>;
if (typedVisitor != null) return typedVisitor.VisitType(this);
else return visitor.VisitChildren(this);
}
}
[RuleVersion(0)]
public TypeContext type() {
TypeContext _localctx = new TypeContext(Context, State);
EnterRule(_localctx, 2, RULE_type);
try {
EnterOuterAlt(_localctx, 1);
{
State = 40;
Match(COLON);
State = 41;
Match(T__0);
ErrorHandler.Sync(this);
_la = TokenStream.LA(1);
while (_la==NL) {
{
{
State = 38;
Match(NL);
}
}
State = 43;
ErrorHandler.Sync(this);
_la = TokenStream.LA(1);
}
State = 44;
Match(Eof);
}
}
catch (RecognitionException re) {
@ -276,7 +284,7 @@ public partial class Waifu2Parser : Parser {
try {
EnterOuterAlt(_localctx, 1);
{
State = 43;
State = 46;
_la = TokenStream.LA(1);
if ( !(_la==ADD || _la==SUB) ) {
ErrorHandler.RecoverInline(this);
@ -298,6 +306,64 @@ public partial class Waifu2Parser : Parser {
return _localctx;
}
public partial class ValueContext : ParserRuleContext {
[System.Diagnostics.DebuggerNonUserCode] public ITerminalNode DEC() { return GetToken(Waifu2Parser.DEC, 0); }
[System.Diagnostics.DebuggerNonUserCode] public ITerminalNode INT() { return GetToken(Waifu2Parser.INT, 0); }
[System.Diagnostics.DebuggerNonUserCode] public ITerminalNode BOOL() { return GetToken(Waifu2Parser.BOOL, 0); }
[System.Diagnostics.DebuggerNonUserCode] public ITerminalNode STR() { return GetToken(Waifu2Parser.STR, 0); }
public ValueContext(ParserRuleContext parent, int invokingState)
: base(parent, invokingState)
{
}
public override int RuleIndex { get { return RULE_value; } }
[System.Diagnostics.DebuggerNonUserCode]
public override void EnterRule(IParseTreeListener listener) {
IWaifu2Listener typedListener = listener as IWaifu2Listener;
if (typedListener != null) typedListener.EnterValue(this);
}
[System.Diagnostics.DebuggerNonUserCode]
public override void ExitRule(IParseTreeListener listener) {
IWaifu2Listener typedListener = listener as IWaifu2Listener;
if (typedListener != null) typedListener.ExitValue(this);
}
[System.Diagnostics.DebuggerNonUserCode]
public override TResult Accept<TResult>(IParseTreeVisitor<TResult> visitor) {
IWaifu2Visitor<TResult> typedVisitor = visitor as IWaifu2Visitor<TResult>;
if (typedVisitor != null) return typedVisitor.VisitValue(this);
else return visitor.VisitChildren(this);
}
}
[RuleVersion(0)]
public ValueContext value() {
ValueContext _localctx = new ValueContext(Context, State);
EnterRule(_localctx, 6, RULE_value);
int _la;
try {
EnterOuterAlt(_localctx, 1);
{
State = 48;
_la = TokenStream.LA(1);
if ( !((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << INT) | (1L << DEC) | (1L << BOOL) | (1L << STR))) != 0)) ) {
ErrorHandler.RecoverInline(this);
}
else {
ErrorHandler.ReportMatch(this);
Consume();
}
}
}
catch (RecognitionException re) {
_localctx.exception = re;
ErrorHandler.ReportError(this, re);
ErrorHandler.Recover(this, re);
}
finally {
ExitRule();
}
return _localctx;
}
public partial class OperatorContext : ParserRuleContext {
[System.Diagnostics.DebuggerNonUserCode] public ITerminalNode SUB() { return GetToken(Waifu2Parser.SUB, 0); }
[System.Diagnostics.DebuggerNonUserCode] public ITerminalNode ADD() { return GetToken(Waifu2Parser.ADD, 0); }
@ -330,12 +396,12 @@ public partial class Waifu2Parser : Parser {
[RuleVersion(0)]
public OperatorContext @operator() {
OperatorContext _localctx = new OperatorContext(Context, State);
EnterRule(_localctx, 6, RULE_operator);
EnterRule(_localctx, 8, RULE_operator);
int _la;
try {
EnterOuterAlt(_localctx, 1);
{
State = 45;
State = 50;
_la = TokenStream.LA(1);
if ( !((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << MULT) | (1L << MOD) | (1L << DIV) | (1L << ADD) | (1L << SUB))) != 0)) ) {
ErrorHandler.RecoverInline(this);
@ -388,12 +454,12 @@ public partial class Waifu2Parser : Parser {
[RuleVersion(0)]
public LiteralContext literal() {
LiteralContext _localctx = new LiteralContext(Context, State);
EnterRule(_localctx, 8, RULE_literal);
EnterRule(_localctx, 10, RULE_literal);
int _la;
try {
EnterOuterAlt(_localctx, 1);
{
State = 47;
State = 52;
_la = TokenStream.LA(1);
if ( !((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << INT) | (1L << DEC) | (1L << BOOL) | (1L << STR))) != 0)) ) {
ErrorHandler.RecoverInline(this);
@ -449,15 +515,15 @@ public partial class Waifu2Parser : Parser {
[RuleVersion(0)]
public FuncContext func() {
FuncContext _localctx = new FuncContext(Context, State);
EnterRule(_localctx, 10, RULE_func);
EnterRule(_localctx, 12, RULE_func);
try {
EnterOuterAlt(_localctx, 1);
{
State = 49;
State = 54;
functionDeclaration();
State = 50;
State = 55;
Match(NL);
State = 51;
State = 56;
functionBody();
}
}
@ -474,19 +540,19 @@ public partial class Waifu2Parser : Parser {
public partial class FunctionDeclarationContext : ParserRuleContext {
[System.Diagnostics.DebuggerNonUserCode] public ITerminalNode LPAREN() { return GetToken(Waifu2Parser.LPAREN, 0); }
[System.Diagnostics.DebuggerNonUserCode] public FunctionParamContext functionParam() {
return GetRuleContext<FunctionParamContext>(0);
}
[System.Diagnostics.DebuggerNonUserCode] public ITerminalNode RPAREN() { return GetToken(Waifu2Parser.RPAREN, 0); }
[System.Diagnostics.DebuggerNonUserCode] public ITerminalNode[] WS() { return GetTokens(Waifu2Parser.WS); }
[System.Diagnostics.DebuggerNonUserCode] public ITerminalNode WS(int i) {
return GetToken(Waifu2Parser.WS, i);
}
[System.Diagnostics.DebuggerNonUserCode] public ITerminalNode ID() { return GetToken(Waifu2Parser.ID, 0); }
[System.Diagnostics.DebuggerNonUserCode] public ITerminalNode NL() { return GetToken(Waifu2Parser.NL, 0); }
[System.Diagnostics.DebuggerNonUserCode] public TypeContext type() {
return GetRuleContext<TypeContext>(0);
[System.Diagnostics.DebuggerNonUserCode] public FunctionParamContext[] functionParam() {
return GetRuleContexts<FunctionParamContext>();
}
[System.Diagnostics.DebuggerNonUserCode] public FunctionParamContext functionParam(int i) {
return GetRuleContext<FunctionParamContext>(i);
}
[System.Diagnostics.DebuggerNonUserCode] public ITerminalNode TYPE() { return GetToken(Waifu2Parser.TYPE, 0); }
public FunctionDeclarationContext(ParserRuleContext parent, int invokingState)
: base(parent, invokingState)
{
@ -513,35 +579,45 @@ public partial class Waifu2Parser : Parser {
[RuleVersion(0)]
public FunctionDeclarationContext functionDeclaration() {
FunctionDeclarationContext _localctx = new FunctionDeclarationContext(Context, State);
EnterRule(_localctx, 12, RULE_functionDeclaration);
EnterRule(_localctx, 14, RULE_functionDeclaration);
int _la;
try {
EnterOuterAlt(_localctx, 1);
{
State = 53;
Match(LPAREN);
State = 54;
functionParam();
State = 55;
Match(RPAREN);
State = 56;
Match(WS);
State = 58;
Match(LPAREN);
State = 62;
ErrorHandler.Sync(this);
_la = TokenStream.LA(1);
if (_la==COLON) {
while (_la==ID) {
{
State = 57;
type();
{
State = 59;
functionParam();
}
}
State = 64;
ErrorHandler.Sync(this);
_la = TokenStream.LA(1);
}
State = 60;
State = 65;
Match(RPAREN);
State = 68;
ErrorHandler.Sync(this);
switch ( Interpreter.AdaptivePredict(TokenStream,4,Context) ) {
case 1:
{
State = 66;
Match(WS);
State = 67;
Match(TYPE);
}
break;
}
State = 70;
Match(WS);
State = 61;
State = 71;
Match(ID);
State = 62;
Match(NL);
}
}
catch (RecognitionException re) {
@ -558,9 +634,7 @@ public partial class Waifu2Parser : Parser {
public partial class FunctionParamContext : ParserRuleContext {
[System.Diagnostics.DebuggerNonUserCode] public ITerminalNode ID() { return GetToken(Waifu2Parser.ID, 0); }
[System.Diagnostics.DebuggerNonUserCode] public ITerminalNode WS() { return GetToken(Waifu2Parser.WS, 0); }
[System.Diagnostics.DebuggerNonUserCode] public TypeContext type() {
return GetRuleContext<TypeContext>(0);
}
[System.Diagnostics.DebuggerNonUserCode] public ITerminalNode TYPE() { return GetToken(Waifu2Parser.TYPE, 0); }
public FunctionParamContext(ParserRuleContext parent, int invokingState)
: base(parent, invokingState)
{
@ -587,16 +661,16 @@ public partial class Waifu2Parser : Parser {
[RuleVersion(0)]
public FunctionParamContext functionParam() {
FunctionParamContext _localctx = new FunctionParamContext(Context, State);
EnterRule(_localctx, 14, RULE_functionParam);
EnterRule(_localctx, 16, RULE_functionParam);
try {
EnterOuterAlt(_localctx, 1);
{
State = 64;
State = 73;
Match(ID);
State = 65;
State = 74;
Match(WS);
State = 66;
type();
State = 75;
Match(TYPE);
}
}
catch (RecognitionException re) {
@ -611,15 +685,27 @@ public partial class Waifu2Parser : Parser {
}
public partial class FunctionBodyContext : ParserRuleContext {
[System.Diagnostics.DebuggerNonUserCode] public ITerminalNode[] NL() { return GetTokens(Waifu2Parser.NL); }
[System.Diagnostics.DebuggerNonUserCode] public ITerminalNode NL(int i) {
return GetToken(Waifu2Parser.NL, i);
}
[System.Diagnostics.DebuggerNonUserCode] public ITerminalNode[] INDENT() { return GetTokens(Waifu2Parser.INDENT); }
[System.Diagnostics.DebuggerNonUserCode] public ITerminalNode INDENT(int i) {
return GetToken(Waifu2Parser.INDENT, i);
}
[System.Diagnostics.DebuggerNonUserCode] public ExprContext[] expr() {
return GetRuleContexts<ExprContext>();
}
[System.Diagnostics.DebuggerNonUserCode] public ExprContext expr(int i) {
return GetRuleContext<ExprContext>(i);
}
[System.Diagnostics.DebuggerNonUserCode] public ITerminalNode[] NL() { return GetTokens(Waifu2Parser.NL); }
[System.Diagnostics.DebuggerNonUserCode] public ITerminalNode NL(int i) {
return GetToken(Waifu2Parser.NL, i);
[System.Diagnostics.DebuggerNonUserCode] public ITerminalNode[] SingleLineComment() { return GetTokens(Waifu2Parser.SingleLineComment); }
[System.Diagnostics.DebuggerNonUserCode] public ITerminalNode SingleLineComment(int i) {
return GetToken(Waifu2Parser.SingleLineComment, i);
}
[System.Diagnostics.DebuggerNonUserCode] public ITerminalNode[] MultiLineComment() { return GetTokens(Waifu2Parser.MultiLineComment); }
[System.Diagnostics.DebuggerNonUserCode] public ITerminalNode MultiLineComment(int i) {
return GetToken(Waifu2Parser.MultiLineComment, i);
}
public FunctionBodyContext(ParserRuleContext parent, int invokingState)
: base(parent, invokingState)
@ -647,46 +733,131 @@ public partial class Waifu2Parser : Parser {
[RuleVersion(0)]
public FunctionBodyContext functionBody() {
FunctionBodyContext _localctx = new FunctionBodyContext(Context, State);
EnterRule(_localctx, 16, RULE_functionBody);
EnterRule(_localctx, 18, RULE_functionBody);
int _la;
try {
int _alt;
EnterOuterAlt(_localctx, 1);
{
State = 74;
State = 84;
ErrorHandler.Sync(this);
_la = TokenStream.LA(1);
do {
{
{
State = 68;
expr(0);
State = 70;
State = 81;
ErrorHandler.Sync(this);
_alt = 1;
do {
switch (_alt) {
case 1:
{
{
State = 69;
Match(NL);
}
}
break;
default:
throw new NoViableAltException(this);
switch (TokenStream.LA(1)) {
case INDENT:
{
State = 77;
Match(INDENT);
State = 78;
expr(0);
}
State = 72;
ErrorHandler.Sync(this);
_alt = Interpreter.AdaptivePredict(TokenStream,4,Context);
} while ( _alt!=2 && _alt!=global::Antlr4.Runtime.Atn.ATN.INVALID_ALT_NUMBER );
break;
case SingleLineComment:
{
State = 79;
Match(SingleLineComment);
}
break;
case MultiLineComment:
{
State = 80;
Match(MultiLineComment);
}
break;
default:
throw new NoViableAltException(this);
}
State = 83;
Match(NL);
}
}
State = 76;
State = 86;
ErrorHandler.Sync(this);
_la = TokenStream.LA(1);
} while ( (((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << ID) | (1L << MultiLineComment) | (1L << SingleLineComment) | (1L << ADD) | (1L << SUB) | (1L << INT) | (1L << DEC) | (1L << BOOL) | (1L << STR))) != 0) );
} while ( (((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << INDENT) | (1L << MultiLineComment) | (1L << SingleLineComment))) != 0) );
}
}
catch (RecognitionException re) {
_localctx.exception = re;
ErrorHandler.ReportError(this, re);
ErrorHandler.Recover(this, re);
}
finally {
ExitRule();
}
return _localctx;
}
public partial class FunctionCallContext : ParserRuleContext {
[System.Diagnostics.DebuggerNonUserCode] public ITerminalNode ID() { return GetToken(Waifu2Parser.ID, 0); }
[System.Diagnostics.DebuggerNonUserCode] public ITerminalNode[] WS() { return GetTokens(Waifu2Parser.WS); }
[System.Diagnostics.DebuggerNonUserCode] public ITerminalNode WS(int i) {
return GetToken(Waifu2Parser.WS, i);
}
[System.Diagnostics.DebuggerNonUserCode] public ExprContext[] expr() {
return GetRuleContexts<ExprContext>();
}
[System.Diagnostics.DebuggerNonUserCode] public ExprContext expr(int i) {
return GetRuleContext<ExprContext>(i);
}
public FunctionCallContext(ParserRuleContext parent, int invokingState)
: base(parent, invokingState)
{
}
public override int RuleIndex { get { return RULE_functionCall; } }
[System.Diagnostics.DebuggerNonUserCode]
public override void EnterRule(IParseTreeListener listener) {
IWaifu2Listener typedListener = listener as IWaifu2Listener;
if (typedListener != null) typedListener.EnterFunctionCall(this);
}
[System.Diagnostics.DebuggerNonUserCode]
public override void ExitRule(IParseTreeListener listener) {
IWaifu2Listener typedListener = listener as IWaifu2Listener;
if (typedListener != null) typedListener.ExitFunctionCall(this);
}
[System.Diagnostics.DebuggerNonUserCode]
public override TResult Accept<TResult>(IParseTreeVisitor<TResult> visitor) {
IWaifu2Visitor<TResult> typedVisitor = visitor as IWaifu2Visitor<TResult>;
if (typedVisitor != null) return typedVisitor.VisitFunctionCall(this);
else return visitor.VisitChildren(this);
}
}
[RuleVersion(0)]
public FunctionCallContext functionCall() {
FunctionCallContext _localctx = new FunctionCallContext(Context, State);
EnterRule(_localctx, 20, RULE_functionCall);
try {
int _alt;
EnterOuterAlt(_localctx, 1);
{
State = 88;
Match(ID);
State = 89;
Match(WS);
State = 90;
expr(0);
State = 95;
ErrorHandler.Sync(this);
_alt = Interpreter.AdaptivePredict(TokenStream,7,Context);
while ( _alt!=2 && _alt!=global::Antlr4.Runtime.Atn.ATN.INVALID_ALT_NUMBER ) {
if ( _alt==1 ) {
{
{
State = 91;
Match(WS);
State = 92;
expr(0);
}
}
}
State = 97;
ErrorHandler.Sync(this);
_alt = Interpreter.AdaptivePredict(TokenStream,7,Context);
}
}
}
catch (RecognitionException re) {
@ -705,9 +876,16 @@ public partial class Waifu2Parser : Parser {
return GetRuleContext<LiteralContext>(0);
}
[System.Diagnostics.DebuggerNonUserCode] public ITerminalNode ID() { return GetToken(Waifu2Parser.ID, 0); }
[System.Diagnostics.DebuggerNonUserCode] public SignContext sign() {
return GetRuleContext<SignContext>(0);
[System.Diagnostics.DebuggerNonUserCode] public ITerminalNode DEC() { return GetToken(Waifu2Parser.DEC, 0); }
[System.Diagnostics.DebuggerNonUserCode] public ITerminalNode SUB() { return GetToken(Waifu2Parser.SUB, 0); }
[System.Diagnostics.DebuggerNonUserCode] public NumContext num() {
return GetRuleContext<NumContext>(0);
}
[System.Diagnostics.DebuggerNonUserCode] public ITerminalNode[] WS() { return GetTokens(Waifu2Parser.WS); }
[System.Diagnostics.DebuggerNonUserCode] public ITerminalNode WS(int i) {
return GetToken(Waifu2Parser.WS, i);
}
[System.Diagnostics.DebuggerNonUserCode] public ITerminalNode ASSIGN() { return GetToken(Waifu2Parser.ASSIGN, 0); }
[System.Diagnostics.DebuggerNonUserCode] public ExprContext[] expr() {
return GetRuleContexts<ExprContext>();
}
@ -716,9 +894,8 @@ public partial class Waifu2Parser : Parser {
}
[System.Diagnostics.DebuggerNonUserCode] public ITerminalNode MultiLineComment() { return GetToken(Waifu2Parser.MultiLineComment, 0); }
[System.Diagnostics.DebuggerNonUserCode] public ITerminalNode SingleLineComment() { return GetToken(Waifu2Parser.SingleLineComment, 0); }
[System.Diagnostics.DebuggerNonUserCode] public ITerminalNode[] WS() { return GetTokens(Waifu2Parser.WS); }
[System.Diagnostics.DebuggerNonUserCode] public ITerminalNode WS(int i) {
return GetToken(Waifu2Parser.WS, i);
[System.Diagnostics.DebuggerNonUserCode] public FunctionCallContext functionCall() {
return GetRuleContext<FunctionCallContext>(0);
}
[System.Diagnostics.DebuggerNonUserCode] public OperatorContext @operator() {
return GetRuleContext<OperatorContext>(0);
@ -756,58 +933,96 @@ public partial class Waifu2Parser : Parser {
int _parentState = State;
ExprContext _localctx = new ExprContext(Context, _parentState);
ExprContext _prevctx = _localctx;
int _startState = 18;
EnterRecursionRule(_localctx, 18, RULE_expr, _p);
int _startState = 22;
EnterRecursionRule(_localctx, 22, RULE_expr, _p);
try {
int _alt;
EnterOuterAlt(_localctx, 1);
{
State = 86;
State = 115;
ErrorHandler.Sync(this);
switch (TokenStream.LA(1)) {
case INT:
case DEC:
case BOOL:
case STR:
switch ( Interpreter.AdaptivePredict(TokenStream,9,Context) ) {
case 1:
{
State = 79;
State = 99;
literal();
}
break;
case ID:
case 2:
{
State = 80;
State = 100;
Match(ID);
}
break;
case ADD:
case SUB:
case 3:
{
State = 81;
sign();
State = 82;
expr(3);
State = 101;
Match(DEC);
}
break;
case MultiLineComment:
case 4:
{
State = 84;
State = 102;
Match(SUB);
State = 105;
ErrorHandler.Sync(this);
switch (TokenStream.LA(1)) {
case ID:
{
State = 103;
Match(ID);
}
break;
case INT:
case DEC:
case BOOL:
{
State = 104;
num();
}
break;
default:
throw new NoViableAltException(this);
}
}
break;
case 5:
{
State = 107;
Match(ID);
State = 108;
Match(WS);
State = 109;
Match(ASSIGN);
State = 110;
Match(WS);
State = 111;
expr(4);
}
break;
case 6:
{
State = 112;
Match(MultiLineComment);
}
break;
case SingleLineComment:
case 7:
{
State = 85;
State = 113;
Match(SingleLineComment);
}
break;
default:
throw new NoViableAltException(this);
case 8:
{
State = 114;
functionCall();
}
break;
}
Context.Stop = TokenStream.LT(-1);
State = 96;
State = 125;
ErrorHandler.Sync(this);
_alt = Interpreter.AdaptivePredict(TokenStream,7,Context);
_alt = Interpreter.AdaptivePredict(TokenStream,10,Context);
while ( _alt!=2 && _alt!=global::Antlr4.Runtime.Atn.ATN.INVALID_ALT_NUMBER ) {
if ( _alt==1 ) {
if ( ParseListeners!=null )
@ -817,22 +1032,22 @@ public partial class Waifu2Parser : Parser {
{
_localctx = new ExprContext(_parentctx, _parentState);
PushNewRecursionContext(_localctx, _startState, RULE_expr);
State = 88;
if (!(Precpred(Context, 4))) throw new FailedPredicateException(this, "Precpred(Context, 4)");
State = 89;
State = 117;
if (!(Precpred(Context, 6))) throw new FailedPredicateException(this, "Precpred(Context, 6)");
State = 118;
Match(WS);
State = 90;
State = 119;
@operator();
State = 91;
State = 120;
Match(WS);
State = 92;
expr(5);
State = 121;
expr(7);
}
}
}
State = 98;
State = 127;
ErrorHandler.Sync(this);
_alt = Interpreter.AdaptivePredict(TokenStream,7,Context);
_alt = Interpreter.AdaptivePredict(TokenStream,10,Context);
}
}
}
@ -849,46 +1064,57 @@ public partial class Waifu2Parser : Parser {
public override bool Sempred(RuleContext _localctx, int ruleIndex, int predIndex) {
switch (ruleIndex) {
case 9: return expr_sempred((ExprContext)_localctx, predIndex);
case 11: return expr_sempred((ExprContext)_localctx, predIndex);
}
return true;
}
private bool expr_sempred(ExprContext _localctx, int predIndex) {
switch (predIndex) {
case 0: return Precpred(Context, 4);
case 0: return Precpred(Context, 6);
}
return true;
}
private static int[] _serializedATN = {
4,1,19,100,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,1,0,5,0,22,8,0,10,0,12,0,25,9,0,1,0,5,0,28,8,0,10,
0,12,0,31,9,0,1,0,5,0,34,8,0,10,0,12,0,37,9,0,1,0,1,0,1,1,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,6,1,6,1,6,1,6,1,6,3,6,59,8,6,1,6,
1,6,1,6,1,6,1,7,1,7,1,7,1,7,1,8,1,8,4,8,71,8,8,11,8,12,8,72,4,8,75,8,8,
11,8,12,8,76,1,9,1,9,1,9,1,9,1,9,1,9,1,9,1,9,3,9,87,8,9,1,9,1,9,1,9,1,
9,1,9,1,9,5,9,95,8,9,10,9,12,9,98,9,9,1,9,0,1,18,10,0,2,4,6,8,10,12,14,
16,18,0,3,1,0,10,11,1,0,7,11,1,0,16,19,100,0,23,1,0,0,0,2,40,1,0,0,0,4,
43,1,0,0,0,6,45,1,0,0,0,8,47,1,0,0,0,10,49,1,0,0,0,12,53,1,0,0,0,14,64,
1,0,0,0,16,74,1,0,0,0,18,86,1,0,0,0,20,22,5,3,0,0,21,20,1,0,0,0,22,25,
1,0,0,0,23,21,1,0,0,0,23,24,1,0,0,0,24,29,1,0,0,0,25,23,1,0,0,0,26,28,
3,10,5,0,27,26,1,0,0,0,28,31,1,0,0,0,29,27,1,0,0,0,29,30,1,0,0,0,30,35,
1,0,0,0,31,29,1,0,0,0,32,34,5,3,0,0,33,32,1,0,0,0,34,37,1,0,0,0,35,33,
1,0,0,0,35,36,1,0,0,0,36,38,1,0,0,0,37,35,1,0,0,0,38,39,5,0,0,1,39,1,1,
0,0,0,40,41,5,15,0,0,41,42,5,1,0,0,42,3,1,0,0,0,43,44,7,0,0,0,44,5,1,0,
0,0,45,46,7,1,0,0,46,7,1,0,0,0,47,48,7,2,0,0,48,9,1,0,0,0,49,50,3,12,6,
0,50,51,5,3,0,0,51,52,3,16,8,0,52,11,1,0,0,0,53,54,5,13,0,0,54,55,3,14,
7,0,55,56,5,14,0,0,56,58,5,2,0,0,57,59,3,2,1,0,58,57,1,0,0,0,58,59,1,0,
0,0,59,60,1,0,0,0,60,61,5,2,0,0,61,62,5,4,0,0,62,63,5,3,0,0,63,13,1,0,
0,0,64,65,5,4,0,0,65,66,5,2,0,0,66,67,3,2,1,0,67,15,1,0,0,0,68,70,3,18,
9,0,69,71,5,3,0,0,70,69,1,0,0,0,71,72,1,0,0,0,72,70,1,0,0,0,72,73,1,0,
0,0,73,75,1,0,0,0,74,68,1,0,0,0,75,76,1,0,0,0,76,74,1,0,0,0,76,77,1,0,
0,0,77,17,1,0,0,0,78,79,6,9,-1,0,79,87,3,8,4,0,80,87,5,4,0,0,81,82,3,4,
2,0,82,83,3,18,9,3,83,87,1,0,0,0,84,87,5,5,0,0,85,87,5,6,0,0,86,78,1,0,
0,0,86,80,1,0,0,0,86,81,1,0,0,0,86,84,1,0,0,0,86,85,1,0,0,0,87,96,1,0,
0,0,88,89,10,4,0,0,89,90,5,2,0,0,90,91,3,6,3,0,91,92,5,2,0,0,92,93,3,18,
9,5,93,95,1,0,0,0,94,88,1,0,0,0,95,98,1,0,0,0,96,94,1,0,0,0,96,97,1,0,
0,0,97,19,1,0,0,0,98,96,1,0,0,0,8,23,29,35,58,72,76,86,96
4,1,21,129,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,1,0,1,0,1,1,5,1,28,8,1,10,1,12,
1,31,9,1,1,1,5,1,34,8,1,10,1,12,1,37,9,1,1,1,5,1,40,8,1,10,1,12,1,43,9,
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,6,1,6,1,7,1,7,5,7,
61,8,7,10,7,12,7,64,9,7,1,7,1,7,1,7,3,7,69,8,7,1,7,1,7,1,7,1,8,1,8,1,8,
1,8,1,9,1,9,1,9,1,9,3,9,82,8,9,1,9,4,9,85,8,9,11,9,12,9,86,1,10,1,10,1,
10,1,10,1,10,5,10,94,8,10,10,10,12,10,97,9,10,1,11,1,11,1,11,1,11,1,11,
1,11,1,11,3,11,106,8,11,1,11,1,11,1,11,1,11,1,11,1,11,1,11,1,11,3,11,116,
8,11,1,11,1,11,1,11,1,11,1,11,1,11,5,11,124,8,11,10,11,12,11,127,9,11,
1,11,0,1,22,12,0,2,4,6,8,10,12,14,16,18,20,22,0,4,1,0,17,19,1,0,10,11,
1,0,17,20,1,0,7,11,134,0,24,1,0,0,0,2,29,1,0,0,0,4,46,1,0,0,0,6,48,1,0,
0,0,8,50,1,0,0,0,10,52,1,0,0,0,12,54,1,0,0,0,14,58,1,0,0,0,16,73,1,0,0,
0,18,84,1,0,0,0,20,88,1,0,0,0,22,115,1,0,0,0,24,25,7,0,0,0,25,1,1,0,0,
0,26,28,5,2,0,0,27,26,1,0,0,0,28,31,1,0,0,0,29,27,1,0,0,0,29,30,1,0,0,
0,30,35,1,0,0,0,31,29,1,0,0,0,32,34,3,12,6,0,33,32,1,0,0,0,34,37,1,0,0,
0,35,33,1,0,0,0,35,36,1,0,0,0,36,41,1,0,0,0,37,35,1,0,0,0,38,40,5,2,0,
0,39,38,1,0,0,0,40,43,1,0,0,0,41,39,1,0,0,0,41,42,1,0,0,0,42,44,1,0,0,
0,43,41,1,0,0,0,44,45,5,0,0,1,45,3,1,0,0,0,46,47,7,1,0,0,47,5,1,0,0,0,
48,49,7,2,0,0,49,7,1,0,0,0,50,51,7,3,0,0,51,9,1,0,0,0,52,53,7,2,0,0,53,
11,1,0,0,0,54,55,3,14,7,0,55,56,5,2,0,0,56,57,3,18,9,0,57,13,1,0,0,0,58,
62,5,13,0,0,59,61,3,16,8,0,60,59,1,0,0,0,61,64,1,0,0,0,62,60,1,0,0,0,62,
63,1,0,0,0,63,65,1,0,0,0,64,62,1,0,0,0,65,68,5,14,0,0,66,67,5,1,0,0,67,
69,5,21,0,0,68,66,1,0,0,0,68,69,1,0,0,0,69,70,1,0,0,0,70,71,5,1,0,0,71,
72,5,3,0,0,72,15,1,0,0,0,73,74,5,3,0,0,74,75,5,1,0,0,75,76,5,21,0,0,76,
17,1,0,0,0,77,78,5,4,0,0,78,82,3,22,11,0,79,82,5,6,0,0,80,82,5,5,0,0,81,
77,1,0,0,0,81,79,1,0,0,0,81,80,1,0,0,0,82,83,1,0,0,0,83,85,5,2,0,0,84,
81,1,0,0,0,85,86,1,0,0,0,86,84,1,0,0,0,86,87,1,0,0,0,87,19,1,0,0,0,88,
89,5,3,0,0,89,90,5,1,0,0,90,95,3,22,11,0,91,92,5,1,0,0,92,94,3,22,11,0,
93,91,1,0,0,0,94,97,1,0,0,0,95,93,1,0,0,0,95,96,1,0,0,0,96,21,1,0,0,0,
97,95,1,0,0,0,98,99,6,11,-1,0,99,116,3,10,5,0,100,116,5,3,0,0,101,116,
5,18,0,0,102,105,5,11,0,0,103,106,5,3,0,0,104,106,3,0,0,0,105,103,1,0,
0,0,105,104,1,0,0,0,106,116,1,0,0,0,107,108,5,3,0,0,108,109,5,1,0,0,109,
110,5,12,0,0,110,111,5,1,0,0,111,116,3,22,11,4,112,116,5,5,0,0,113,116,
5,6,0,0,114,116,3,20,10,0,115,98,1,0,0,0,115,100,1,0,0,0,115,101,1,0,0,
0,115,102,1,0,0,0,115,107,1,0,0,0,115,112,1,0,0,0,115,113,1,0,0,0,115,
114,1,0,0,0,116,125,1,0,0,0,117,118,10,6,0,0,118,119,5,1,0,0,119,120,3,
8,4,0,120,121,5,1,0,0,121,122,3,22,11,7,122,124,1,0,0,0,123,117,1,0,0,
0,124,127,1,0,0,0,125,123,1,0,0,0,125,126,1,0,0,0,126,23,1,0,0,0,127,125,
1,0,0,0,11,29,35,41,62,68,81,86,95,105,115,125
};
public static readonly ATN _ATN =

View File

@ -32,6 +32,12 @@ using IToken = Antlr4.Runtime.IToken;
[System.CodeDom.Compiler.GeneratedCode("ANTLR", "4.10.1")]
[System.CLSCompliant(false)]
public interface IWaifu2Visitor<Result> : IParseTreeVisitor<Result> {
/// <summary>
/// Visit a parse tree produced by <see cref="Waifu2Parser.num"/>.
/// </summary>
/// <param name="context">The parse tree.</param>
/// <return>The visitor result.</return>
Result VisitNum([NotNull] Waifu2Parser.NumContext context);
/// <summary>
/// Visit a parse tree produced by <see cref="Waifu2Parser.waifuFile"/>.
/// </summary>
@ -39,18 +45,18 @@ public interface IWaifu2Visitor<Result> : IParseTreeVisitor<Result> {
/// <return>The visitor result.</return>
Result VisitWaifuFile([NotNull] Waifu2Parser.WaifuFileContext context);
/// <summary>
/// Visit a parse tree produced by <see cref="Waifu2Parser.type"/>.
/// </summary>
/// <param name="context">The parse tree.</param>
/// <return>The visitor result.</return>
Result VisitType([NotNull] Waifu2Parser.TypeContext context);
/// <summary>
/// Visit a parse tree produced by <see cref="Waifu2Parser.sign"/>.
/// </summary>
/// <param name="context">The parse tree.</param>
/// <return>The visitor result.</return>
Result VisitSign([NotNull] Waifu2Parser.SignContext context);
/// <summary>
/// Visit a parse tree produced by <see cref="Waifu2Parser.value"/>.
/// </summary>
/// <param name="context">The parse tree.</param>
/// <return>The visitor result.</return>
Result VisitValue([NotNull] Waifu2Parser.ValueContext context);
/// <summary>
/// Visit a parse tree produced by <see cref="Waifu2Parser.operator"/>.
/// </summary>
/// <param name="context">The parse tree.</param>
@ -87,6 +93,12 @@ public interface IWaifu2Visitor<Result> : IParseTreeVisitor<Result> {
/// <return>The visitor result.</return>
Result VisitFunctionBody([NotNull] Waifu2Parser.FunctionBodyContext context);
/// <summary>
/// Visit a parse tree produced by <see cref="Waifu2Parser.functionCall"/>.
/// </summary>
/// <param name="context">The parse tree.</param>
/// <return>The visitor result.</return>
Result VisitFunctionCall([NotNull] Waifu2Parser.FunctionCallContext context);
/// <summary>
/// Visit a parse tree produced by <see cref="Waifu2Parser.expr"/>.
/// </summary>
/// <param name="context">The parse tree.</param>