self.visit_list(ctx.defn())
return self.module
- return self.visit(ctx.expr())
+ if ctx.expr():
+ return self.visit(ctx.expr())
- # Exprs
+ return self.module
+ # Exprs
def visitOpIdent(self, ctx):
# type: (RelayParser.OpIdentContext) -> op.Op
return op.get(ctx.CNAME().getText())
self.enter_var_scope()
# Capture type params in params.
self.enter_type_param_scope()
+ type_params = ctx.typeParamSeq()
+
+ if type_params is not None:
+ type_params = type_params.ident()
+ assert type_params
+ for ty_param in type_params:
+ name = ty_param.getText()
+ self.mk_typ(name, ty.Kind.Type)
+
var_list, attr_list = self.visit(ctx.argList())
ret_type = self.getType_(ctx.type_())
+ body = self.visit(ctx.body())
+ # NB(@jroesch): you must stay in the type parameter scope until
+ # after you exit the body, you can reference the type parameters
+ # of your parent scopes.
type_params = list(self.exit_type_param_scope())
if type_params:
_, type_params = zip(*type_params)
-
- body = self.visit(ctx.body())
self.exit_var_scope()
attrs = tvm.make.node("DictAttrs", **attr_list) if attr_list is not None else None
# type (RelayParser.IncompleteTypeContext) -> None:
return None
- def visitIdentType(self, ctx):
- # type: (RelayParser.IdentTypeContext) -> Union[ty.TensorType, str]
- ident_type = ctx.CNAME().getText()
+ def visitTypeIdent(self, ctx):
+ # type: (RelayParser.TypeIdentContext) -> Union[ty.TensorType, str]
+ '''
+ Handle type identifier.
+ '''
+ type_ident = ctx.CNAME().getText()
- # look through all type prefixes for a match
+ # Look through all type prefixes for a match
for type_prefix in TYPE_PREFIXES:
- if ident_type.startswith(type_prefix):
- return ty.scalar_type(ident_type)
+ if type_ident.startswith(type_prefix):
+ return ty.scalar_type(type_ident)
+
+ type_param = lookup(self.type_param_scopes, type_ident)
+ if type_param is not None:
+ return type_param
- raise ParseError("Unknown builtin type: {}".format(ident_type))
+ raise ParseError("Unknown builtin type: {}".format(type_ident))
# def visitCallType(self, ctx):
# # type: (RelayParser.CallTypeContext) -> Union[expr.Expr, ty.TensorType]
grammar Relay;
-SEMVER: 'v0.0.1' ;
+SEMVER: 'v0.0.2' ;
// Lexing
// comments
// | 'debug' # debug
;
-func: 'fn' '(' argList ')' ('->' type_)? body ;
-defn: 'def' ident '(' argList ')' ('->' type_)? body ;
+func: 'fn' typeParamSeq? '(' argList ')' ('->' type_)? body ;
+defn: 'def' ident typeParamSeq? '(' argList ')' ('->' type_)? body ;
argList
: varList
// relations: 'where' relation (',' relation)* ;
// relation: ident '(' (type_ (',' type_)*)? ')' ;
+typeParamSeq
+ : '[' ']'
+ | '[' ident (',' ident)* ']'
+ ;
+
type_
: '(' ')' # tupleType
| '(' type_ ',' ')' # tupleType
| '(' type_ (',' type_)+ ')' # tupleType
- | identType # identTypeType
+ | typeIdent # typeIdentType
| 'Tensor' '[' shapeSeq ',' type_ ']' # tensorType
// currently unused
- // | identType '[' (type_ (',' type_)*)? ']' # callType
- | 'fn' '(' (type_ (',' type_)*)? ')' '->' type_ # funcType
+ // | typeIdent '[' (type_ (',' type_)*)? ']' # callType
+ | 'fn' typeParamSeq? '(' (type_ (',' type_)*)? ')' '->' type_ # funcType
| '_' # incompleteType
| NAT # intType
;
| NAT # intShape
;
-identType: CNAME ;
+typeIdent : CNAME ;
// int8, int16, int32, int64
// uint8, uint16, uint32, uint64
// float16, float32, float64
--- /dev/null
+Relay* binary
+Relay* linguist-generated=true
+Relay* linguist-detectable=false
\ No newline at end of file
--- /dev/null
+token literal names:
+null
+'('
+')'
+','
+'['
+']'
+'if'
+'else'
+'let'
+'='
+';'
+'{'
+'}'
+'fn'
+'->'
+'def'
+':'
+'Tensor'
+'_'
+'v0.0.2'
+null
+null
+null
+'*'
+'/'
+'+'
+'-'
+'<'
+'>'
+'<='
+'>='
+'=='
+'!='
+null
+null
+null
+'mut'
+null
+null
+null
+null
+
+token symbolic names:
+null
+null
+null
+null
+null
+null
+null
+null
+null
+null
+null
+null
+null
+null
+null
+null
+null
+null
+null
+SEMVER
+WS
+LINE_COMMENT
+COMMENT
+MUL
+DIV
+ADD
+SUB
+LT
+GT
+LE
+GE
+EQ
+NE
+GLOBAL_VAR
+LOCAL_VAR
+GRAPH_VAR
+MUT
+BOOL_LIT
+FLOAT
+NAT
+CNAME
+
+rule names:
+opIdent
+prog
+expr
+func
+defn
+argList
+varList
+var
+attrList
+attr
+typeParamSeq
+type_
+shapeSeq
+shape
+typeIdent
+body
+scalar
+ident
+
+
+atn:
+[3, 24715, 42794, 33075, 47597, 16764, 15335, 30598, 22884, 3, 42, 332, 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, 4, 14, 9, 14, 4, 15, 9, 15, 4, 16, 9, 16, 4, 17, 9, 17, 4, 18, 9, 18, 4, 19, 9, 19, 3, 2, 3, 2, 3, 3, 3, 3, 7, 3, 43, 10, 3, 12, 3, 14, 3, 46, 11, 3, 3, 3, 5, 3, 49, 10, 3, 3, 3, 3, 3, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 6, 4, 72, 10, 4, 13, 4, 14, 4, 73, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 7, 4, 82, 10, 4, 12, 4, 14, 4, 85, 11, 4, 5, 4, 87, 10, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 5, 4, 100, 10, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 5, 4, 110, 10, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 5, 4, 128, 10, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 7, 4, 150, 10, 4, 12, 4, 14, 4, 153, 11, 4, 5, 4, 155, 10, 4, 3, 4, 7, 4, 158, 10, 4, 12, 4, 14, 4, 161, 11, 4, 3, 5, 3, 5, 5, 5, 165, 10, 5, 3, 5, 3, 5, 3, 5, 3, 5, 3, 5, 5, 5, 172, 10, 5, 3, 5, 3, 5, 3, 6, 3, 6, 3, 6, 5, 6, 179, 10, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 5, 6, 186, 10, 6, 3, 6, 3, 6, 3, 7, 3, 7, 3, 7, 3, 7, 3, 7, 3, 7, 5, 7, 196, 10, 7, 3, 8, 3, 8, 3, 8, 7, 8, 201, 10, 8, 12, 8, 14, 8, 204, 11, 8, 5, 8, 206, 10, 8, 3, 9, 3, 9, 3, 9, 5, 9, 211, 10, 9, 3, 10, 3, 10, 3, 10, 7, 10, 216, 10, 10, 12, 10, 14, 10, 219, 11, 10, 5, 10, 221, 10, 10, 3, 11, 3, 11, 3, 11, 3, 11, 3, 12, 3, 12, 3, 12, 3, 12, 3, 12, 3, 12, 7, 12, 233, 10, 12, 12, 12, 14, 12, 236, 11, 12, 3, 12, 3, 12, 5, 12, 240, 10, 12, 3, 13, 3, 13, 3, 13, 3, 13, 3, 13, 3, 13, 3, 13, 3, 13, 3, 13, 3, 13, 3, 13, 6, 13, 253, 10, 13, 13, 13, 14, 13, 254, 3, 13, 3, 13, 3, 13, 3, 13, 3, 13, 3, 13, 3, 13, 3, 13, 3, 13, 3, 13, 3, 13, 3, 13, 5, 13, 269, 10, 13, 3, 13, 3, 13, 3, 13, 3, 13, 7, 13, 275, 10, 13, 12, 13, 14, 13, 278, 11, 13, 5, 13, 280, 10, 13, 3, 13, 3, 13, 3, 13, 3, 13, 3, 13, 5, 13, 287, 10, 13, 3, 14, 3, 14, 3, 14, 3, 14, 3, 14, 3, 14, 3, 14, 3, 14, 3, 14, 3, 14, 3, 14, 6, 14, 300, 10, 14, 13, 14, 14, 14, 301, 3, 14, 3, 14, 5, 14, 306, 10, 14, 3, 15, 3, 15, 3, 15, 3, 15, 3, 15, 5, 15, 313, 10, 15, 3, 16, 3, 16, 3, 17, 3, 17, 3, 17, 3, 17, 3, 18, 3, 18, 3, 18, 5, 18, 324, 10, 18, 3, 19, 3, 19, 3, 19, 3, 19, 5, 19, 330, 10, 19, 3, 19, 2, 3, 6, 20, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 2, 6, 3, 2, 25, 26, 3, 2, 27, 28, 3, 2, 29, 32, 3, 2, 33, 34, 2, 373, 2, 38, 3, 2, 2, 2, 4, 40, 3, 2, 2, 2, 6, 127, 3, 2, 2, 2, 8, 162, 3, 2, 2, 2, 10, 175, 3, 2, 2, 2, 12, 195, 3, 2, 2, 2, 14, 205, 3, 2, 2, 2, 16, 207, 3, 2, 2, 2, 18, 220, 3, 2, 2, 2, 20, 222, 3, 2, 2, 2, 22, 239, 3, 2, 2, 2, 24, 286, 3, 2, 2, 2, 26, 305, 3, 2, 2, 2, 28, 312, 3, 2, 2, 2, 30, 314, 3, 2, 2, 2, 32, 316, 3, 2, 2, 2, 34, 323, 3, 2, 2, 2, 36, 329, 3, 2, 2, 2, 38, 39, 7, 42, 2, 2, 39, 3, 3, 2, 2, 2, 40, 48, 7, 21, 2, 2, 41, 43, 5, 10, 6, 2, 42, 41, 3, 2, 2, 2, 43, 46, 3, 2, 2, 2, 44, 42, 3, 2, 2, 2, 44, 45, 3, 2, 2, 2, 45, 49, 3, 2, 2, 2, 46, 44, 3, 2, 2, 2, 47, 49, 5, 6, 4, 2, 48, 44, 3, 2, 2, 2, 48, 47, 3, 2, 2, 2, 49, 50, 3, 2, 2, 2, 50, 51, 7, 2, 2, 3, 51, 5, 3, 2, 2, 2, 52, 53, 8, 4, 1, 2, 53, 54, 7, 3, 2, 2, 54, 55, 5, 6, 4, 2, 55, 56, 7, 4, 2, 2, 56, 128, 3, 2, 2, 2, 57, 58, 7, 28, 2, 2, 58, 128, 5, 6, 4, 19, 59, 128, 5, 8, 5, 2, 60, 61, 7, 3, 2, 2, 61, 128, 7, 4, 2, 2, 62, 63, 7, 3, 2, 2, 63, 64, 5, 6, 4, 2, 64, 65, 7, 5, 2, 2, 65, 66, 7, 4, 2, 2, 66, 128, 3, 2, 2, 2, 67, 68, 7, 3, 2, 2, 68, 71, 5, 6, 4, 2, 69, 70, 7, 5, 2, 2, 70, 72, 5, 6, 4, 2, 71, 69, 3, 2, 2, 2, 72, 73, 3, 2, 2, 2, 73, 71, 3, 2, 2, 2, 73, 74, 3, 2, 2, 2, 74, 75, 3, 2, 2, 2, 75, 76, 7, 4, 2, 2, 76, 128, 3, 2, 2, 2, 77, 86, 7, 6, 2, 2, 78, 83, 5, 6, 4, 2, 79, 80, 7, 5, 2, 2, 80, 82, 5, 6, 4, 2, 81, 79, 3, 2, 2, 2, 82, 85, 3, 2, 2, 2, 83, 81, 3, 2, 2, 2, 83, 84, 3, 2, 2, 2, 84, 87, 3, 2, 2, 2, 85, 83, 3, 2, 2, 2, 86, 78, 3, 2, 2, 2, 86, 87, 3, 2, 2, 2, 87, 88, 3, 2, 2, 2, 88, 128, 7, 7, 2, 2, 89, 90, 7, 8, 2, 2, 90, 91, 7, 3, 2, 2, 91, 92, 5, 6, 4, 2, 92, 93, 7, 4, 2, 2, 93, 94, 5, 32, 17, 2, 94, 95, 7, 9, 2, 2, 95, 96, 5, 32, 17, 2, 96, 128, 3, 2, 2, 2, 97, 99, 7, 10, 2, 2, 98, 100, 7, 38, 2, 2, 99, 98, 3, 2, 2, 2, 99, 100, 3, 2, 2, 2, 100, 101, 3, 2, 2, 2, 101, 102, 5, 16, 9, 2, 102, 103, 7, 11, 2, 2, 103, 104, 5, 6, 4, 2, 104, 105, 7, 12, 2, 2, 105, 106, 5, 6, 4, 8, 106, 128, 3, 2, 2, 2, 107, 109, 7, 10, 2, 2, 108, 110, 7, 38, 2, 2, 109, 108, 3, 2, 2, 2, 109, 110, 3, 2, 2, 2, 110, 111, 3, 2, 2, 2, 111, 112, 5, 16, 9, 2, 112, 113, 7, 11, 2, 2, 113, 114, 7, 13, 2, 2, 114, 115, 5, 6, 4, 2, 115, 116, 7, 14, 2, 2, 116, 117, 7, 12, 2, 2, 117, 118, 5, 6, 4, 7, 118, 128, 3, 2, 2, 2, 119, 120, 5, 36, 19, 2, 120, 121, 7, 11, 2, 2, 121, 122, 5, 6, 4, 2, 122, 123, 7, 12, 2, 2, 123, 124, 5, 6, 4, 5, 124, 128, 3, 2, 2, 2, 125, 128, 5, 36, 19, 2, 126, 128, 5, 34, 18, 2, 127, 52, 3, 2, 2, 2, 127, 57, 3, 2, 2, 2, 127, 59, 3, 2, 2, 2, 127, 60, 3, 2, 2, 2, 127, 62, 3, 2, 2, 2, 127, 67, 3, 2, 2, 2, 127, 77, 3, 2, 2, 2, 127, 89, 3, 2, 2, 2, 127, 97, 3, 2, 2, 2, 127, 107, 3, 2, 2, 2, 127, 119, 3, 2, 2, 2, 127, 125, 3, 2, 2, 2, 127, 126, 3, 2, 2, 2, 128, 159, 3, 2, 2, 2, 129, 130, 12, 18, 2, 2, 130, 131, 9, 2, 2, 2, 131, 158, 5, 6, 4, 19, 132, 133, 12, 17, 2, 2, 133, 134, 9, 3, 2, 2, 134, 158, 5, 6, 4, 18, 135, 136, 12, 16, 2, 2, 136, 137, 9, 4, 2, 2, 137, 158, 5, 6, 4, 17, 138, 139, 12, 15, 2, 2, 139, 140, 9, 5, 2, 2, 140, 158, 5, 6, 4, 16, 141, 142, 12, 6, 2, 2, 142, 143, 7, 12, 2, 2, 143, 158, 5, 6, 4, 7, 144, 145, 12, 20, 2, 2, 145, 154, 7, 3, 2, 2, 146, 151, 5, 6, 4, 2, 147, 148, 7, 5, 2, 2, 148, 150, 5, 6, 4, 2, 149, 147, 3, 2, 2, 2, 150, 153, 3, 2, 2, 2, 151, 149, 3, 2, 2, 2, 151, 152, 3, 2, 2, 2, 152, 155, 3, 2, 2, 2, 153, 151, 3, 2, 2, 2, 154, 146, 3, 2, 2, 2, 154, 155, 3, 2, 2, 2, 155, 156, 3, 2, 2, 2, 156, 158, 7, 4, 2, 2, 157, 129, 3, 2, 2, 2, 157, 132, 3, 2, 2, 2, 157, 135, 3, 2, 2, 2, 157, 138, 3, 2, 2, 2, 157, 141, 3, 2, 2, 2, 157, 144, 3, 2, 2, 2, 158, 161, 3, 2, 2, 2, 159, 157, 3, 2, 2, 2, 159, 160, 3, 2, 2, 2, 160, 7, 3, 2, 2, 2, 161, 159, 3, 2, 2, 2, 162, 164, 7, 15, 2, 2, 163, 165, 5, 22, 12, 2, 164, 163, 3, 2, 2, 2, 164, 165, 3, 2, 2, 2, 165, 166, 3, 2, 2, 2, 166, 167, 7, 3, 2, 2, 167, 168, 5, 12, 7, 2, 168, 171, 7, 4, 2, 2, 169, 170, 7, 16, 2, 2, 170, 172, 5, 24, 13, 2, 171, 169, 3, 2, 2, 2, 171, 172, 3, 2, 2, 2, 172, 173, 3, 2, 2, 2, 173, 174, 5, 32, 17, 2, 174, 9, 3, 2, 2, 2, 175, 176, 7, 17, 2, 2, 176, 178, 5, 36, 19, 2, 177, 179, 5, 22, 12, 2, 178, 177, 3, 2, 2, 2, 178, 179, 3, 2, 2, 2, 179, 180, 3, 2, 2, 2, 180, 181, 7, 3, 2, 2, 181, 182, 5, 12, 7, 2, 182, 185, 7, 4, 2, 2, 183, 184, 7, 16, 2, 2, 184, 186, 5, 24, 13, 2, 185, 183, 3, 2, 2, 2, 185, 186, 3, 2, 2, 2, 186, 187, 3, 2, 2, 2, 187, 188, 5, 32, 17, 2, 188, 11, 3, 2, 2, 2, 189, 196, 5, 14, 8, 2, 190, 196, 5, 18, 10, 2, 191, 192, 5, 14, 8, 2, 192, 193, 7, 5, 2, 2, 193, 194, 5, 18, 10, 2, 194, 196, 3, 2, 2, 2, 195, 189, 3, 2, 2, 2, 195, 190, 3, 2, 2, 2, 195, 191, 3, 2, 2, 2, 196, 13, 3, 2, 2, 2, 197, 202, 5, 16, 9, 2, 198, 199, 7, 5, 2, 2, 199, 201, 5, 16, 9, 2, 200, 198, 3, 2, 2, 2, 201, 204, 3, 2, 2, 2, 202, 200, 3, 2, 2, 2, 202, 203, 3, 2, 2, 2, 203, 206, 3, 2, 2, 2, 204, 202, 3, 2, 2, 2, 205, 197, 3, 2, 2, 2, 205, 206, 3, 2, 2, 2, 206, 15, 3, 2, 2, 2, 207, 210, 5, 36, 19, 2, 208, 209, 7, 18, 2, 2, 209, 211, 5, 24, 13, 2, 210, 208, 3, 2, 2, 2, 210, 211, 3, 2, 2, 2, 211, 17, 3, 2, 2, 2, 212, 217, 5, 20, 11, 2, 213, 214, 7, 5, 2, 2, 214, 216, 5, 20, 11, 2, 215, 213, 3, 2, 2, 2, 216, 219, 3, 2, 2, 2, 217, 215, 3, 2, 2, 2, 217, 218, 3, 2, 2, 2, 218, 221, 3, 2, 2, 2, 219, 217, 3, 2, 2, 2, 220, 212, 3, 2, 2, 2, 220, 221, 3, 2, 2, 2, 221, 19, 3, 2, 2, 2, 222, 223, 7, 42, 2, 2, 223, 224, 7, 11, 2, 2, 224, 225, 5, 6, 4, 2, 225, 21, 3, 2, 2, 2, 226, 227, 7, 6, 2, 2, 227, 240, 7, 7, 2, 2, 228, 229, 7, 6, 2, 2, 229, 234, 5, 36, 19, 2, 230, 231, 7, 5, 2, 2, 231, 233, 5, 36, 19, 2, 232, 230, 3, 2, 2, 2, 233, 236, 3, 2, 2, 2, 234, 232, 3, 2, 2, 2, 234, 235, 3, 2, 2, 2, 235, 237, 3, 2, 2, 2, 236, 234, 3, 2, 2, 2, 237, 238, 7, 7, 2, 2, 238, 240, 3, 2, 2, 2, 239, 226, 3, 2, 2, 2, 239, 228, 3, 2, 2, 2, 240, 23, 3, 2, 2, 2, 241, 242, 7, 3, 2, 2, 242, 287, 7, 4, 2, 2, 243, 244, 7, 3, 2, 2, 244, 245, 5, 24, 13, 2, 245, 246, 7, 5, 2, 2, 246, 247, 7, 4, 2, 2, 247, 287, 3, 2, 2, 2, 248, 249, 7, 3, 2, 2, 249, 252, 5, 24, 13, 2, 250, 251, 7, 5, 2, 2, 251, 253, 5, 24, 13, 2, 252, 250, 3, 2, 2, 2, 253, 254, 3, 2, 2, 2, 254, 252, 3, 2, 2, 2, 254, 255, 3, 2, 2, 2, 255, 256, 3, 2, 2, 2, 256, 257, 7, 4, 2, 2, 257, 287, 3, 2, 2, 2, 258, 287, 5, 30, 16, 2, 259, 260, 7, 19, 2, 2, 260, 261, 7, 6, 2, 2, 261, 262, 5, 26, 14, 2, 262, 263, 7, 5, 2, 2, 263, 264, 5, 24, 13, 2, 264, 265, 7, 7, 2, 2, 265, 287, 3, 2, 2, 2, 266, 268, 7, 15, 2, 2, 267, 269, 5, 22, 12, 2, 268, 267, 3, 2, 2, 2, 268, 269, 3, 2, 2, 2, 269, 270, 3, 2, 2, 2, 270, 279, 7, 3, 2, 2, 271, 276, 5, 24, 13, 2, 272, 273, 7, 5, 2, 2, 273, 275, 5, 24, 13, 2, 274, 272, 3, 2, 2, 2, 275, 278, 3, 2, 2, 2, 276, 274, 3, 2, 2, 2, 276, 277, 3, 2, 2, 2, 277, 280, 3, 2, 2, 2, 278, 276, 3, 2, 2, 2, 279, 271, 3, 2, 2, 2, 279, 280, 3, 2, 2, 2, 280, 281, 3, 2, 2, 2, 281, 282, 7, 4, 2, 2, 282, 283, 7, 16, 2, 2, 283, 287, 5, 24, 13, 2, 284, 287, 7, 20, 2, 2, 285, 287, 7, 41, 2, 2, 286, 241, 3, 2, 2, 2, 286, 243, 3, 2, 2, 2, 286, 248, 3, 2, 2, 2, 286, 258, 3, 2, 2, 2, 286, 259, 3, 2, 2, 2, 286, 266, 3, 2, 2, 2, 286, 284, 3, 2, 2, 2, 286, 285, 3, 2, 2, 2, 287, 25, 3, 2, 2, 2, 288, 289, 7, 3, 2, 2, 289, 306, 7, 4, 2, 2, 290, 291, 7, 3, 2, 2, 291, 292, 5, 28, 15, 2, 292, 293, 7, 5, 2, 2, 293, 294, 7, 4, 2, 2, 294, 306, 3, 2, 2, 2, 295, 296, 7, 3, 2, 2, 296, 299, 5, 28, 15, 2, 297, 298, 7, 5, 2, 2, 298, 300, 5, 28, 15, 2, 299, 297, 3, 2, 2, 2, 300, 301, 3, 2, 2, 2, 301, 299, 3, 2, 2, 2, 301, 302, 3, 2, 2, 2, 302, 303, 3, 2, 2, 2, 303, 304, 7, 4, 2, 2, 304, 306, 3, 2, 2, 2, 305, 288, 3, 2, 2, 2, 305, 290, 3, 2, 2, 2, 305, 295, 3, 2, 2, 2, 306, 27, 3, 2, 2, 2, 307, 308, 7, 3, 2, 2, 308, 309, 5, 28, 15, 2, 309, 310, 7, 4, 2, 2, 310, 313, 3, 2, 2, 2, 311, 313, 7, 41, 2, 2, 312, 307, 3, 2, 2, 2, 312, 311, 3, 2, 2, 2, 313, 29, 3, 2, 2, 2, 314, 315, 7, 42, 2, 2, 315, 31, 3, 2, 2, 2, 316, 317, 7, 13, 2, 2, 317, 318, 5, 6, 4, 2, 318, 319, 7, 14, 2, 2, 319, 33, 3, 2, 2, 2, 320, 324, 7, 40, 2, 2, 321, 324, 7, 41, 2, 2, 322, 324, 7, 39, 2, 2, 323, 320, 3, 2, 2, 2, 323, 321, 3, 2, 2, 2, 323, 322, 3, 2, 2, 2, 324, 35, 3, 2, 2, 2, 325, 330, 5, 2, 2, 2, 326, 330, 7, 35, 2, 2, 327, 330, 7, 36, 2, 2, 328, 330, 7, 37, 2, 2, 329, 325, 3, 2, 2, 2, 329, 326, 3, 2, 2, 2, 329, 327, 3, 2, 2, 2, 329, 328, 3, 2, 2, 2, 330, 37, 3, 2, 2, 2, 36, 44, 48, 73, 83, 86, 99, 109, 127, 151, 154, 157, 159, 164, 171, 178, 185, 195, 202, 205, 210, 217, 220, 234, 239, 254, 268, 276, 279, 286, 301, 305, 312, 323, 329]
\ No newline at end of file
--- /dev/null
+T__0=1
+T__1=2
+T__2=3
+T__3=4
+T__4=5
+T__5=6
+T__6=7
+T__7=8
+T__8=9
+T__9=10
+T__10=11
+T__11=12
+T__12=13
+T__13=14
+T__14=15
+T__15=16
+T__16=17
+T__17=18
+SEMVER=19
+WS=20
+LINE_COMMENT=21
+COMMENT=22
+MUL=23
+DIV=24
+ADD=25
+SUB=26
+LT=27
+GT=28
+LE=29
+GE=30
+EQ=31
+NE=32
+GLOBAL_VAR=33
+LOCAL_VAR=34
+GRAPH_VAR=35
+MUT=36
+BOOL_LIT=37
+FLOAT=38
+NAT=39
+CNAME=40
+'('=1
+')'=2
+','=3
+'['=4
+']'=5
+'if'=6
+'else'=7
+'let'=8
+'='=9
+';'=10
+'{'=11
+'}'=12
+'fn'=13
+'->'=14
+'def'=15
+':'=16
+'Tensor'=17
+'_'=18
+'v0.0.2'=19
+'*'=23
+'/'=24
+'+'=25
+'-'=26
+'<'=27
+'>'=28
+'<='=29
+'>='=30
+'=='=31
+'!='=32
+'mut'=36
--- /dev/null
+token literal names:
+null
+'('
+')'
+','
+'['
+']'
+'if'
+'else'
+'let'
+'='
+';'
+'{'
+'}'
+'fn'
+'->'
+'def'
+':'
+'Tensor'
+'_'
+'v0.0.2'
+null
+null
+null
+'*'
+'/'
+'+'
+'-'
+'<'
+'>'
+'<='
+'>='
+'=='
+'!='
+null
+null
+null
+'mut'
+null
+null
+null
+null
+
+token symbolic names:
+null
+null
+null
+null
+null
+null
+null
+null
+null
+null
+null
+null
+null
+null
+null
+null
+null
+null
+null
+SEMVER
+WS
+LINE_COMMENT
+COMMENT
+MUL
+DIV
+ADD
+SUB
+LT
+GT
+LE
+GE
+EQ
+NE
+GLOBAL_VAR
+LOCAL_VAR
+GRAPH_VAR
+MUT
+BOOL_LIT
+FLOAT
+NAT
+CNAME
+
+rule names:
+T__0
+T__1
+T__2
+T__3
+T__4
+T__5
+T__6
+T__7
+T__8
+T__9
+T__10
+T__11
+T__12
+T__13
+T__14
+T__15
+T__16
+T__17
+SEMVER
+WS
+LINE_COMMENT
+COMMENT
+MUL
+DIV
+ADD
+SUB
+LT
+GT
+LE
+GE
+EQ
+NE
+GLOBAL_VAR
+LOCAL_VAR
+GRAPH_VAR
+MUT
+BOOL_LIT
+FLOAT
+NAT
+EXP
+CNAME
+LETTER
+DIGIT
+
+channel names:
+DEFAULT_TOKEN_CHANNEL
+HIDDEN
+
+mode names:
+DEFAULT_MODE
+
+atn:
+[3, 24715, 42794, 33075, 47597, 16764, 15335, 30598, 22884, 2, 42, 267, 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, 4, 14, 9, 14, 4, 15, 9, 15, 4, 16, 9, 16, 4, 17, 9, 17, 4, 18, 9, 18, 4, 19, 9, 19, 4, 20, 9, 20, 4, 21, 9, 21, 4, 22, 9, 22, 4, 23, 9, 23, 4, 24, 9, 24, 4, 25, 9, 25, 4, 26, 9, 26, 4, 27, 9, 27, 4, 28, 9, 28, 4, 29, 9, 29, 4, 30, 9, 30, 4, 31, 9, 31, 4, 32, 9, 32, 4, 33, 9, 33, 4, 34, 9, 34, 4, 35, 9, 35, 4, 36, 9, 36, 4, 37, 9, 37, 4, 38, 9, 38, 4, 39, 9, 39, 4, 40, 9, 40, 4, 41, 9, 41, 4, 42, 9, 42, 4, 43, 9, 43, 4, 44, 9, 44, 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, 7, 3, 8, 3, 8, 3, 8, 3, 8, 3, 8, 3, 9, 3, 9, 3, 9, 3, 9, 3, 10, 3, 10, 3, 11, 3, 11, 3, 12, 3, 12, 3, 13, 3, 13, 3, 14, 3, 14, 3, 14, 3, 15, 3, 15, 3, 15, 3, 16, 3, 16, 3, 16, 3, 16, 3, 17, 3, 17, 3, 18, 3, 18, 3, 18, 3, 18, 3, 18, 3, 18, 3, 18, 3, 19, 3, 19, 3, 20, 3, 20, 3, 20, 3, 20, 3, 20, 3, 20, 3, 20, 3, 21, 6, 21, 149, 10, 21, 13, 21, 14, 21, 150, 3, 21, 3, 21, 3, 22, 3, 22, 3, 22, 3, 22, 7, 22, 159, 10, 22, 12, 22, 14, 22, 162, 11, 22, 3, 22, 3, 22, 3, 22, 3, 22, 3, 23, 3, 23, 3, 23, 3, 23, 7, 23, 172, 10, 23, 12, 23, 14, 23, 175, 11, 23, 3, 23, 3, 23, 3, 23, 3, 23, 3, 23, 3, 24, 3, 24, 3, 25, 3, 25, 3, 26, 3, 26, 3, 27, 3, 27, 3, 28, 3, 28, 3, 29, 3, 29, 3, 30, 3, 30, 3, 30, 3, 31, 3, 31, 3, 31, 3, 32, 3, 32, 3, 32, 3, 33, 3, 33, 3, 33, 3, 34, 3, 34, 3, 34, 3, 35, 3, 35, 3, 35, 3, 36, 3, 36, 3, 36, 3, 37, 3, 37, 3, 37, 3, 37, 3, 38, 3, 38, 3, 38, 3, 38, 3, 38, 3, 38, 3, 38, 3, 38, 3, 38, 5, 38, 228, 10, 38, 3, 39, 3, 39, 3, 39, 3, 39, 5, 39, 234, 10, 39, 3, 39, 3, 39, 3, 39, 5, 39, 239, 10, 39, 3, 40, 6, 40, 242, 10, 40, 13, 40, 14, 40, 243, 3, 41, 3, 41, 5, 41, 248, 10, 41, 3, 41, 3, 41, 3, 42, 3, 42, 5, 42, 254, 10, 42, 3, 42, 3, 42, 3, 42, 7, 42, 259, 10, 42, 12, 42, 14, 42, 262, 11, 42, 3, 43, 3, 43, 3, 44, 3, 44, 4, 160, 173, 2, 45, 3, 3, 5, 4, 7, 5, 9, 6, 11, 7, 13, 8, 15, 9, 17, 10, 19, 11, 21, 12, 23, 13, 25, 14, 27, 15, 29, 16, 31, 17, 33, 18, 35, 19, 37, 20, 39, 21, 41, 22, 43, 23, 45, 24, 47, 25, 49, 26, 51, 27, 53, 28, 55, 29, 57, 30, 59, 31, 61, 32, 63, 33, 65, 34, 67, 35, 69, 36, 71, 37, 73, 38, 75, 39, 77, 40, 79, 41, 81, 2, 83, 42, 85, 2, 87, 2, 3, 2, 7, 5, 2, 11, 12, 15, 15, 34, 34, 4, 2, 71, 71, 103, 103, 4, 2, 45, 45, 47, 47, 4, 2, 67, 92, 99, 124, 3, 2, 50, 59, 2, 275, 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, 15, 3, 2, 2, 2, 2, 17, 3, 2, 2, 2, 2, 19, 3, 2, 2, 2, 2, 21, 3, 2, 2, 2, 2, 23, 3, 2, 2, 2, 2, 25, 3, 2, 2, 2, 2, 27, 3, 2, 2, 2, 2, 29, 3, 2, 2, 2, 2, 31, 3, 2, 2, 2, 2, 33, 3, 2, 2, 2, 2, 35, 3, 2, 2, 2, 2, 37, 3, 2, 2, 2, 2, 39, 3, 2, 2, 2, 2, 41, 3, 2, 2, 2, 2, 43, 3, 2, 2, 2, 2, 45, 3, 2, 2, 2, 2, 47, 3, 2, 2, 2, 2, 49, 3, 2, 2, 2, 2, 51, 3, 2, 2, 2, 2, 53, 3, 2, 2, 2, 2, 55, 3, 2, 2, 2, 2, 57, 3, 2, 2, 2, 2, 59, 3, 2, 2, 2, 2, 61, 3, 2, 2, 2, 2, 63, 3, 2, 2, 2, 2, 65, 3, 2, 2, 2, 2, 67, 3, 2, 2, 2, 2, 69, 3, 2, 2, 2, 2, 71, 3, 2, 2, 2, 2, 73, 3, 2, 2, 2, 2, 75, 3, 2, 2, 2, 2, 77, 3, 2, 2, 2, 2, 79, 3, 2, 2, 2, 2, 83, 3, 2, 2, 2, 3, 89, 3, 2, 2, 2, 5, 91, 3, 2, 2, 2, 7, 93, 3, 2, 2, 2, 9, 95, 3, 2, 2, 2, 11, 97, 3, 2, 2, 2, 13, 99, 3, 2, 2, 2, 15, 102, 3, 2, 2, 2, 17, 107, 3, 2, 2, 2, 19, 111, 3, 2, 2, 2, 21, 113, 3, 2, 2, 2, 23, 115, 3, 2, 2, 2, 25, 117, 3, 2, 2, 2, 27, 119, 3, 2, 2, 2, 29, 122, 3, 2, 2, 2, 31, 125, 3, 2, 2, 2, 33, 129, 3, 2, 2, 2, 35, 131, 3, 2, 2, 2, 37, 138, 3, 2, 2, 2, 39, 140, 3, 2, 2, 2, 41, 148, 3, 2, 2, 2, 43, 154, 3, 2, 2, 2, 45, 167, 3, 2, 2, 2, 47, 181, 3, 2, 2, 2, 49, 183, 3, 2, 2, 2, 51, 185, 3, 2, 2, 2, 53, 187, 3, 2, 2, 2, 55, 189, 3, 2, 2, 2, 57, 191, 3, 2, 2, 2, 59, 193, 3, 2, 2, 2, 61, 196, 3, 2, 2, 2, 63, 199, 3, 2, 2, 2, 65, 202, 3, 2, 2, 2, 67, 205, 3, 2, 2, 2, 69, 208, 3, 2, 2, 2, 71, 211, 3, 2, 2, 2, 73, 214, 3, 2, 2, 2, 75, 227, 3, 2, 2, 2, 77, 238, 3, 2, 2, 2, 79, 241, 3, 2, 2, 2, 81, 245, 3, 2, 2, 2, 83, 253, 3, 2, 2, 2, 85, 263, 3, 2, 2, 2, 87, 265, 3, 2, 2, 2, 89, 90, 7, 42, 2, 2, 90, 4, 3, 2, 2, 2, 91, 92, 7, 43, 2, 2, 92, 6, 3, 2, 2, 2, 93, 94, 7, 46, 2, 2, 94, 8, 3, 2, 2, 2, 95, 96, 7, 93, 2, 2, 96, 10, 3, 2, 2, 2, 97, 98, 7, 95, 2, 2, 98, 12, 3, 2, 2, 2, 99, 100, 7, 107, 2, 2, 100, 101, 7, 104, 2, 2, 101, 14, 3, 2, 2, 2, 102, 103, 7, 103, 2, 2, 103, 104, 7, 110, 2, 2, 104, 105, 7, 117, 2, 2, 105, 106, 7, 103, 2, 2, 106, 16, 3, 2, 2, 2, 107, 108, 7, 110, 2, 2, 108, 109, 7, 103, 2, 2, 109, 110, 7, 118, 2, 2, 110, 18, 3, 2, 2, 2, 111, 112, 7, 63, 2, 2, 112, 20, 3, 2, 2, 2, 113, 114, 7, 61, 2, 2, 114, 22, 3, 2, 2, 2, 115, 116, 7, 125, 2, 2, 116, 24, 3, 2, 2, 2, 117, 118, 7, 127, 2, 2, 118, 26, 3, 2, 2, 2, 119, 120, 7, 104, 2, 2, 120, 121, 7, 112, 2, 2, 121, 28, 3, 2, 2, 2, 122, 123, 7, 47, 2, 2, 123, 124, 7, 64, 2, 2, 124, 30, 3, 2, 2, 2, 125, 126, 7, 102, 2, 2, 126, 127, 7, 103, 2, 2, 127, 128, 7, 104, 2, 2, 128, 32, 3, 2, 2, 2, 129, 130, 7, 60, 2, 2, 130, 34, 3, 2, 2, 2, 131, 132, 7, 86, 2, 2, 132, 133, 7, 103, 2, 2, 133, 134, 7, 112, 2, 2, 134, 135, 7, 117, 2, 2, 135, 136, 7, 113, 2, 2, 136, 137, 7, 116, 2, 2, 137, 36, 3, 2, 2, 2, 138, 139, 7, 97, 2, 2, 139, 38, 3, 2, 2, 2, 140, 141, 7, 120, 2, 2, 141, 142, 7, 50, 2, 2, 142, 143, 7, 48, 2, 2, 143, 144, 7, 50, 2, 2, 144, 145, 7, 48, 2, 2, 145, 146, 7, 52, 2, 2, 146, 40, 3, 2, 2, 2, 147, 149, 9, 2, 2, 2, 148, 147, 3, 2, 2, 2, 149, 150, 3, 2, 2, 2, 150, 148, 3, 2, 2, 2, 150, 151, 3, 2, 2, 2, 151, 152, 3, 2, 2, 2, 152, 153, 8, 21, 2, 2, 153, 42, 3, 2, 2, 2, 154, 155, 7, 49, 2, 2, 155, 156, 7, 49, 2, 2, 156, 160, 3, 2, 2, 2, 157, 159, 11, 2, 2, 2, 158, 157, 3, 2, 2, 2, 159, 162, 3, 2, 2, 2, 160, 161, 3, 2, 2, 2, 160, 158, 3, 2, 2, 2, 161, 163, 3, 2, 2, 2, 162, 160, 3, 2, 2, 2, 163, 164, 7, 12, 2, 2, 164, 165, 3, 2, 2, 2, 165, 166, 8, 22, 2, 2, 166, 44, 3, 2, 2, 2, 167, 168, 7, 49, 2, 2, 168, 169, 7, 44, 2, 2, 169, 173, 3, 2, 2, 2, 170, 172, 11, 2, 2, 2, 171, 170, 3, 2, 2, 2, 172, 175, 3, 2, 2, 2, 173, 174, 3, 2, 2, 2, 173, 171, 3, 2, 2, 2, 174, 176, 3, 2, 2, 2, 175, 173, 3, 2, 2, 2, 176, 177, 7, 44, 2, 2, 177, 178, 7, 49, 2, 2, 178, 179, 3, 2, 2, 2, 179, 180, 8, 23, 2, 2, 180, 46, 3, 2, 2, 2, 181, 182, 7, 44, 2, 2, 182, 48, 3, 2, 2, 2, 183, 184, 7, 49, 2, 2, 184, 50, 3, 2, 2, 2, 185, 186, 7, 45, 2, 2, 186, 52, 3, 2, 2, 2, 187, 188, 7, 47, 2, 2, 188, 54, 3, 2, 2, 2, 189, 190, 7, 62, 2, 2, 190, 56, 3, 2, 2, 2, 191, 192, 7, 64, 2, 2, 192, 58, 3, 2, 2, 2, 193, 194, 7, 62, 2, 2, 194, 195, 7, 63, 2, 2, 195, 60, 3, 2, 2, 2, 196, 197, 7, 64, 2, 2, 197, 198, 7, 63, 2, 2, 198, 62, 3, 2, 2, 2, 199, 200, 7, 63, 2, 2, 200, 201, 7, 63, 2, 2, 201, 64, 3, 2, 2, 2, 202, 203, 7, 35, 2, 2, 203, 204, 7, 63, 2, 2, 204, 66, 3, 2, 2, 2, 205, 206, 7, 66, 2, 2, 206, 207, 5, 83, 42, 2, 207, 68, 3, 2, 2, 2, 208, 209, 7, 39, 2, 2, 209, 210, 5, 83, 42, 2, 210, 70, 3, 2, 2, 2, 211, 212, 7, 39, 2, 2, 212, 213, 5, 79, 40, 2, 213, 72, 3, 2, 2, 2, 214, 215, 7, 111, 2, 2, 215, 216, 7, 119, 2, 2, 216, 217, 7, 118, 2, 2, 217, 74, 3, 2, 2, 2, 218, 219, 7, 86, 2, 2, 219, 220, 7, 116, 2, 2, 220, 221, 7, 119, 2, 2, 221, 228, 7, 103, 2, 2, 222, 223, 7, 72, 2, 2, 223, 224, 7, 99, 2, 2, 224, 225, 7, 110, 2, 2, 225, 226, 7, 117, 2, 2, 226, 228, 7, 103, 2, 2, 227, 218, 3, 2, 2, 2, 227, 222, 3, 2, 2, 2, 228, 76, 3, 2, 2, 2, 229, 230, 5, 79, 40, 2, 230, 231, 7, 48, 2, 2, 231, 233, 5, 79, 40, 2, 232, 234, 5, 81, 41, 2, 233, 232, 3, 2, 2, 2, 233, 234, 3, 2, 2, 2, 234, 239, 3, 2, 2, 2, 235, 236, 5, 79, 40, 2, 236, 237, 5, 81, 41, 2, 237, 239, 3, 2, 2, 2, 238, 229, 3, 2, 2, 2, 238, 235, 3, 2, 2, 2, 239, 78, 3, 2, 2, 2, 240, 242, 5, 87, 44, 2, 241, 240, 3, 2, 2, 2, 242, 243, 3, 2, 2, 2, 243, 241, 3, 2, 2, 2, 243, 244, 3, 2, 2, 2, 244, 80, 3, 2, 2, 2, 245, 247, 9, 3, 2, 2, 246, 248, 9, 4, 2, 2, 247, 246, 3, 2, 2, 2, 247, 248, 3, 2, 2, 2, 248, 249, 3, 2, 2, 2, 249, 250, 5, 79, 40, 2, 250, 82, 3, 2, 2, 2, 251, 254, 7, 97, 2, 2, 252, 254, 5, 85, 43, 2, 253, 251, 3, 2, 2, 2, 253, 252, 3, 2, 2, 2, 254, 260, 3, 2, 2, 2, 255, 259, 7, 97, 2, 2, 256, 259, 5, 85, 43, 2, 257, 259, 5, 87, 44, 2, 258, 255, 3, 2, 2, 2, 258, 256, 3, 2, 2, 2, 258, 257, 3, 2, 2, 2, 259, 262, 3, 2, 2, 2, 260, 258, 3, 2, 2, 2, 260, 261, 3, 2, 2, 2, 261, 84, 3, 2, 2, 2, 262, 260, 3, 2, 2, 2, 263, 264, 9, 5, 2, 2, 264, 86, 3, 2, 2, 2, 265, 266, 9, 6, 2, 2, 266, 88, 3, 2, 2, 2, 14, 2, 150, 160, 173, 227, 233, 238, 243, 247, 253, 258, 260, 3, 8, 2, 2]
\ No newline at end of file
--- /dev/null
+# Generated from /home/sslyu/tvm/python/tvm/relay/grammar/Relay.g4 by ANTLR 4.7.2
+# encoding: utf-8
+from __future__ import print_function
+from antlr4 import *
+from io import StringIO
+import sys
+
+
+
+def serializedATN():
+ with StringIO() as buf:
+ buf.write(u"\3\u608b\ua72a\u8133\ub9ed\u417c\u3be7\u7786\u5964\2")
+ buf.write(u"*\u010b\b\1\4\2\t\2\4\3\t\3\4\4\t\4\4\5\t\5\4\6\t\6\4")
+ buf.write(u"\7\t\7\4\b\t\b\4\t\t\t\4\n\t\n\4\13\t\13\4\f\t\f\4\r")
+ buf.write(u"\t\r\4\16\t\16\4\17\t\17\4\20\t\20\4\21\t\21\4\22\t\22")
+ buf.write(u"\4\23\t\23\4\24\t\24\4\25\t\25\4\26\t\26\4\27\t\27\4")
+ buf.write(u"\30\t\30\4\31\t\31\4\32\t\32\4\33\t\33\4\34\t\34\4\35")
+ buf.write(u"\t\35\4\36\t\36\4\37\t\37\4 \t \4!\t!\4\"\t\"\4#\t#\4")
+ buf.write(u"$\t$\4%\t%\4&\t&\4\'\t\'\4(\t(\4)\t)\4*\t*\4+\t+\4,\t")
+ buf.write(u",\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\7")
+ buf.write(u"\3\b\3\b\3\b\3\b\3\b\3\t\3\t\3\t\3\t\3\n\3\n\3\13\3\13")
+ buf.write(u"\3\f\3\f\3\r\3\r\3\16\3\16\3\16\3\17\3\17\3\17\3\20\3")
+ buf.write(u"\20\3\20\3\20\3\21\3\21\3\22\3\22\3\22\3\22\3\22\3\22")
+ buf.write(u"\3\22\3\23\3\23\3\24\3\24\3\24\3\24\3\24\3\24\3\24\3")
+ buf.write(u"\25\6\25\u0095\n\25\r\25\16\25\u0096\3\25\3\25\3\26\3")
+ buf.write(u"\26\3\26\3\26\7\26\u009f\n\26\f\26\16\26\u00a2\13\26")
+ buf.write(u"\3\26\3\26\3\26\3\26\3\27\3\27\3\27\3\27\7\27\u00ac\n")
+ buf.write(u"\27\f\27\16\27\u00af\13\27\3\27\3\27\3\27\3\27\3\27\3")
+ buf.write(u"\30\3\30\3\31\3\31\3\32\3\32\3\33\3\33\3\34\3\34\3\35")
+ buf.write(u"\3\35\3\36\3\36\3\36\3\37\3\37\3\37\3 \3 \3 \3!\3!\3")
+ buf.write(u"!\3\"\3\"\3\"\3#\3#\3#\3$\3$\3$\3%\3%\3%\3%\3&\3&\3&")
+ buf.write(u"\3&\3&\3&\3&\3&\3&\5&\u00e4\n&\3\'\3\'\3\'\3\'\5\'\u00ea")
+ buf.write(u"\n\'\3\'\3\'\3\'\5\'\u00ef\n\'\3(\6(\u00f2\n(\r(\16(")
+ buf.write(u"\u00f3\3)\3)\5)\u00f8\n)\3)\3)\3*\3*\5*\u00fe\n*\3*\3")
+ buf.write(u"*\3*\7*\u0103\n*\f*\16*\u0106\13*\3+\3+\3,\3,\4\u00a0")
+ buf.write(u"\u00ad\2-\3\3\5\4\7\5\t\6\13\7\r\b\17\t\21\n\23\13\25")
+ buf.write(u"\f\27\r\31\16\33\17\35\20\37\21!\22#\23%\24\'\25)\26")
+ buf.write(u"+\27-\30/\31\61\32\63\33\65\34\67\359\36;\37= ?!A\"C")
+ buf.write(u"#E$G%I&K\'M(O)Q\2S*U\2W\2\3\2\7\5\2\13\f\17\17\"\"\4")
+ buf.write(u"\2GGgg\4\2--//\4\2C\\c|\3\2\62;\2\u0113\2\3\3\2\2\2\2")
+ buf.write(u"\5\3\2\2\2\2\7\3\2\2\2\2\t\3\2\2\2\2\13\3\2\2\2\2\r\3")
+ buf.write(u"\2\2\2\2\17\3\2\2\2\2\21\3\2\2\2\2\23\3\2\2\2\2\25\3")
+ buf.write(u"\2\2\2\2\27\3\2\2\2\2\31\3\2\2\2\2\33\3\2\2\2\2\35\3")
+ buf.write(u"\2\2\2\2\37\3\2\2\2\2!\3\2\2\2\2#\3\2\2\2\2%\3\2\2\2")
+ buf.write(u"\2\'\3\2\2\2\2)\3\2\2\2\2+\3\2\2\2\2-\3\2\2\2\2/\3\2")
+ buf.write(u"\2\2\2\61\3\2\2\2\2\63\3\2\2\2\2\65\3\2\2\2\2\67\3\2")
+ buf.write(u"\2\2\29\3\2\2\2\2;\3\2\2\2\2=\3\2\2\2\2?\3\2\2\2\2A\3")
+ buf.write(u"\2\2\2\2C\3\2\2\2\2E\3\2\2\2\2G\3\2\2\2\2I\3\2\2\2\2")
+ buf.write(u"K\3\2\2\2\2M\3\2\2\2\2O\3\2\2\2\2S\3\2\2\2\3Y\3\2\2\2")
+ buf.write(u"\5[\3\2\2\2\7]\3\2\2\2\t_\3\2\2\2\13a\3\2\2\2\rc\3\2")
+ buf.write(u"\2\2\17f\3\2\2\2\21k\3\2\2\2\23o\3\2\2\2\25q\3\2\2\2")
+ buf.write(u"\27s\3\2\2\2\31u\3\2\2\2\33w\3\2\2\2\35z\3\2\2\2\37}")
+ buf.write(u"\3\2\2\2!\u0081\3\2\2\2#\u0083\3\2\2\2%\u008a\3\2\2\2")
+ buf.write(u"\'\u008c\3\2\2\2)\u0094\3\2\2\2+\u009a\3\2\2\2-\u00a7")
+ buf.write(u"\3\2\2\2/\u00b5\3\2\2\2\61\u00b7\3\2\2\2\63\u00b9\3\2")
+ buf.write(u"\2\2\65\u00bb\3\2\2\2\67\u00bd\3\2\2\29\u00bf\3\2\2\2")
+ buf.write(u";\u00c1\3\2\2\2=\u00c4\3\2\2\2?\u00c7\3\2\2\2A\u00ca")
+ buf.write(u"\3\2\2\2C\u00cd\3\2\2\2E\u00d0\3\2\2\2G\u00d3\3\2\2\2")
+ buf.write(u"I\u00d6\3\2\2\2K\u00e3\3\2\2\2M\u00ee\3\2\2\2O\u00f1")
+ buf.write(u"\3\2\2\2Q\u00f5\3\2\2\2S\u00fd\3\2\2\2U\u0107\3\2\2\2")
+ buf.write(u"W\u0109\3\2\2\2YZ\7*\2\2Z\4\3\2\2\2[\\\7+\2\2\\\6\3\2")
+ buf.write(u"\2\2]^\7.\2\2^\b\3\2\2\2_`\7]\2\2`\n\3\2\2\2ab\7_\2\2")
+ buf.write(u"b\f\3\2\2\2cd\7k\2\2de\7h\2\2e\16\3\2\2\2fg\7g\2\2gh")
+ buf.write(u"\7n\2\2hi\7u\2\2ij\7g\2\2j\20\3\2\2\2kl\7n\2\2lm\7g\2")
+ buf.write(u"\2mn\7v\2\2n\22\3\2\2\2op\7?\2\2p\24\3\2\2\2qr\7=\2\2")
+ buf.write(u"r\26\3\2\2\2st\7}\2\2t\30\3\2\2\2uv\7\177\2\2v\32\3\2")
+ buf.write(u"\2\2wx\7h\2\2xy\7p\2\2y\34\3\2\2\2z{\7/\2\2{|\7@\2\2")
+ buf.write(u"|\36\3\2\2\2}~\7f\2\2~\177\7g\2\2\177\u0080\7h\2\2\u0080")
+ buf.write(u" \3\2\2\2\u0081\u0082\7<\2\2\u0082\"\3\2\2\2\u0083\u0084")
+ buf.write(u"\7V\2\2\u0084\u0085\7g\2\2\u0085\u0086\7p\2\2\u0086\u0087")
+ buf.write(u"\7u\2\2\u0087\u0088\7q\2\2\u0088\u0089\7t\2\2\u0089$")
+ buf.write(u"\3\2\2\2\u008a\u008b\7a\2\2\u008b&\3\2\2\2\u008c\u008d")
+ buf.write(u"\7x\2\2\u008d\u008e\7\62\2\2\u008e\u008f\7\60\2\2\u008f")
+ buf.write(u"\u0090\7\62\2\2\u0090\u0091\7\60\2\2\u0091\u0092\7\64")
+ buf.write(u"\2\2\u0092(\3\2\2\2\u0093\u0095\t\2\2\2\u0094\u0093\3")
+ buf.write(u"\2\2\2\u0095\u0096\3\2\2\2\u0096\u0094\3\2\2\2\u0096")
+ buf.write(u"\u0097\3\2\2\2\u0097\u0098\3\2\2\2\u0098\u0099\b\25\2")
+ buf.write(u"\2\u0099*\3\2\2\2\u009a\u009b\7\61\2\2\u009b\u009c\7")
+ buf.write(u"\61\2\2\u009c\u00a0\3\2\2\2\u009d\u009f\13\2\2\2\u009e")
+ buf.write(u"\u009d\3\2\2\2\u009f\u00a2\3\2\2\2\u00a0\u00a1\3\2\2")
+ buf.write(u"\2\u00a0\u009e\3\2\2\2\u00a1\u00a3\3\2\2\2\u00a2\u00a0")
+ buf.write(u"\3\2\2\2\u00a3\u00a4\7\f\2\2\u00a4\u00a5\3\2\2\2\u00a5")
+ buf.write(u"\u00a6\b\26\2\2\u00a6,\3\2\2\2\u00a7\u00a8\7\61\2\2\u00a8")
+ buf.write(u"\u00a9\7,\2\2\u00a9\u00ad\3\2\2\2\u00aa\u00ac\13\2\2")
+ buf.write(u"\2\u00ab\u00aa\3\2\2\2\u00ac\u00af\3\2\2\2\u00ad\u00ae")
+ buf.write(u"\3\2\2\2\u00ad\u00ab\3\2\2\2\u00ae\u00b0\3\2\2\2\u00af")
+ buf.write(u"\u00ad\3\2\2\2\u00b0\u00b1\7,\2\2\u00b1\u00b2\7\61\2")
+ buf.write(u"\2\u00b2\u00b3\3\2\2\2\u00b3\u00b4\b\27\2\2\u00b4.\3")
+ buf.write(u"\2\2\2\u00b5\u00b6\7,\2\2\u00b6\60\3\2\2\2\u00b7\u00b8")
+ buf.write(u"\7\61\2\2\u00b8\62\3\2\2\2\u00b9\u00ba\7-\2\2\u00ba\64")
+ buf.write(u"\3\2\2\2\u00bb\u00bc\7/\2\2\u00bc\66\3\2\2\2\u00bd\u00be")
+ buf.write(u"\7>\2\2\u00be8\3\2\2\2\u00bf\u00c0\7@\2\2\u00c0:\3\2")
+ buf.write(u"\2\2\u00c1\u00c2\7>\2\2\u00c2\u00c3\7?\2\2\u00c3<\3\2")
+ buf.write(u"\2\2\u00c4\u00c5\7@\2\2\u00c5\u00c6\7?\2\2\u00c6>\3\2")
+ buf.write(u"\2\2\u00c7\u00c8\7?\2\2\u00c8\u00c9\7?\2\2\u00c9@\3\2")
+ buf.write(u"\2\2\u00ca\u00cb\7#\2\2\u00cb\u00cc\7?\2\2\u00ccB\3\2")
+ buf.write(u"\2\2\u00cd\u00ce\7B\2\2\u00ce\u00cf\5S*\2\u00cfD\3\2")
+ buf.write(u"\2\2\u00d0\u00d1\7\'\2\2\u00d1\u00d2\5S*\2\u00d2F\3\2")
+ buf.write(u"\2\2\u00d3\u00d4\7\'\2\2\u00d4\u00d5\5O(\2\u00d5H\3\2")
+ buf.write(u"\2\2\u00d6\u00d7\7o\2\2\u00d7\u00d8\7w\2\2\u00d8\u00d9")
+ buf.write(u"\7v\2\2\u00d9J\3\2\2\2\u00da\u00db\7V\2\2\u00db\u00dc")
+ buf.write(u"\7t\2\2\u00dc\u00dd\7w\2\2\u00dd\u00e4\7g\2\2\u00de\u00df")
+ buf.write(u"\7H\2\2\u00df\u00e0\7c\2\2\u00e0\u00e1\7n\2\2\u00e1\u00e2")
+ buf.write(u"\7u\2\2\u00e2\u00e4\7g\2\2\u00e3\u00da\3\2\2\2\u00e3")
+ buf.write(u"\u00de\3\2\2\2\u00e4L\3\2\2\2\u00e5\u00e6\5O(\2\u00e6")
+ buf.write(u"\u00e7\7\60\2\2\u00e7\u00e9\5O(\2\u00e8\u00ea\5Q)\2\u00e9")
+ buf.write(u"\u00e8\3\2\2\2\u00e9\u00ea\3\2\2\2\u00ea\u00ef\3\2\2")
+ buf.write(u"\2\u00eb\u00ec\5O(\2\u00ec\u00ed\5Q)\2\u00ed\u00ef\3")
+ buf.write(u"\2\2\2\u00ee\u00e5\3\2\2\2\u00ee\u00eb\3\2\2\2\u00ef")
+ buf.write(u"N\3\2\2\2\u00f0\u00f2\5W,\2\u00f1\u00f0\3\2\2\2\u00f2")
+ buf.write(u"\u00f3\3\2\2\2\u00f3\u00f1\3\2\2\2\u00f3\u00f4\3\2\2")
+ buf.write(u"\2\u00f4P\3\2\2\2\u00f5\u00f7\t\3\2\2\u00f6\u00f8\t\4")
+ buf.write(u"\2\2\u00f7\u00f6\3\2\2\2\u00f7\u00f8\3\2\2\2\u00f8\u00f9")
+ buf.write(u"\3\2\2\2\u00f9\u00fa\5O(\2\u00faR\3\2\2\2\u00fb\u00fe")
+ buf.write(u"\7a\2\2\u00fc\u00fe\5U+\2\u00fd\u00fb\3\2\2\2\u00fd\u00fc")
+ buf.write(u"\3\2\2\2\u00fe\u0104\3\2\2\2\u00ff\u0103\7a\2\2\u0100")
+ buf.write(u"\u0103\5U+\2\u0101\u0103\5W,\2\u0102\u00ff\3\2\2\2\u0102")
+ buf.write(u"\u0100\3\2\2\2\u0102\u0101\3\2\2\2\u0103\u0106\3\2\2")
+ buf.write(u"\2\u0104\u0102\3\2\2\2\u0104\u0105\3\2\2\2\u0105T\3\2")
+ buf.write(u"\2\2\u0106\u0104\3\2\2\2\u0107\u0108\t\5\2\2\u0108V\3")
+ buf.write(u"\2\2\2\u0109\u010a\t\6\2\2\u010aX\3\2\2\2\16\2\u0096")
+ buf.write(u"\u00a0\u00ad\u00e3\u00e9\u00ee\u00f3\u00f7\u00fd\u0102")
+ buf.write(u"\u0104\3\b\2\2")
+ return buf.getvalue()
+
+
+class RelayLexer(Lexer):
+
+ atn = ATNDeserializer().deserialize(serializedATN())
+
+ decisionsToDFA = [ DFA(ds, i) for i, ds in enumerate(atn.decisionToState) ]
+
+ T__0 = 1
+ T__1 = 2
+ T__2 = 3
+ T__3 = 4
+ T__4 = 5
+ T__5 = 6
+ T__6 = 7
+ T__7 = 8
+ T__8 = 9
+ T__9 = 10
+ T__10 = 11
+ T__11 = 12
+ T__12 = 13
+ T__13 = 14
+ T__14 = 15
+ T__15 = 16
+ T__16 = 17
+ T__17 = 18
+ SEMVER = 19
+ WS = 20
+ LINE_COMMENT = 21
+ COMMENT = 22
+ MUL = 23
+ DIV = 24
+ ADD = 25
+ SUB = 26
+ LT = 27
+ GT = 28
+ LE = 29
+ GE = 30
+ EQ = 31
+ NE = 32
+ GLOBAL_VAR = 33
+ LOCAL_VAR = 34
+ GRAPH_VAR = 35
+ MUT = 36
+ BOOL_LIT = 37
+ FLOAT = 38
+ NAT = 39
+ CNAME = 40
+
+ channelNames = [ u"DEFAULT_TOKEN_CHANNEL", u"HIDDEN" ]
+
+ modeNames = [ u"DEFAULT_MODE" ]
+
+ literalNames = [ u"<INVALID>",
+ u"'('", u"')'", u"','", u"'['", u"']'", u"'if'", u"'else'",
+ u"'let'", u"'='", u"';'", u"'{'", u"'}'", u"'fn'", u"'->'",
+ u"'def'", u"':'", u"'Tensor'", u"'_'", u"'v0.0.2'", u"'*'",
+ u"'/'", u"'+'", u"'-'", u"'<'", u"'>'", u"'<='", u"'>='", u"'=='",
+ u"'!='", u"'mut'" ]
+
+ symbolicNames = [ u"<INVALID>",
+ u"SEMVER", u"WS", u"LINE_COMMENT", u"COMMENT", u"MUL", u"DIV",
+ u"ADD", u"SUB", u"LT", u"GT", u"LE", u"GE", u"EQ", u"NE", u"GLOBAL_VAR",
+ u"LOCAL_VAR", u"GRAPH_VAR", u"MUT", u"BOOL_LIT", u"FLOAT", u"NAT",
+ u"CNAME" ]
+
+ ruleNames = [ u"T__0", u"T__1", u"T__2", u"T__3", u"T__4", u"T__5",
+ u"T__6", u"T__7", u"T__8", u"T__9", u"T__10", u"T__11",
+ u"T__12", u"T__13", u"T__14", u"T__15", u"T__16", u"T__17",
+ u"SEMVER", u"WS", u"LINE_COMMENT", u"COMMENT", u"MUL",
+ u"DIV", u"ADD", u"SUB", u"LT", u"GT", u"LE", u"GE", u"EQ",
+ u"NE", u"GLOBAL_VAR", u"LOCAL_VAR", u"GRAPH_VAR", u"MUT",
+ u"BOOL_LIT", u"FLOAT", u"NAT", u"EXP", u"CNAME", u"LETTER",
+ u"DIGIT" ]
+
+ grammarFileName = u"Relay.g4"
+
+ def __init__(self, input=None, output=sys.stdout):
+ super(RelayLexer, self).__init__(input, output=output)
+ self.checkVersion("4.7.2")
+ self._interp = LexerATNSimulator(self, self.atn, self.decisionsToDFA, PredictionContextCache())
+ self._actions = None
+ self._predicates = None
+
+
--- /dev/null
+T__0=1
+T__1=2
+T__2=3
+T__3=4
+T__4=5
+T__5=6
+T__6=7
+T__7=8
+T__8=9
+T__9=10
+T__10=11
+T__11=12
+T__12=13
+T__13=14
+T__14=15
+T__15=16
+T__16=17
+T__17=18
+SEMVER=19
+WS=20
+LINE_COMMENT=21
+COMMENT=22
+MUL=23
+DIV=24
+ADD=25
+SUB=26
+LT=27
+GT=28
+LE=29
+GE=30
+EQ=31
+NE=32
+GLOBAL_VAR=33
+LOCAL_VAR=34
+GRAPH_VAR=35
+MUT=36
+BOOL_LIT=37
+FLOAT=38
+NAT=39
+CNAME=40
+'('=1
+')'=2
+','=3
+'['=4
+']'=5
+'if'=6
+'else'=7
+'let'=8
+'='=9
+';'=10
+'{'=11
+'}'=12
+'fn'=13
+'->'=14
+'def'=15
+':'=16
+'Tensor'=17
+'_'=18
+'v0.0.2'=19
+'*'=23
+'/'=24
+'+'=25
+'-'=26
+'<'=27
+'>'=28
+'<='=29
+'>='=30
+'=='=31
+'!='=32
+'mut'=36
--- /dev/null
+# Generated from /home/sslyu/tvm/python/tvm/relay/grammar/Relay.g4 by ANTLR 4.7.2
+# encoding: utf-8
+from __future__ import print_function
+from antlr4 import *
+from io import StringIO
+import sys
+
+
+def serializedATN():
+ with StringIO() as buf:
+ buf.write(u"\3\u608b\ua72a\u8133\ub9ed\u417c\u3be7\u7786\u5964\3")
+ buf.write(u"*\u014c\4\2\t\2\4\3\t\3\4\4\t\4\4\5\t\5\4\6\t\6\4\7\t")
+ buf.write(u"\7\4\b\t\b\4\t\t\t\4\n\t\n\4\13\t\13\4\f\t\f\4\r\t\r")
+ buf.write(u"\4\16\t\16\4\17\t\17\4\20\t\20\4\21\t\21\4\22\t\22\4")
+ buf.write(u"\23\t\23\3\2\3\2\3\3\3\3\7\3+\n\3\f\3\16\3.\13\3\3\3")
+ buf.write(u"\5\3\61\n\3\3\3\3\3\3\4\3\4\3\4\3\4\3\4\3\4\3\4\3\4\3")
+ buf.write(u"\4\3\4\3\4\3\4\3\4\3\4\3\4\3\4\3\4\3\4\3\4\6\4H\n\4\r")
+ buf.write(u"\4\16\4I\3\4\3\4\3\4\3\4\3\4\3\4\7\4R\n\4\f\4\16\4U\13")
+ buf.write(u"\4\5\4W\n\4\3\4\3\4\3\4\3\4\3\4\3\4\3\4\3\4\3\4\3\4\3")
+ buf.write(u"\4\5\4d\n\4\3\4\3\4\3\4\3\4\3\4\3\4\3\4\3\4\5\4n\n\4")
+ buf.write(u"\3\4\3\4\3\4\3\4\3\4\3\4\3\4\3\4\3\4\3\4\3\4\3\4\3\4")
+ buf.write(u"\3\4\3\4\3\4\5\4\u0080\n\4\3\4\3\4\3\4\3\4\3\4\3\4\3")
+ buf.write(u"\4\3\4\3\4\3\4\3\4\3\4\3\4\3\4\3\4\3\4\3\4\3\4\3\4\3")
+ buf.write(u"\4\7\4\u0096\n\4\f\4\16\4\u0099\13\4\5\4\u009b\n\4\3")
+ buf.write(u"\4\7\4\u009e\n\4\f\4\16\4\u00a1\13\4\3\5\3\5\5\5\u00a5")
+ buf.write(u"\n\5\3\5\3\5\3\5\3\5\3\5\5\5\u00ac\n\5\3\5\3\5\3\6\3")
+ buf.write(u"\6\3\6\5\6\u00b3\n\6\3\6\3\6\3\6\3\6\3\6\5\6\u00ba\n")
+ buf.write(u"\6\3\6\3\6\3\7\3\7\3\7\3\7\3\7\3\7\5\7\u00c4\n\7\3\b")
+ buf.write(u"\3\b\3\b\7\b\u00c9\n\b\f\b\16\b\u00cc\13\b\5\b\u00ce")
+ buf.write(u"\n\b\3\t\3\t\3\t\5\t\u00d3\n\t\3\n\3\n\3\n\7\n\u00d8")
+ buf.write(u"\n\n\f\n\16\n\u00db\13\n\5\n\u00dd\n\n\3\13\3\13\3\13")
+ buf.write(u"\3\13\3\f\3\f\3\f\3\f\3\f\3\f\7\f\u00e9\n\f\f\f\16\f")
+ buf.write(u"\u00ec\13\f\3\f\3\f\5\f\u00f0\n\f\3\r\3\r\3\r\3\r\3\r")
+ buf.write(u"\3\r\3\r\3\r\3\r\3\r\3\r\6\r\u00fd\n\r\r\r\16\r\u00fe")
+ buf.write(u"\3\r\3\r\3\r\3\r\3\r\3\r\3\r\3\r\3\r\3\r\3\r\3\r\5\r")
+ buf.write(u"\u010d\n\r\3\r\3\r\3\r\3\r\7\r\u0113\n\r\f\r\16\r\u0116")
+ buf.write(u"\13\r\5\r\u0118\n\r\3\r\3\r\3\r\3\r\3\r\5\r\u011f\n\r")
+ buf.write(u"\3\16\3\16\3\16\3\16\3\16\3\16\3\16\3\16\3\16\3\16\3")
+ buf.write(u"\16\6\16\u012c\n\16\r\16\16\16\u012d\3\16\3\16\5\16\u0132")
+ buf.write(u"\n\16\3\17\3\17\3\17\3\17\3\17\5\17\u0139\n\17\3\20\3")
+ buf.write(u"\20\3\21\3\21\3\21\3\21\3\22\3\22\3\22\5\22\u0144\n\22")
+ buf.write(u"\3\23\3\23\3\23\3\23\5\23\u014a\n\23\3\23\2\3\6\24\2")
+ buf.write(u"\4\6\b\n\f\16\20\22\24\26\30\32\34\36 \"$\2\6\3\2\31")
+ buf.write(u"\32\3\2\33\34\3\2\35 \3\2!\"\2\u0175\2&\3\2\2\2\4(\3")
+ buf.write(u"\2\2\2\6\177\3\2\2\2\b\u00a2\3\2\2\2\n\u00af\3\2\2\2")
+ buf.write(u"\f\u00c3\3\2\2\2\16\u00cd\3\2\2\2\20\u00cf\3\2\2\2\22")
+ buf.write(u"\u00dc\3\2\2\2\24\u00de\3\2\2\2\26\u00ef\3\2\2\2\30\u011e")
+ buf.write(u"\3\2\2\2\32\u0131\3\2\2\2\34\u0138\3\2\2\2\36\u013a\3")
+ buf.write(u"\2\2\2 \u013c\3\2\2\2\"\u0143\3\2\2\2$\u0149\3\2\2\2")
+ buf.write(u"&\'\7*\2\2\'\3\3\2\2\2(\60\7\25\2\2)+\5\n\6\2*)\3\2\2")
+ buf.write(u"\2+.\3\2\2\2,*\3\2\2\2,-\3\2\2\2-\61\3\2\2\2.,\3\2\2")
+ buf.write(u"\2/\61\5\6\4\2\60,\3\2\2\2\60/\3\2\2\2\61\62\3\2\2\2")
+ buf.write(u"\62\63\7\2\2\3\63\5\3\2\2\2\64\65\b\4\1\2\65\66\7\3\2")
+ buf.write(u"\2\66\67\5\6\4\2\678\7\4\2\28\u0080\3\2\2\29:\7\34\2")
+ buf.write(u"\2:\u0080\5\6\4\23;\u0080\5\b\5\2<=\7\3\2\2=\u0080\7")
+ buf.write(u"\4\2\2>?\7\3\2\2?@\5\6\4\2@A\7\5\2\2AB\7\4\2\2B\u0080")
+ buf.write(u"\3\2\2\2CD\7\3\2\2DG\5\6\4\2EF\7\5\2\2FH\5\6\4\2GE\3")
+ buf.write(u"\2\2\2HI\3\2\2\2IG\3\2\2\2IJ\3\2\2\2JK\3\2\2\2KL\7\4")
+ buf.write(u"\2\2L\u0080\3\2\2\2MV\7\6\2\2NS\5\6\4\2OP\7\5\2\2PR\5")
+ buf.write(u"\6\4\2QO\3\2\2\2RU\3\2\2\2SQ\3\2\2\2ST\3\2\2\2TW\3\2")
+ buf.write(u"\2\2US\3\2\2\2VN\3\2\2\2VW\3\2\2\2WX\3\2\2\2X\u0080\7")
+ buf.write(u"\7\2\2YZ\7\b\2\2Z[\7\3\2\2[\\\5\6\4\2\\]\7\4\2\2]^\5")
+ buf.write(u" \21\2^_\7\t\2\2_`\5 \21\2`\u0080\3\2\2\2ac\7\n\2\2b")
+ buf.write(u"d\7&\2\2cb\3\2\2\2cd\3\2\2\2de\3\2\2\2ef\5\20\t\2fg\7")
+ buf.write(u"\13\2\2gh\5\6\4\2hi\7\f\2\2ij\5\6\4\bj\u0080\3\2\2\2")
+ buf.write(u"km\7\n\2\2ln\7&\2\2ml\3\2\2\2mn\3\2\2\2no\3\2\2\2op\5")
+ buf.write(u"\20\t\2pq\7\13\2\2qr\7\r\2\2rs\5\6\4\2st\7\16\2\2tu\7")
+ buf.write(u"\f\2\2uv\5\6\4\7v\u0080\3\2\2\2wx\5$\23\2xy\7\13\2\2")
+ buf.write(u"yz\5\6\4\2z{\7\f\2\2{|\5\6\4\5|\u0080\3\2\2\2}\u0080")
+ buf.write(u"\5$\23\2~\u0080\5\"\22\2\177\64\3\2\2\2\1779\3\2\2\2")
+ buf.write(u"\177;\3\2\2\2\177<\3\2\2\2\177>\3\2\2\2\177C\3\2\2\2")
+ buf.write(u"\177M\3\2\2\2\177Y\3\2\2\2\177a\3\2\2\2\177k\3\2\2\2")
+ buf.write(u"\177w\3\2\2\2\177}\3\2\2\2\177~\3\2\2\2\u0080\u009f\3")
+ buf.write(u"\2\2\2\u0081\u0082\f\22\2\2\u0082\u0083\t\2\2\2\u0083")
+ buf.write(u"\u009e\5\6\4\23\u0084\u0085\f\21\2\2\u0085\u0086\t\3")
+ buf.write(u"\2\2\u0086\u009e\5\6\4\22\u0087\u0088\f\20\2\2\u0088")
+ buf.write(u"\u0089\t\4\2\2\u0089\u009e\5\6\4\21\u008a\u008b\f\17")
+ buf.write(u"\2\2\u008b\u008c\t\5\2\2\u008c\u009e\5\6\4\20\u008d\u008e")
+ buf.write(u"\f\6\2\2\u008e\u008f\7\f\2\2\u008f\u009e\5\6\4\7\u0090")
+ buf.write(u"\u0091\f\24\2\2\u0091\u009a\7\3\2\2\u0092\u0097\5\6\4")
+ buf.write(u"\2\u0093\u0094\7\5\2\2\u0094\u0096\5\6\4\2\u0095\u0093")
+ buf.write(u"\3\2\2\2\u0096\u0099\3\2\2\2\u0097\u0095\3\2\2\2\u0097")
+ buf.write(u"\u0098\3\2\2\2\u0098\u009b\3\2\2\2\u0099\u0097\3\2\2")
+ buf.write(u"\2\u009a\u0092\3\2\2\2\u009a\u009b\3\2\2\2\u009b\u009c")
+ buf.write(u"\3\2\2\2\u009c\u009e\7\4\2\2\u009d\u0081\3\2\2\2\u009d")
+ buf.write(u"\u0084\3\2\2\2\u009d\u0087\3\2\2\2\u009d\u008a\3\2\2")
+ buf.write(u"\2\u009d\u008d\3\2\2\2\u009d\u0090\3\2\2\2\u009e\u00a1")
+ buf.write(u"\3\2\2\2\u009f\u009d\3\2\2\2\u009f\u00a0\3\2\2\2\u00a0")
+ buf.write(u"\7\3\2\2\2\u00a1\u009f\3\2\2\2\u00a2\u00a4\7\17\2\2\u00a3")
+ buf.write(u"\u00a5\5\26\f\2\u00a4\u00a3\3\2\2\2\u00a4\u00a5\3\2\2")
+ buf.write(u"\2\u00a5\u00a6\3\2\2\2\u00a6\u00a7\7\3\2\2\u00a7\u00a8")
+ buf.write(u"\5\f\7\2\u00a8\u00ab\7\4\2\2\u00a9\u00aa\7\20\2\2\u00aa")
+ buf.write(u"\u00ac\5\30\r\2\u00ab\u00a9\3\2\2\2\u00ab\u00ac\3\2\2")
+ buf.write(u"\2\u00ac\u00ad\3\2\2\2\u00ad\u00ae\5 \21\2\u00ae\t\3")
+ buf.write(u"\2\2\2\u00af\u00b0\7\21\2\2\u00b0\u00b2\5$\23\2\u00b1")
+ buf.write(u"\u00b3\5\26\f\2\u00b2\u00b1\3\2\2\2\u00b2\u00b3\3\2\2")
+ buf.write(u"\2\u00b3\u00b4\3\2\2\2\u00b4\u00b5\7\3\2\2\u00b5\u00b6")
+ buf.write(u"\5\f\7\2\u00b6\u00b9\7\4\2\2\u00b7\u00b8\7\20\2\2\u00b8")
+ buf.write(u"\u00ba\5\30\r\2\u00b9\u00b7\3\2\2\2\u00b9\u00ba\3\2\2")
+ buf.write(u"\2\u00ba\u00bb\3\2\2\2\u00bb\u00bc\5 \21\2\u00bc\13\3")
+ buf.write(u"\2\2\2\u00bd\u00c4\5\16\b\2\u00be\u00c4\5\22\n\2\u00bf")
+ buf.write(u"\u00c0\5\16\b\2\u00c0\u00c1\7\5\2\2\u00c1\u00c2\5\22")
+ buf.write(u"\n\2\u00c2\u00c4\3\2\2\2\u00c3\u00bd\3\2\2\2\u00c3\u00be")
+ buf.write(u"\3\2\2\2\u00c3\u00bf\3\2\2\2\u00c4\r\3\2\2\2\u00c5\u00ca")
+ buf.write(u"\5\20\t\2\u00c6\u00c7\7\5\2\2\u00c7\u00c9\5\20\t\2\u00c8")
+ buf.write(u"\u00c6\3\2\2\2\u00c9\u00cc\3\2\2\2\u00ca\u00c8\3\2\2")
+ buf.write(u"\2\u00ca\u00cb\3\2\2\2\u00cb\u00ce\3\2\2\2\u00cc\u00ca")
+ buf.write(u"\3\2\2\2\u00cd\u00c5\3\2\2\2\u00cd\u00ce\3\2\2\2\u00ce")
+ buf.write(u"\17\3\2\2\2\u00cf\u00d2\5$\23\2\u00d0\u00d1\7\22\2\2")
+ buf.write(u"\u00d1\u00d3\5\30\r\2\u00d2\u00d0\3\2\2\2\u00d2\u00d3")
+ buf.write(u"\3\2\2\2\u00d3\21\3\2\2\2\u00d4\u00d9\5\24\13\2\u00d5")
+ buf.write(u"\u00d6\7\5\2\2\u00d6\u00d8\5\24\13\2\u00d7\u00d5\3\2")
+ buf.write(u"\2\2\u00d8\u00db\3\2\2\2\u00d9\u00d7\3\2\2\2\u00d9\u00da")
+ buf.write(u"\3\2\2\2\u00da\u00dd\3\2\2\2\u00db\u00d9\3\2\2\2\u00dc")
+ buf.write(u"\u00d4\3\2\2\2\u00dc\u00dd\3\2\2\2\u00dd\23\3\2\2\2\u00de")
+ buf.write(u"\u00df\7*\2\2\u00df\u00e0\7\13\2\2\u00e0\u00e1\5\6\4")
+ buf.write(u"\2\u00e1\25\3\2\2\2\u00e2\u00e3\7\6\2\2\u00e3\u00f0\7")
+ buf.write(u"\7\2\2\u00e4\u00e5\7\6\2\2\u00e5\u00ea\5$\23\2\u00e6")
+ buf.write(u"\u00e7\7\5\2\2\u00e7\u00e9\5$\23\2\u00e8\u00e6\3\2\2")
+ buf.write(u"\2\u00e9\u00ec\3\2\2\2\u00ea\u00e8\3\2\2\2\u00ea\u00eb")
+ buf.write(u"\3\2\2\2\u00eb\u00ed\3\2\2\2\u00ec\u00ea\3\2\2\2\u00ed")
+ buf.write(u"\u00ee\7\7\2\2\u00ee\u00f0\3\2\2\2\u00ef\u00e2\3\2\2")
+ buf.write(u"\2\u00ef\u00e4\3\2\2\2\u00f0\27\3\2\2\2\u00f1\u00f2\7")
+ buf.write(u"\3\2\2\u00f2\u011f\7\4\2\2\u00f3\u00f4\7\3\2\2\u00f4")
+ buf.write(u"\u00f5\5\30\r\2\u00f5\u00f6\7\5\2\2\u00f6\u00f7\7\4\2")
+ buf.write(u"\2\u00f7\u011f\3\2\2\2\u00f8\u00f9\7\3\2\2\u00f9\u00fc")
+ buf.write(u"\5\30\r\2\u00fa\u00fb\7\5\2\2\u00fb\u00fd\5\30\r\2\u00fc")
+ buf.write(u"\u00fa\3\2\2\2\u00fd\u00fe\3\2\2\2\u00fe\u00fc\3\2\2")
+ buf.write(u"\2\u00fe\u00ff\3\2\2\2\u00ff\u0100\3\2\2\2\u0100\u0101")
+ buf.write(u"\7\4\2\2\u0101\u011f\3\2\2\2\u0102\u011f\5\36\20\2\u0103")
+ buf.write(u"\u0104\7\23\2\2\u0104\u0105\7\6\2\2\u0105\u0106\5\32")
+ buf.write(u"\16\2\u0106\u0107\7\5\2\2\u0107\u0108\5\30\r\2\u0108")
+ buf.write(u"\u0109\7\7\2\2\u0109\u011f\3\2\2\2\u010a\u010c\7\17\2")
+ buf.write(u"\2\u010b\u010d\5\26\f\2\u010c\u010b\3\2\2\2\u010c\u010d")
+ buf.write(u"\3\2\2\2\u010d\u010e\3\2\2\2\u010e\u0117\7\3\2\2\u010f")
+ buf.write(u"\u0114\5\30\r\2\u0110\u0111\7\5\2\2\u0111\u0113\5\30")
+ buf.write(u"\r\2\u0112\u0110\3\2\2\2\u0113\u0116\3\2\2\2\u0114\u0112")
+ buf.write(u"\3\2\2\2\u0114\u0115\3\2\2\2\u0115\u0118\3\2\2\2\u0116")
+ buf.write(u"\u0114\3\2\2\2\u0117\u010f\3\2\2\2\u0117\u0118\3\2\2")
+ buf.write(u"\2\u0118\u0119\3\2\2\2\u0119\u011a\7\4\2\2\u011a\u011b")
+ buf.write(u"\7\20\2\2\u011b\u011f\5\30\r\2\u011c\u011f\7\24\2\2\u011d")
+ buf.write(u"\u011f\7)\2\2\u011e\u00f1\3\2\2\2\u011e\u00f3\3\2\2\2")
+ buf.write(u"\u011e\u00f8\3\2\2\2\u011e\u0102\3\2\2\2\u011e\u0103")
+ buf.write(u"\3\2\2\2\u011e\u010a\3\2\2\2\u011e\u011c\3\2\2\2\u011e")
+ buf.write(u"\u011d\3\2\2\2\u011f\31\3\2\2\2\u0120\u0121\7\3\2\2\u0121")
+ buf.write(u"\u0132\7\4\2\2\u0122\u0123\7\3\2\2\u0123\u0124\5\34\17")
+ buf.write(u"\2\u0124\u0125\7\5\2\2\u0125\u0126\7\4\2\2\u0126\u0132")
+ buf.write(u"\3\2\2\2\u0127\u0128\7\3\2\2\u0128\u012b\5\34\17\2\u0129")
+ buf.write(u"\u012a\7\5\2\2\u012a\u012c\5\34\17\2\u012b\u0129\3\2")
+ buf.write(u"\2\2\u012c\u012d\3\2\2\2\u012d\u012b\3\2\2\2\u012d\u012e")
+ buf.write(u"\3\2\2\2\u012e\u012f\3\2\2\2\u012f\u0130\7\4\2\2\u0130")
+ buf.write(u"\u0132\3\2\2\2\u0131\u0120\3\2\2\2\u0131\u0122\3\2\2")
+ buf.write(u"\2\u0131\u0127\3\2\2\2\u0132\33\3\2\2\2\u0133\u0134\7")
+ buf.write(u"\3\2\2\u0134\u0135\5\34\17\2\u0135\u0136\7\4\2\2\u0136")
+ buf.write(u"\u0139\3\2\2\2\u0137\u0139\7)\2\2\u0138\u0133\3\2\2\2")
+ buf.write(u"\u0138\u0137\3\2\2\2\u0139\35\3\2\2\2\u013a\u013b\7*")
+ buf.write(u"\2\2\u013b\37\3\2\2\2\u013c\u013d\7\r\2\2\u013d\u013e")
+ buf.write(u"\5\6\4\2\u013e\u013f\7\16\2\2\u013f!\3\2\2\2\u0140\u0144")
+ buf.write(u"\7(\2\2\u0141\u0144\7)\2\2\u0142\u0144\7\'\2\2\u0143")
+ buf.write(u"\u0140\3\2\2\2\u0143\u0141\3\2\2\2\u0143\u0142\3\2\2")
+ buf.write(u"\2\u0144#\3\2\2\2\u0145\u014a\5\2\2\2\u0146\u014a\7#")
+ buf.write(u"\2\2\u0147\u014a\7$\2\2\u0148\u014a\7%\2\2\u0149\u0145")
+ buf.write(u"\3\2\2\2\u0149\u0146\3\2\2\2\u0149\u0147\3\2\2\2\u0149")
+ buf.write(u"\u0148\3\2\2\2\u014a%\3\2\2\2$,\60ISVcm\177\u0097\u009a")
+ buf.write(u"\u009d\u009f\u00a4\u00ab\u00b2\u00b9\u00c3\u00ca\u00cd")
+ buf.write(u"\u00d2\u00d9\u00dc\u00ea\u00ef\u00fe\u010c\u0114\u0117")
+ buf.write(u"\u011e\u012d\u0131\u0138\u0143\u0149")
+ return buf.getvalue()
+
+
+class RelayParser ( Parser ):
+
+ grammarFileName = "Relay.g4"
+
+ atn = ATNDeserializer().deserialize(serializedATN())
+
+ decisionsToDFA = [ DFA(ds, i) for i, ds in enumerate(atn.decisionToState) ]
+
+ sharedContextCache = PredictionContextCache()
+
+ literalNames = [ u"<INVALID>", u"'('", u"')'", u"','", u"'['", u"']'",
+ u"'if'", u"'else'", u"'let'", u"'='", u"';'", u"'{'",
+ u"'}'", u"'fn'", u"'->'", u"'def'", u"':'", u"'Tensor'",
+ u"'_'", u"'v0.0.2'", u"<INVALID>", u"<INVALID>", u"<INVALID>",
+ u"'*'", u"'/'", u"'+'", u"'-'", u"'<'", u"'>'", u"'<='",
+ u"'>='", u"'=='", u"'!='", u"<INVALID>", u"<INVALID>",
+ u"<INVALID>", u"'mut'" ]
+
+ symbolicNames = [ u"<INVALID>", u"<INVALID>", u"<INVALID>", u"<INVALID>",
+ u"<INVALID>", u"<INVALID>", u"<INVALID>", u"<INVALID>",
+ u"<INVALID>", u"<INVALID>", u"<INVALID>", u"<INVALID>",
+ u"<INVALID>", u"<INVALID>", u"<INVALID>", u"<INVALID>",
+ u"<INVALID>", u"<INVALID>", u"<INVALID>", u"SEMVER",
+ u"WS", u"LINE_COMMENT", u"COMMENT", u"MUL", u"DIV",
+ u"ADD", u"SUB", u"LT", u"GT", u"LE", u"GE", u"EQ",
+ u"NE", u"GLOBAL_VAR", u"LOCAL_VAR", u"GRAPH_VAR",
+ u"MUT", u"BOOL_LIT", u"FLOAT", u"NAT", u"CNAME" ]
+
+ RULE_opIdent = 0
+ RULE_prog = 1
+ RULE_expr = 2
+ RULE_func = 3
+ RULE_defn = 4
+ RULE_argList = 5
+ RULE_varList = 6
+ RULE_var = 7
+ RULE_attrList = 8
+ RULE_attr = 9
+ RULE_typeParamSeq = 10
+ RULE_type_ = 11
+ RULE_shapeSeq = 12
+ RULE_shape = 13
+ RULE_typeIdent = 14
+ RULE_body = 15
+ RULE_scalar = 16
+ RULE_ident = 17
+
+ ruleNames = [ u"opIdent", u"prog", u"expr", u"func", u"defn", u"argList",
+ u"varList", u"var", u"attrList", u"attr", u"typeParamSeq",
+ u"type_", u"shapeSeq", u"shape", u"typeIdent", u"body",
+ u"scalar", u"ident" ]
+
+ EOF = Token.EOF
+ T__0=1
+ T__1=2
+ T__2=3
+ T__3=4
+ T__4=5
+ T__5=6
+ T__6=7
+ T__7=8
+ T__8=9
+ T__9=10
+ T__10=11
+ T__11=12
+ T__12=13
+ T__13=14
+ T__14=15
+ T__15=16
+ T__16=17
+ T__17=18
+ SEMVER=19
+ WS=20
+ LINE_COMMENT=21
+ COMMENT=22
+ MUL=23
+ DIV=24
+ ADD=25
+ SUB=26
+ LT=27
+ GT=28
+ LE=29
+ GE=30
+ EQ=31
+ NE=32
+ GLOBAL_VAR=33
+ LOCAL_VAR=34
+ GRAPH_VAR=35
+ MUT=36
+ BOOL_LIT=37
+ FLOAT=38
+ NAT=39
+ CNAME=40
+
+ def __init__(self, input, output=sys.stdout):
+ super(RelayParser, self).__init__(input, output=output)
+ self.checkVersion("4.7.2")
+ self._interp = ParserATNSimulator(self, self.atn, self.decisionsToDFA, self.sharedContextCache)
+ self._predicates = None
+
+
+
+
+ class OpIdentContext(ParserRuleContext):
+
+ def __init__(self, parser, parent=None, invokingState=-1):
+ super(RelayParser.OpIdentContext, self).__init__(parent, invokingState)
+ self.parser = parser
+
+ def CNAME(self):
+ return self.getToken(RelayParser.CNAME, 0)
+
+ def getRuleIndex(self):
+ return RelayParser.RULE_opIdent
+
+ def accept(self, visitor):
+ if hasattr(visitor, "visitOpIdent"):
+ return visitor.visitOpIdent(self)
+ else:
+ return visitor.visitChildren(self)
+
+
+
+
+ def opIdent(self):
+
+ localctx = RelayParser.OpIdentContext(self, self._ctx, self.state)
+ self.enterRule(localctx, 0, self.RULE_opIdent)
+ try:
+ self.enterOuterAlt(localctx, 1)
+ self.state = 36
+ self.match(RelayParser.CNAME)
+ except RecognitionException as re:
+ localctx.exception = re
+ self._errHandler.reportError(self, re)
+ self._errHandler.recover(self, re)
+ finally:
+ self.exitRule()
+ return localctx
+
+
+ class ProgContext(ParserRuleContext):
+
+ def __init__(self, parser, parent=None, invokingState=-1):
+ super(RelayParser.ProgContext, self).__init__(parent, invokingState)
+ self.parser = parser
+
+ def SEMVER(self):
+ return self.getToken(RelayParser.SEMVER, 0)
+
+ def EOF(self):
+ return self.getToken(RelayParser.EOF, 0)
+
+ def expr(self):
+ return self.getTypedRuleContext(RelayParser.ExprContext,0)
+
+
+ def defn(self, i=None):
+ if i is None:
+ return self.getTypedRuleContexts(RelayParser.DefnContext)
+ else:
+ return self.getTypedRuleContext(RelayParser.DefnContext,i)
+
+
+ def getRuleIndex(self):
+ return RelayParser.RULE_prog
+
+ def accept(self, visitor):
+ if hasattr(visitor, "visitProg"):
+ return visitor.visitProg(self)
+ else:
+ return visitor.visitChildren(self)
+
+
+
+
+ def prog(self):
+
+ localctx = RelayParser.ProgContext(self, self._ctx, self.state)
+ self.enterRule(localctx, 2, self.RULE_prog)
+ self._la = 0 # Token type
+ try:
+ self.enterOuterAlt(localctx, 1)
+ self.state = 38
+ self.match(RelayParser.SEMVER)
+ self.state = 46
+ self._errHandler.sync(self)
+ token = self._input.LA(1)
+ if token in [RelayParser.EOF, RelayParser.T__14]:
+ self.state = 42
+ self._errHandler.sync(self)
+ _la = self._input.LA(1)
+ while _la==RelayParser.T__14:
+ self.state = 39
+ self.defn()
+ self.state = 44
+ self._errHandler.sync(self)
+ _la = self._input.LA(1)
+
+ pass
+ elif token in [RelayParser.T__0, RelayParser.T__3, RelayParser.T__5, RelayParser.T__7, RelayParser.T__12, RelayParser.SUB, RelayParser.GLOBAL_VAR, RelayParser.LOCAL_VAR, RelayParser.GRAPH_VAR, RelayParser.BOOL_LIT, RelayParser.FLOAT, RelayParser.NAT, RelayParser.CNAME]:
+ self.state = 45
+ self.expr(0)
+ pass
+ else:
+ raise NoViableAltException(self)
+
+ self.state = 48
+ self.match(RelayParser.EOF)
+ except RecognitionException as re:
+ localctx.exception = re
+ self._errHandler.reportError(self, re)
+ self._errHandler.recover(self, re)
+ finally:
+ self.exitRule()
+ return localctx
+
+
+ class ExprContext(ParserRuleContext):
+
+ def __init__(self, parser, parent=None, invokingState=-1):
+ super(RelayParser.ExprContext, self).__init__(parent, invokingState)
+ self.parser = parser
+
+
+ def getRuleIndex(self):
+ return RelayParser.RULE_expr
+
+
+ def copyFrom(self, ctx):
+ super(RelayParser.ExprContext, self).copyFrom(ctx)
+
+
+ class IdentExprContext(ExprContext):
+
+ def __init__(self, parser, ctx): # actually a RelayParser.ExprContext)
+ super(RelayParser.IdentExprContext, self).__init__(parser)
+ self.copyFrom(ctx)
+
+ def ident(self):
+ return self.getTypedRuleContext(RelayParser.IdentContext,0)
+
+
+ def accept(self, visitor):
+ if hasattr(visitor, "visitIdentExpr"):
+ return visitor.visitIdentExpr(self)
+ else:
+ return visitor.visitChildren(self)
+
+
+ class CallContext(ExprContext):
+
+ def __init__(self, parser, ctx): # actually a RelayParser.ExprContext)
+ super(RelayParser.CallContext, self).__init__(parser)
+ self.copyFrom(ctx)
+
+ def expr(self, i=None):
+ if i is None:
+ return self.getTypedRuleContexts(RelayParser.ExprContext)
+ else:
+ return self.getTypedRuleContext(RelayParser.ExprContext,i)
+
+
+ def accept(self, visitor):
+ if hasattr(visitor, "visitCall"):
+ return visitor.visitCall(self)
+ else:
+ return visitor.visitChildren(self)
+
+
+ class NegContext(ExprContext):
+
+ def __init__(self, parser, ctx): # actually a RelayParser.ExprContext)
+ super(RelayParser.NegContext, self).__init__(parser)
+ self.copyFrom(ctx)
+
+ def SUB(self):
+ return self.getToken(RelayParser.SUB, 0)
+ def expr(self):
+ return self.getTypedRuleContext(RelayParser.ExprContext,0)
+
+
+ def accept(self, visitor):
+ if hasattr(visitor, "visitNeg"):
+ return visitor.visitNeg(self)
+ else:
+ return visitor.visitChildren(self)
+
+
+ class TupleContext(ExprContext):
+
+ def __init__(self, parser, ctx): # actually a RelayParser.ExprContext)
+ super(RelayParser.TupleContext, self).__init__(parser)
+ self.copyFrom(ctx)
+
+ def expr(self, i=None):
+ if i is None:
+ return self.getTypedRuleContexts(RelayParser.ExprContext)
+ else:
+ return self.getTypedRuleContext(RelayParser.ExprContext,i)
+
+
+ def accept(self, visitor):
+ if hasattr(visitor, "visitTuple"):
+ return visitor.visitTuple(self)
+ else:
+ return visitor.visitChildren(self)
+
+
+ class ParensContext(ExprContext):
+
+ def __init__(self, parser, ctx): # actually a RelayParser.ExprContext)
+ super(RelayParser.ParensContext, self).__init__(parser)
+ self.copyFrom(ctx)
+
+ def expr(self):
+ return self.getTypedRuleContext(RelayParser.ExprContext,0)
+
+
+ def accept(self, visitor):
+ if hasattr(visitor, "visitParens"):
+ return visitor.visitParens(self)
+ else:
+ return visitor.visitChildren(self)
+
+
+ class FuncExprContext(ExprContext):
+
+ def __init__(self, parser, ctx): # actually a RelayParser.ExprContext)
+ super(RelayParser.FuncExprContext, self).__init__(parser)
+ self.copyFrom(ctx)
+
+ def func(self):
+ return self.getTypedRuleContext(RelayParser.FuncContext,0)
+
+
+ def accept(self, visitor):
+ if hasattr(visitor, "visitFuncExpr"):
+ return visitor.visitFuncExpr(self)
+ else:
+ return visitor.visitChildren(self)
+
+
+ class ScalarExprContext(ExprContext):
+
+ def __init__(self, parser, ctx): # actually a RelayParser.ExprContext)
+ super(RelayParser.ScalarExprContext, self).__init__(parser)
+ self.copyFrom(ctx)
+
+ def scalar(self):
+ return self.getTypedRuleContext(RelayParser.ScalarContext,0)
+
+
+ def accept(self, visitor):
+ if hasattr(visitor, "visitScalarExpr"):
+ return visitor.visitScalarExpr(self)
+ else:
+ return visitor.visitChildren(self)
+
+
+ class LetContext(ExprContext):
+
+ def __init__(self, parser, ctx): # actually a RelayParser.ExprContext)
+ super(RelayParser.LetContext, self).__init__(parser)
+ self.copyFrom(ctx)
+
+ def var(self):
+ return self.getTypedRuleContext(RelayParser.VarContext,0)
+
+ def expr(self, i=None):
+ if i is None:
+ return self.getTypedRuleContexts(RelayParser.ExprContext)
+ else:
+ return self.getTypedRuleContext(RelayParser.ExprContext,i)
+
+ def MUT(self):
+ return self.getToken(RelayParser.MUT, 0)
+
+ def accept(self, visitor):
+ if hasattr(visitor, "visitLet"):
+ return visitor.visitLet(self)
+ else:
+ return visitor.visitChildren(self)
+
+
+ class TensorContext(ExprContext):
+
+ def __init__(self, parser, ctx): # actually a RelayParser.ExprContext)
+ super(RelayParser.TensorContext, self).__init__(parser)
+ self.copyFrom(ctx)
+
+ def expr(self, i=None):
+ if i is None:
+ return self.getTypedRuleContexts(RelayParser.ExprContext)
+ else:
+ return self.getTypedRuleContext(RelayParser.ExprContext,i)
+
+
+ def accept(self, visitor):
+ if hasattr(visitor, "visitTensor"):
+ return visitor.visitTensor(self)
+ else:
+ return visitor.visitChildren(self)
+
+
+ class IfElseContext(ExprContext):
+
+ def __init__(self, parser, ctx): # actually a RelayParser.ExprContext)
+ super(RelayParser.IfElseContext, self).__init__(parser)
+ self.copyFrom(ctx)
+
+ def expr(self):
+ return self.getTypedRuleContext(RelayParser.ExprContext,0)
+
+ def body(self, i=None):
+ if i is None:
+ return self.getTypedRuleContexts(RelayParser.BodyContext)
+ else:
+ return self.getTypedRuleContext(RelayParser.BodyContext,i)
+
+
+ def accept(self, visitor):
+ if hasattr(visitor, "visitIfElse"):
+ return visitor.visitIfElse(self)
+ else:
+ return visitor.visitChildren(self)
+
+
+ class GraphContext(ExprContext):
+
+ def __init__(self, parser, ctx): # actually a RelayParser.ExprContext)
+ super(RelayParser.GraphContext, self).__init__(parser)
+ self.copyFrom(ctx)
+
+ def ident(self):
+ return self.getTypedRuleContext(RelayParser.IdentContext,0)
+
+ def expr(self, i=None):
+ if i is None:
+ return self.getTypedRuleContexts(RelayParser.ExprContext)
+ else:
+ return self.getTypedRuleContext(RelayParser.ExprContext,i)
+
+
+ def accept(self, visitor):
+ if hasattr(visitor, "visitGraph"):
+ return visitor.visitGraph(self)
+ else:
+ return visitor.visitChildren(self)
+
+
+ class BinOpContext(ExprContext):
+
+ def __init__(self, parser, ctx): # actually a RelayParser.ExprContext)
+ super(RelayParser.BinOpContext, self).__init__(parser)
+ self.op = None # Token
+ self.copyFrom(ctx)
+
+ def expr(self, i=None):
+ if i is None:
+ return self.getTypedRuleContexts(RelayParser.ExprContext)
+ else:
+ return self.getTypedRuleContext(RelayParser.ExprContext,i)
+
+ def MUL(self):
+ return self.getToken(RelayParser.MUL, 0)
+ def DIV(self):
+ return self.getToken(RelayParser.DIV, 0)
+ def ADD(self):
+ return self.getToken(RelayParser.ADD, 0)
+ def SUB(self):
+ return self.getToken(RelayParser.SUB, 0)
+ def LT(self):
+ return self.getToken(RelayParser.LT, 0)
+ def GT(self):
+ return self.getToken(RelayParser.GT, 0)
+ def LE(self):
+ return self.getToken(RelayParser.LE, 0)
+ def GE(self):
+ return self.getToken(RelayParser.GE, 0)
+ def EQ(self):
+ return self.getToken(RelayParser.EQ, 0)
+ def NE(self):
+ return self.getToken(RelayParser.NE, 0)
+
+ def accept(self, visitor):
+ if hasattr(visitor, "visitBinOp"):
+ return visitor.visitBinOp(self)
+ else:
+ return visitor.visitChildren(self)
+
+
+
+ def expr(self, _p=0):
+ _parentctx = self._ctx
+ _parentState = self.state
+ localctx = RelayParser.ExprContext(self, self._ctx, _parentState)
+ _prevctx = localctx
+ _startState = 4
+ self.enterRecursionRule(localctx, 4, self.RULE_expr, _p)
+ self._la = 0 # Token type
+ try:
+ self.enterOuterAlt(localctx, 1)
+ self.state = 125
+ self._errHandler.sync(self)
+ la_ = self._interp.adaptivePredict(self._input,7,self._ctx)
+ if la_ == 1:
+ localctx = RelayParser.ParensContext(self, localctx)
+ self._ctx = localctx
+ _prevctx = localctx
+
+ self.state = 51
+ self.match(RelayParser.T__0)
+ self.state = 52
+ self.expr(0)
+ self.state = 53
+ self.match(RelayParser.T__1)
+ pass
+
+ elif la_ == 2:
+ localctx = RelayParser.NegContext(self, localctx)
+ self._ctx = localctx
+ _prevctx = localctx
+ self.state = 55
+ self.match(RelayParser.SUB)
+ self.state = 56
+ self.expr(17)
+ pass
+
+ elif la_ == 3:
+ localctx = RelayParser.FuncExprContext(self, localctx)
+ self._ctx = localctx
+ _prevctx = localctx
+ self.state = 57
+ self.func()
+ pass
+
+ elif la_ == 4:
+ localctx = RelayParser.TupleContext(self, localctx)
+ self._ctx = localctx
+ _prevctx = localctx
+ self.state = 58
+ self.match(RelayParser.T__0)
+ self.state = 59
+ self.match(RelayParser.T__1)
+ pass
+
+ elif la_ == 5:
+ localctx = RelayParser.TupleContext(self, localctx)
+ self._ctx = localctx
+ _prevctx = localctx
+ self.state = 60
+ self.match(RelayParser.T__0)
+ self.state = 61
+ self.expr(0)
+ self.state = 62
+ self.match(RelayParser.T__2)
+ self.state = 63
+ self.match(RelayParser.T__1)
+ pass
+
+ elif la_ == 6:
+ localctx = RelayParser.TupleContext(self, localctx)
+ self._ctx = localctx
+ _prevctx = localctx
+ self.state = 65
+ self.match(RelayParser.T__0)
+ self.state = 66
+ self.expr(0)
+ self.state = 69
+ self._errHandler.sync(self)
+ _la = self._input.LA(1)
+ while True:
+ self.state = 67
+ self.match(RelayParser.T__2)
+ self.state = 68
+ self.expr(0)
+ self.state = 71
+ self._errHandler.sync(self)
+ _la = self._input.LA(1)
+ if not (_la==RelayParser.T__2):
+ break
+
+ self.state = 73
+ self.match(RelayParser.T__1)
+ pass
+
+ elif la_ == 7:
+ localctx = RelayParser.TensorContext(self, localctx)
+ self._ctx = localctx
+ _prevctx = localctx
+ self.state = 75
+ self.match(RelayParser.T__3)
+ self.state = 84
+ self._errHandler.sync(self)
+ _la = self._input.LA(1)
+ if (((_la) & ~0x3f) == 0 and ((1 << _la) & ((1 << RelayParser.T__0) | (1 << RelayParser.T__3) | (1 << RelayParser.T__5) | (1 << RelayParser.T__7) | (1 << RelayParser.T__12) | (1 << RelayParser.SUB) | (1 << RelayParser.GLOBAL_VAR) | (1 << RelayParser.LOCAL_VAR) | (1 << RelayParser.GRAPH_VAR) | (1 << RelayParser.BOOL_LIT) | (1 << RelayParser.FLOAT) | (1 << RelayParser.NAT) | (1 << RelayParser.CNAME))) != 0):
+ self.state = 76
+ self.expr(0)
+ self.state = 81
+ self._errHandler.sync(self)
+ _la = self._input.LA(1)
+ while _la==RelayParser.T__2:
+ self.state = 77
+ self.match(RelayParser.T__2)
+ self.state = 78
+ self.expr(0)
+ self.state = 83
+ self._errHandler.sync(self)
+ _la = self._input.LA(1)
+
+
+
+ self.state = 86
+ self.match(RelayParser.T__4)
+ pass
+
+ elif la_ == 8:
+ localctx = RelayParser.IfElseContext(self, localctx)
+ self._ctx = localctx
+ _prevctx = localctx
+ self.state = 87
+ self.match(RelayParser.T__5)
+ self.state = 88
+ self.match(RelayParser.T__0)
+ self.state = 89
+ self.expr(0)
+ self.state = 90
+ self.match(RelayParser.T__1)
+ self.state = 91
+ self.body()
+ self.state = 92
+ self.match(RelayParser.T__6)
+ self.state = 93
+ self.body()
+ pass
+
+ elif la_ == 9:
+ localctx = RelayParser.LetContext(self, localctx)
+ self._ctx = localctx
+ _prevctx = localctx
+ self.state = 95
+ self.match(RelayParser.T__7)
+ self.state = 97
+ self._errHandler.sync(self)
+ _la = self._input.LA(1)
+ if _la==RelayParser.MUT:
+ self.state = 96
+ self.match(RelayParser.MUT)
+
+
+ self.state = 99
+ self.var()
+ self.state = 100
+ self.match(RelayParser.T__8)
+ self.state = 101
+ self.expr(0)
+ self.state = 102
+ self.match(RelayParser.T__9)
+ self.state = 103
+ self.expr(6)
+ pass
+
+ elif la_ == 10:
+ localctx = RelayParser.LetContext(self, localctx)
+ self._ctx = localctx
+ _prevctx = localctx
+ self.state = 105
+ self.match(RelayParser.T__7)
+ self.state = 107
+ self._errHandler.sync(self)
+ _la = self._input.LA(1)
+ if _la==RelayParser.MUT:
+ self.state = 106
+ self.match(RelayParser.MUT)
+
+
+ self.state = 109
+ self.var()
+ self.state = 110
+ self.match(RelayParser.T__8)
+ self.state = 111
+ self.match(RelayParser.T__10)
+ self.state = 112
+ self.expr(0)
+ self.state = 113
+ self.match(RelayParser.T__11)
+ self.state = 114
+ self.match(RelayParser.T__9)
+ self.state = 115
+ self.expr(5)
+ pass
+
+ elif la_ == 11:
+ localctx = RelayParser.GraphContext(self, localctx)
+ self._ctx = localctx
+ _prevctx = localctx
+ self.state = 117
+ self.ident()
+ self.state = 118
+ self.match(RelayParser.T__8)
+ self.state = 119
+ self.expr(0)
+ self.state = 120
+ self.match(RelayParser.T__9)
+ self.state = 121
+ self.expr(3)
+ pass
+
+ elif la_ == 12:
+ localctx = RelayParser.IdentExprContext(self, localctx)
+ self._ctx = localctx
+ _prevctx = localctx
+ self.state = 123
+ self.ident()
+ pass
+
+ elif la_ == 13:
+ localctx = RelayParser.ScalarExprContext(self, localctx)
+ self._ctx = localctx
+ _prevctx = localctx
+ self.state = 124
+ self.scalar()
+ pass
+
+
+ self._ctx.stop = self._input.LT(-1)
+ self.state = 157
+ self._errHandler.sync(self)
+ _alt = self._interp.adaptivePredict(self._input,11,self._ctx)
+ while _alt!=2 and _alt!=ATN.INVALID_ALT_NUMBER:
+ if _alt==1:
+ if self._parseListeners is not None:
+ self.triggerExitRuleEvent()
+ _prevctx = localctx
+ self.state = 155
+ self._errHandler.sync(self)
+ la_ = self._interp.adaptivePredict(self._input,10,self._ctx)
+ if la_ == 1:
+ localctx = RelayParser.BinOpContext(self, RelayParser.ExprContext(self, _parentctx, _parentState))
+ self.pushNewRecursionContext(localctx, _startState, self.RULE_expr)
+ self.state = 127
+ if not self.precpred(self._ctx, 16):
+ from antlr4.error.Errors import FailedPredicateException
+ raise FailedPredicateException(self, "self.precpred(self._ctx, 16)")
+ self.state = 128
+ localctx.op = self._input.LT(1)
+ _la = self._input.LA(1)
+ if not(_la==RelayParser.MUL or _la==RelayParser.DIV):
+ localctx.op = self._errHandler.recoverInline(self)
+ else:
+ self._errHandler.reportMatch(self)
+ self.consume()
+ self.state = 129
+ self.expr(17)
+ pass
+
+ elif la_ == 2:
+ localctx = RelayParser.BinOpContext(self, RelayParser.ExprContext(self, _parentctx, _parentState))
+ self.pushNewRecursionContext(localctx, _startState, self.RULE_expr)
+ self.state = 130
+ if not self.precpred(self._ctx, 15):
+ from antlr4.error.Errors import FailedPredicateException
+ raise FailedPredicateException(self, "self.precpred(self._ctx, 15)")
+ self.state = 131
+ localctx.op = self._input.LT(1)
+ _la = self._input.LA(1)
+ if not(_la==RelayParser.ADD or _la==RelayParser.SUB):
+ localctx.op = self._errHandler.recoverInline(self)
+ else:
+ self._errHandler.reportMatch(self)
+ self.consume()
+ self.state = 132
+ self.expr(16)
+ pass
+
+ elif la_ == 3:
+ localctx = RelayParser.BinOpContext(self, RelayParser.ExprContext(self, _parentctx, _parentState))
+ self.pushNewRecursionContext(localctx, _startState, self.RULE_expr)
+ self.state = 133
+ if not self.precpred(self._ctx, 14):
+ from antlr4.error.Errors import FailedPredicateException
+ raise FailedPredicateException(self, "self.precpred(self._ctx, 14)")
+ self.state = 134
+ localctx.op = self._input.LT(1)
+ _la = self._input.LA(1)
+ if not((((_la) & ~0x3f) == 0 and ((1 << _la) & ((1 << RelayParser.LT) | (1 << RelayParser.GT) | (1 << RelayParser.LE) | (1 << RelayParser.GE))) != 0)):
+ localctx.op = self._errHandler.recoverInline(self)
+ else:
+ self._errHandler.reportMatch(self)
+ self.consume()
+ self.state = 135
+ self.expr(15)
+ pass
+
+ elif la_ == 4:
+ localctx = RelayParser.BinOpContext(self, RelayParser.ExprContext(self, _parentctx, _parentState))
+ self.pushNewRecursionContext(localctx, _startState, self.RULE_expr)
+ self.state = 136
+ if not self.precpred(self._ctx, 13):
+ from antlr4.error.Errors import FailedPredicateException
+ raise FailedPredicateException(self, "self.precpred(self._ctx, 13)")
+ self.state = 137
+ localctx.op = self._input.LT(1)
+ _la = self._input.LA(1)
+ if not(_la==RelayParser.EQ or _la==RelayParser.NE):
+ localctx.op = self._errHandler.recoverInline(self)
+ else:
+ self._errHandler.reportMatch(self)
+ self.consume()
+ self.state = 138
+ self.expr(14)
+ pass
+
+ elif la_ == 5:
+ localctx = RelayParser.LetContext(self, RelayParser.ExprContext(self, _parentctx, _parentState))
+ self.pushNewRecursionContext(localctx, _startState, self.RULE_expr)
+ self.state = 139
+ if not self.precpred(self._ctx, 4):
+ from antlr4.error.Errors import FailedPredicateException
+ raise FailedPredicateException(self, "self.precpred(self._ctx, 4)")
+ self.state = 140
+ self.match(RelayParser.T__9)
+ self.state = 141
+ self.expr(5)
+ pass
+
+ elif la_ == 6:
+ localctx = RelayParser.CallContext(self, RelayParser.ExprContext(self, _parentctx, _parentState))
+ self.pushNewRecursionContext(localctx, _startState, self.RULE_expr)
+ self.state = 142
+ if not self.precpred(self._ctx, 18):
+ from antlr4.error.Errors import FailedPredicateException
+ raise FailedPredicateException(self, "self.precpred(self._ctx, 18)")
+ self.state = 143
+ self.match(RelayParser.T__0)
+ self.state = 152
+ self._errHandler.sync(self)
+ _la = self._input.LA(1)
+ if (((_la) & ~0x3f) == 0 and ((1 << _la) & ((1 << RelayParser.T__0) | (1 << RelayParser.T__3) | (1 << RelayParser.T__5) | (1 << RelayParser.T__7) | (1 << RelayParser.T__12) | (1 << RelayParser.SUB) | (1 << RelayParser.GLOBAL_VAR) | (1 << RelayParser.LOCAL_VAR) | (1 << RelayParser.GRAPH_VAR) | (1 << RelayParser.BOOL_LIT) | (1 << RelayParser.FLOAT) | (1 << RelayParser.NAT) | (1 << RelayParser.CNAME))) != 0):
+ self.state = 144
+ self.expr(0)
+ self.state = 149
+ self._errHandler.sync(self)
+ _la = self._input.LA(1)
+ while _la==RelayParser.T__2:
+ self.state = 145
+ self.match(RelayParser.T__2)
+ self.state = 146
+ self.expr(0)
+ self.state = 151
+ self._errHandler.sync(self)
+ _la = self._input.LA(1)
+
+
+
+ self.state = 154
+ self.match(RelayParser.T__1)
+ pass
+
+
+ self.state = 159
+ self._errHandler.sync(self)
+ _alt = self._interp.adaptivePredict(self._input,11,self._ctx)
+
+ except RecognitionException as re:
+ localctx.exception = re
+ self._errHandler.reportError(self, re)
+ self._errHandler.recover(self, re)
+ finally:
+ self.unrollRecursionContexts(_parentctx)
+ return localctx
+
+
+ class FuncContext(ParserRuleContext):
+
+ def __init__(self, parser, parent=None, invokingState=-1):
+ super(RelayParser.FuncContext, self).__init__(parent, invokingState)
+ self.parser = parser
+
+ def argList(self):
+ return self.getTypedRuleContext(RelayParser.ArgListContext,0)
+
+
+ def body(self):
+ return self.getTypedRuleContext(RelayParser.BodyContext,0)
+
+
+ def typeParamSeq(self):
+ return self.getTypedRuleContext(RelayParser.TypeParamSeqContext,0)
+
+
+ def type_(self):
+ return self.getTypedRuleContext(RelayParser.Type_Context,0)
+
+
+ def getRuleIndex(self):
+ return RelayParser.RULE_func
+
+ def accept(self, visitor):
+ if hasattr(visitor, "visitFunc"):
+ return visitor.visitFunc(self)
+ else:
+ return visitor.visitChildren(self)
+
+
+
+
+ def func(self):
+
+ localctx = RelayParser.FuncContext(self, self._ctx, self.state)
+ self.enterRule(localctx, 6, self.RULE_func)
+ self._la = 0 # Token type
+ try:
+ self.enterOuterAlt(localctx, 1)
+ self.state = 160
+ self.match(RelayParser.T__12)
+ self.state = 162
+ self._errHandler.sync(self)
+ _la = self._input.LA(1)
+ if _la==RelayParser.T__3:
+ self.state = 161
+ self.typeParamSeq()
+
+
+ self.state = 164
+ self.match(RelayParser.T__0)
+ self.state = 165
+ self.argList()
+ self.state = 166
+ self.match(RelayParser.T__1)
+ self.state = 169
+ self._errHandler.sync(self)
+ _la = self._input.LA(1)
+ if _la==RelayParser.T__13:
+ self.state = 167
+ self.match(RelayParser.T__13)
+ self.state = 168
+ self.type_()
+
+
+ self.state = 171
+ self.body()
+ except RecognitionException as re:
+ localctx.exception = re
+ self._errHandler.reportError(self, re)
+ self._errHandler.recover(self, re)
+ finally:
+ self.exitRule()
+ return localctx
+
+
+ class DefnContext(ParserRuleContext):
+
+ def __init__(self, parser, parent=None, invokingState=-1):
+ super(RelayParser.DefnContext, self).__init__(parent, invokingState)
+ self.parser = parser
+
+ def ident(self):
+ return self.getTypedRuleContext(RelayParser.IdentContext,0)
+
+
+ def argList(self):
+ return self.getTypedRuleContext(RelayParser.ArgListContext,0)
+
+
+ def body(self):
+ return self.getTypedRuleContext(RelayParser.BodyContext,0)
+
+
+ def typeParamSeq(self):
+ return self.getTypedRuleContext(RelayParser.TypeParamSeqContext,0)
+
+
+ def type_(self):
+ return self.getTypedRuleContext(RelayParser.Type_Context,0)
+
+
+ def getRuleIndex(self):
+ return RelayParser.RULE_defn
+
+ def accept(self, visitor):
+ if hasattr(visitor, "visitDefn"):
+ return visitor.visitDefn(self)
+ else:
+ return visitor.visitChildren(self)
+
+
+
+
+ def defn(self):
+
+ localctx = RelayParser.DefnContext(self, self._ctx, self.state)
+ self.enterRule(localctx, 8, self.RULE_defn)
+ self._la = 0 # Token type
+ try:
+ self.enterOuterAlt(localctx, 1)
+ self.state = 173
+ self.match(RelayParser.T__14)
+ self.state = 174
+ self.ident()
+ self.state = 176
+ self._errHandler.sync(self)
+ _la = self._input.LA(1)
+ if _la==RelayParser.T__3:
+ self.state = 175
+ self.typeParamSeq()
+
+
+ self.state = 178
+ self.match(RelayParser.T__0)
+ self.state = 179
+ self.argList()
+ self.state = 180
+ self.match(RelayParser.T__1)
+ self.state = 183
+ self._errHandler.sync(self)
+ _la = self._input.LA(1)
+ if _la==RelayParser.T__13:
+ self.state = 181
+ self.match(RelayParser.T__13)
+ self.state = 182
+ self.type_()
+
+
+ self.state = 185
+ self.body()
+ except RecognitionException as re:
+ localctx.exception = re
+ self._errHandler.reportError(self, re)
+ self._errHandler.recover(self, re)
+ finally:
+ self.exitRule()
+ return localctx
+
+
+ class ArgListContext(ParserRuleContext):
+
+ def __init__(self, parser, parent=None, invokingState=-1):
+ super(RelayParser.ArgListContext, self).__init__(parent, invokingState)
+ self.parser = parser
+
+ def varList(self):
+ return self.getTypedRuleContext(RelayParser.VarListContext,0)
+
+
+ def attrList(self):
+ return self.getTypedRuleContext(RelayParser.AttrListContext,0)
+
+
+ def getRuleIndex(self):
+ return RelayParser.RULE_argList
+
+ def accept(self, visitor):
+ if hasattr(visitor, "visitArgList"):
+ return visitor.visitArgList(self)
+ else:
+ return visitor.visitChildren(self)
+
+
+
+
+ def argList(self):
+
+ localctx = RelayParser.ArgListContext(self, self._ctx, self.state)
+ self.enterRule(localctx, 10, self.RULE_argList)
+ try:
+ self.state = 193
+ self._errHandler.sync(self)
+ la_ = self._interp.adaptivePredict(self._input,16,self._ctx)
+ if la_ == 1:
+ self.enterOuterAlt(localctx, 1)
+ self.state = 187
+ self.varList()
+ pass
+
+ elif la_ == 2:
+ self.enterOuterAlt(localctx, 2)
+ self.state = 188
+ self.attrList()
+ pass
+
+ elif la_ == 3:
+ self.enterOuterAlt(localctx, 3)
+ self.state = 189
+ self.varList()
+ self.state = 190
+ self.match(RelayParser.T__2)
+ self.state = 191
+ self.attrList()
+ pass
+
+
+ except RecognitionException as re:
+ localctx.exception = re
+ self._errHandler.reportError(self, re)
+ self._errHandler.recover(self, re)
+ finally:
+ self.exitRule()
+ return localctx
+
+
+ class VarListContext(ParserRuleContext):
+
+ def __init__(self, parser, parent=None, invokingState=-1):
+ super(RelayParser.VarListContext, self).__init__(parent, invokingState)
+ self.parser = parser
+
+ def var(self, i=None):
+ if i is None:
+ return self.getTypedRuleContexts(RelayParser.VarContext)
+ else:
+ return self.getTypedRuleContext(RelayParser.VarContext,i)
+
+
+ def getRuleIndex(self):
+ return RelayParser.RULE_varList
+
+ def accept(self, visitor):
+ if hasattr(visitor, "visitVarList"):
+ return visitor.visitVarList(self)
+ else:
+ return visitor.visitChildren(self)
+
+
+
+
+ def varList(self):
+
+ localctx = RelayParser.VarListContext(self, self._ctx, self.state)
+ self.enterRule(localctx, 12, self.RULE_varList)
+ self._la = 0 # Token type
+ try:
+ self.enterOuterAlt(localctx, 1)
+ self.state = 203
+ self._errHandler.sync(self)
+ _la = self._input.LA(1)
+ if (((_la) & ~0x3f) == 0 and ((1 << _la) & ((1 << RelayParser.GLOBAL_VAR) | (1 << RelayParser.LOCAL_VAR) | (1 << RelayParser.GRAPH_VAR) | (1 << RelayParser.CNAME))) != 0):
+ self.state = 195
+ self.var()
+ self.state = 200
+ self._errHandler.sync(self)
+ _alt = self._interp.adaptivePredict(self._input,17,self._ctx)
+ while _alt!=2 and _alt!=ATN.INVALID_ALT_NUMBER:
+ if _alt==1:
+ self.state = 196
+ self.match(RelayParser.T__2)
+ self.state = 197
+ self.var()
+ self.state = 202
+ self._errHandler.sync(self)
+ _alt = self._interp.adaptivePredict(self._input,17,self._ctx)
+
+
+
+ except RecognitionException as re:
+ localctx.exception = re
+ self._errHandler.reportError(self, re)
+ self._errHandler.recover(self, re)
+ finally:
+ self.exitRule()
+ return localctx
+
+
+ class VarContext(ParserRuleContext):
+
+ def __init__(self, parser, parent=None, invokingState=-1):
+ super(RelayParser.VarContext, self).__init__(parent, invokingState)
+ self.parser = parser
+
+ def ident(self):
+ return self.getTypedRuleContext(RelayParser.IdentContext,0)
+
+
+ def type_(self):
+ return self.getTypedRuleContext(RelayParser.Type_Context,0)
+
+
+ def getRuleIndex(self):
+ return RelayParser.RULE_var
+
+ def accept(self, visitor):
+ if hasattr(visitor, "visitVar"):
+ return visitor.visitVar(self)
+ else:
+ return visitor.visitChildren(self)
+
+
+
+
+ def var(self):
+
+ localctx = RelayParser.VarContext(self, self._ctx, self.state)
+ self.enterRule(localctx, 14, self.RULE_var)
+ self._la = 0 # Token type
+ try:
+ self.enterOuterAlt(localctx, 1)
+ self.state = 205
+ self.ident()
+ self.state = 208
+ self._errHandler.sync(self)
+ _la = self._input.LA(1)
+ if _la==RelayParser.T__15:
+ self.state = 206
+ self.match(RelayParser.T__15)
+ self.state = 207
+ self.type_()
+
+
+ except RecognitionException as re:
+ localctx.exception = re
+ self._errHandler.reportError(self, re)
+ self._errHandler.recover(self, re)
+ finally:
+ self.exitRule()
+ return localctx
+
+
+ class AttrListContext(ParserRuleContext):
+
+ def __init__(self, parser, parent=None, invokingState=-1):
+ super(RelayParser.AttrListContext, self).__init__(parent, invokingState)
+ self.parser = parser
+
+ def attr(self, i=None):
+ if i is None:
+ return self.getTypedRuleContexts(RelayParser.AttrContext)
+ else:
+ return self.getTypedRuleContext(RelayParser.AttrContext,i)
+
+
+ def getRuleIndex(self):
+ return RelayParser.RULE_attrList
+
+ def accept(self, visitor):
+ if hasattr(visitor, "visitAttrList"):
+ return visitor.visitAttrList(self)
+ else:
+ return visitor.visitChildren(self)
+
+
+
+
+ def attrList(self):
+
+ localctx = RelayParser.AttrListContext(self, self._ctx, self.state)
+ self.enterRule(localctx, 16, self.RULE_attrList)
+ self._la = 0 # Token type
+ try:
+ self.enterOuterAlt(localctx, 1)
+ self.state = 218
+ self._errHandler.sync(self)
+ _la = self._input.LA(1)
+ if _la==RelayParser.CNAME:
+ self.state = 210
+ self.attr()
+ self.state = 215
+ self._errHandler.sync(self)
+ _la = self._input.LA(1)
+ while _la==RelayParser.T__2:
+ self.state = 211
+ self.match(RelayParser.T__2)
+ self.state = 212
+ self.attr()
+ self.state = 217
+ self._errHandler.sync(self)
+ _la = self._input.LA(1)
+
+
+
+ except RecognitionException as re:
+ localctx.exception = re
+ self._errHandler.reportError(self, re)
+ self._errHandler.recover(self, re)
+ finally:
+ self.exitRule()
+ return localctx
+
+
+ class AttrContext(ParserRuleContext):
+
+ def __init__(self, parser, parent=None, invokingState=-1):
+ super(RelayParser.AttrContext, self).__init__(parent, invokingState)
+ self.parser = parser
+
+ def CNAME(self):
+ return self.getToken(RelayParser.CNAME, 0)
+
+ def expr(self):
+ return self.getTypedRuleContext(RelayParser.ExprContext,0)
+
+
+ def getRuleIndex(self):
+ return RelayParser.RULE_attr
+
+ def accept(self, visitor):
+ if hasattr(visitor, "visitAttr"):
+ return visitor.visitAttr(self)
+ else:
+ return visitor.visitChildren(self)
+
+
+
+
+ def attr(self):
+
+ localctx = RelayParser.AttrContext(self, self._ctx, self.state)
+ self.enterRule(localctx, 18, self.RULE_attr)
+ try:
+ self.enterOuterAlt(localctx, 1)
+ self.state = 220
+ self.match(RelayParser.CNAME)
+ self.state = 221
+ self.match(RelayParser.T__8)
+ self.state = 222
+ self.expr(0)
+ except RecognitionException as re:
+ localctx.exception = re
+ self._errHandler.reportError(self, re)
+ self._errHandler.recover(self, re)
+ finally:
+ self.exitRule()
+ return localctx
+
+
+ class TypeParamSeqContext(ParserRuleContext):
+
+ def __init__(self, parser, parent=None, invokingState=-1):
+ super(RelayParser.TypeParamSeqContext, self).__init__(parent, invokingState)
+ self.parser = parser
+
+ def ident(self, i=None):
+ if i is None:
+ return self.getTypedRuleContexts(RelayParser.IdentContext)
+ else:
+ return self.getTypedRuleContext(RelayParser.IdentContext,i)
+
+
+ def getRuleIndex(self):
+ return RelayParser.RULE_typeParamSeq
+
+ def accept(self, visitor):
+ if hasattr(visitor, "visitTypeParamSeq"):
+ return visitor.visitTypeParamSeq(self)
+ else:
+ return visitor.visitChildren(self)
+
+
+
+
+ def typeParamSeq(self):
+
+ localctx = RelayParser.TypeParamSeqContext(self, self._ctx, self.state)
+ self.enterRule(localctx, 20, self.RULE_typeParamSeq)
+ self._la = 0 # Token type
+ try:
+ self.state = 237
+ self._errHandler.sync(self)
+ la_ = self._interp.adaptivePredict(self._input,23,self._ctx)
+ if la_ == 1:
+ self.enterOuterAlt(localctx, 1)
+ self.state = 224
+ self.match(RelayParser.T__3)
+ self.state = 225
+ self.match(RelayParser.T__4)
+ pass
+
+ elif la_ == 2:
+ self.enterOuterAlt(localctx, 2)
+ self.state = 226
+ self.match(RelayParser.T__3)
+ self.state = 227
+ self.ident()
+ self.state = 232
+ self._errHandler.sync(self)
+ _la = self._input.LA(1)
+ while _la==RelayParser.T__2:
+ self.state = 228
+ self.match(RelayParser.T__2)
+ self.state = 229
+ self.ident()
+ self.state = 234
+ self._errHandler.sync(self)
+ _la = self._input.LA(1)
+
+ self.state = 235
+ self.match(RelayParser.T__4)
+ pass
+
+
+ except RecognitionException as re:
+ localctx.exception = re
+ self._errHandler.reportError(self, re)
+ self._errHandler.recover(self, re)
+ finally:
+ self.exitRule()
+ return localctx
+
+
+ class Type_Context(ParserRuleContext):
+
+ def __init__(self, parser, parent=None, invokingState=-1):
+ super(RelayParser.Type_Context, self).__init__(parent, invokingState)
+ self.parser = parser
+
+
+ def getRuleIndex(self):
+ return RelayParser.RULE_type_
+
+
+ def copyFrom(self, ctx):
+ super(RelayParser.Type_Context, self).copyFrom(ctx)
+
+
+
+ class IntTypeContext(Type_Context):
+
+ def __init__(self, parser, ctx): # actually a RelayParser.Type_Context)
+ super(RelayParser.IntTypeContext, self).__init__(parser)
+ self.copyFrom(ctx)
+
+ def NAT(self):
+ return self.getToken(RelayParser.NAT, 0)
+
+ def accept(self, visitor):
+ if hasattr(visitor, "visitIntType"):
+ return visitor.visitIntType(self)
+ else:
+ return visitor.visitChildren(self)
+
+
+ class TupleTypeContext(Type_Context):
+
+ def __init__(self, parser, ctx): # actually a RelayParser.Type_Context)
+ super(RelayParser.TupleTypeContext, self).__init__(parser)
+ self.copyFrom(ctx)
+
+ def type_(self, i=None):
+ if i is None:
+ return self.getTypedRuleContexts(RelayParser.Type_Context)
+ else:
+ return self.getTypedRuleContext(RelayParser.Type_Context,i)
+
+
+ def accept(self, visitor):
+ if hasattr(visitor, "visitTupleType"):
+ return visitor.visitTupleType(self)
+ else:
+ return visitor.visitChildren(self)
+
+
+ class TypeIdentTypeContext(Type_Context):
+
+ def __init__(self, parser, ctx): # actually a RelayParser.Type_Context)
+ super(RelayParser.TypeIdentTypeContext, self).__init__(parser)
+ self.copyFrom(ctx)
+
+ def typeIdent(self):
+ return self.getTypedRuleContext(RelayParser.TypeIdentContext,0)
+
+
+ def accept(self, visitor):
+ if hasattr(visitor, "visitTypeIdentType"):
+ return visitor.visitTypeIdentType(self)
+ else:
+ return visitor.visitChildren(self)
+
+
+ class IncompleteTypeContext(Type_Context):
+
+ def __init__(self, parser, ctx): # actually a RelayParser.Type_Context)
+ super(RelayParser.IncompleteTypeContext, self).__init__(parser)
+ self.copyFrom(ctx)
+
+
+ def accept(self, visitor):
+ if hasattr(visitor, "visitIncompleteType"):
+ return visitor.visitIncompleteType(self)
+ else:
+ return visitor.visitChildren(self)
+
+
+ class TensorTypeContext(Type_Context):
+
+ def __init__(self, parser, ctx): # actually a RelayParser.Type_Context)
+ super(RelayParser.TensorTypeContext, self).__init__(parser)
+ self.copyFrom(ctx)
+
+ def shapeSeq(self):
+ return self.getTypedRuleContext(RelayParser.ShapeSeqContext,0)
+
+ def type_(self):
+ return self.getTypedRuleContext(RelayParser.Type_Context,0)
+
+
+ def accept(self, visitor):
+ if hasattr(visitor, "visitTensorType"):
+ return visitor.visitTensorType(self)
+ else:
+ return visitor.visitChildren(self)
+
+
+ class FuncTypeContext(Type_Context):
+
+ def __init__(self, parser, ctx): # actually a RelayParser.Type_Context)
+ super(RelayParser.FuncTypeContext, self).__init__(parser)
+ self.copyFrom(ctx)
+
+ def type_(self, i=None):
+ if i is None:
+ return self.getTypedRuleContexts(RelayParser.Type_Context)
+ else:
+ return self.getTypedRuleContext(RelayParser.Type_Context,i)
+
+ def typeParamSeq(self):
+ return self.getTypedRuleContext(RelayParser.TypeParamSeqContext,0)
+
+
+ def accept(self, visitor):
+ if hasattr(visitor, "visitFuncType"):
+ return visitor.visitFuncType(self)
+ else:
+ return visitor.visitChildren(self)
+
+
+
+ def type_(self):
+
+ localctx = RelayParser.Type_Context(self, self._ctx, self.state)
+ self.enterRule(localctx, 22, self.RULE_type_)
+ self._la = 0 # Token type
+ try:
+ self.state = 284
+ self._errHandler.sync(self)
+ la_ = self._interp.adaptivePredict(self._input,28,self._ctx)
+ if la_ == 1:
+ localctx = RelayParser.TupleTypeContext(self, localctx)
+ self.enterOuterAlt(localctx, 1)
+ self.state = 239
+ self.match(RelayParser.T__0)
+ self.state = 240
+ self.match(RelayParser.T__1)
+ pass
+
+ elif la_ == 2:
+ localctx = RelayParser.TupleTypeContext(self, localctx)
+ self.enterOuterAlt(localctx, 2)
+ self.state = 241
+ self.match(RelayParser.T__0)
+ self.state = 242
+ self.type_()
+ self.state = 243
+ self.match(RelayParser.T__2)
+ self.state = 244
+ self.match(RelayParser.T__1)
+ pass
+
+ elif la_ == 3:
+ localctx = RelayParser.TupleTypeContext(self, localctx)
+ self.enterOuterAlt(localctx, 3)
+ self.state = 246
+ self.match(RelayParser.T__0)
+ self.state = 247
+ self.type_()
+ self.state = 250
+ self._errHandler.sync(self)
+ _la = self._input.LA(1)
+ while True:
+ self.state = 248
+ self.match(RelayParser.T__2)
+ self.state = 249
+ self.type_()
+ self.state = 252
+ self._errHandler.sync(self)
+ _la = self._input.LA(1)
+ if not (_la==RelayParser.T__2):
+ break
+
+ self.state = 254
+ self.match(RelayParser.T__1)
+ pass
+
+ elif la_ == 4:
+ localctx = RelayParser.TypeIdentTypeContext(self, localctx)
+ self.enterOuterAlt(localctx, 4)
+ self.state = 256
+ self.typeIdent()
+ pass
+
+ elif la_ == 5:
+ localctx = RelayParser.TensorTypeContext(self, localctx)
+ self.enterOuterAlt(localctx, 5)
+ self.state = 257
+ self.match(RelayParser.T__16)
+ self.state = 258
+ self.match(RelayParser.T__3)
+ self.state = 259
+ self.shapeSeq()
+ self.state = 260
+ self.match(RelayParser.T__2)
+ self.state = 261
+ self.type_()
+ self.state = 262
+ self.match(RelayParser.T__4)
+ pass
+
+ elif la_ == 6:
+ localctx = RelayParser.FuncTypeContext(self, localctx)
+ self.enterOuterAlt(localctx, 6)
+ self.state = 264
+ self.match(RelayParser.T__12)
+ self.state = 266
+ self._errHandler.sync(self)
+ _la = self._input.LA(1)
+ if _la==RelayParser.T__3:
+ self.state = 265
+ self.typeParamSeq()
+
+
+ self.state = 268
+ self.match(RelayParser.T__0)
+ self.state = 277
+ self._errHandler.sync(self)
+ _la = self._input.LA(1)
+ if (((_la) & ~0x3f) == 0 and ((1 << _la) & ((1 << RelayParser.T__0) | (1 << RelayParser.T__12) | (1 << RelayParser.T__16) | (1 << RelayParser.T__17) | (1 << RelayParser.NAT) | (1 << RelayParser.CNAME))) != 0):
+ self.state = 269
+ self.type_()
+ self.state = 274
+ self._errHandler.sync(self)
+ _la = self._input.LA(1)
+ while _la==RelayParser.T__2:
+ self.state = 270
+ self.match(RelayParser.T__2)
+ self.state = 271
+ self.type_()
+ self.state = 276
+ self._errHandler.sync(self)
+ _la = self._input.LA(1)
+
+
+
+ self.state = 279
+ self.match(RelayParser.T__1)
+ self.state = 280
+ self.match(RelayParser.T__13)
+ self.state = 281
+ self.type_()
+ pass
+
+ elif la_ == 7:
+ localctx = RelayParser.IncompleteTypeContext(self, localctx)
+ self.enterOuterAlt(localctx, 7)
+ self.state = 282
+ self.match(RelayParser.T__17)
+ pass
+
+ elif la_ == 8:
+ localctx = RelayParser.IntTypeContext(self, localctx)
+ self.enterOuterAlt(localctx, 8)
+ self.state = 283
+ self.match(RelayParser.NAT)
+ pass
+
+
+ except RecognitionException as re:
+ localctx.exception = re
+ self._errHandler.reportError(self, re)
+ self._errHandler.recover(self, re)
+ finally:
+ self.exitRule()
+ return localctx
+
+
+ class ShapeSeqContext(ParserRuleContext):
+
+ def __init__(self, parser, parent=None, invokingState=-1):
+ super(RelayParser.ShapeSeqContext, self).__init__(parent, invokingState)
+ self.parser = parser
+
+ def shape(self, i=None):
+ if i is None:
+ return self.getTypedRuleContexts(RelayParser.ShapeContext)
+ else:
+ return self.getTypedRuleContext(RelayParser.ShapeContext,i)
+
+
+ def getRuleIndex(self):
+ return RelayParser.RULE_shapeSeq
+
+ def accept(self, visitor):
+ if hasattr(visitor, "visitShapeSeq"):
+ return visitor.visitShapeSeq(self)
+ else:
+ return visitor.visitChildren(self)
+
+
+
+
+ def shapeSeq(self):
+
+ localctx = RelayParser.ShapeSeqContext(self, self._ctx, self.state)
+ self.enterRule(localctx, 24, self.RULE_shapeSeq)
+ self._la = 0 # Token type
+ try:
+ self.state = 303
+ self._errHandler.sync(self)
+ la_ = self._interp.adaptivePredict(self._input,30,self._ctx)
+ if la_ == 1:
+ self.enterOuterAlt(localctx, 1)
+ self.state = 286
+ self.match(RelayParser.T__0)
+ self.state = 287
+ self.match(RelayParser.T__1)
+ pass
+
+ elif la_ == 2:
+ self.enterOuterAlt(localctx, 2)
+ self.state = 288
+ self.match(RelayParser.T__0)
+ self.state = 289
+ self.shape()
+ self.state = 290
+ self.match(RelayParser.T__2)
+ self.state = 291
+ self.match(RelayParser.T__1)
+ pass
+
+ elif la_ == 3:
+ self.enterOuterAlt(localctx, 3)
+ self.state = 293
+ self.match(RelayParser.T__0)
+ self.state = 294
+ self.shape()
+ self.state = 297
+ self._errHandler.sync(self)
+ _la = self._input.LA(1)
+ while True:
+ self.state = 295
+ self.match(RelayParser.T__2)
+ self.state = 296
+ self.shape()
+ self.state = 299
+ self._errHandler.sync(self)
+ _la = self._input.LA(1)
+ if not (_la==RelayParser.T__2):
+ break
+
+ self.state = 301
+ self.match(RelayParser.T__1)
+ pass
+
+
+ except RecognitionException as re:
+ localctx.exception = re
+ self._errHandler.reportError(self, re)
+ self._errHandler.recover(self, re)
+ finally:
+ self.exitRule()
+ return localctx
+
+
+ class ShapeContext(ParserRuleContext):
+
+ def __init__(self, parser, parent=None, invokingState=-1):
+ super(RelayParser.ShapeContext, self).__init__(parent, invokingState)
+ self.parser = parser
+
+
+ def getRuleIndex(self):
+ return RelayParser.RULE_shape
+
+
+ def copyFrom(self, ctx):
+ super(RelayParser.ShapeContext, self).copyFrom(ctx)
+
+
+
+ class ParensShapeContext(ShapeContext):
+
+ def __init__(self, parser, ctx): # actually a RelayParser.ShapeContext)
+ super(RelayParser.ParensShapeContext, self).__init__(parser)
+ self.copyFrom(ctx)
+
+ def shape(self):
+ return self.getTypedRuleContext(RelayParser.ShapeContext,0)
+
+
+ def accept(self, visitor):
+ if hasattr(visitor, "visitParensShape"):
+ return visitor.visitParensShape(self)
+ else:
+ return visitor.visitChildren(self)
+
+
+ class IntShapeContext(ShapeContext):
+
+ def __init__(self, parser, ctx): # actually a RelayParser.ShapeContext)
+ super(RelayParser.IntShapeContext, self).__init__(parser)
+ self.copyFrom(ctx)
+
+ def NAT(self):
+ return self.getToken(RelayParser.NAT, 0)
+
+ def accept(self, visitor):
+ if hasattr(visitor, "visitIntShape"):
+ return visitor.visitIntShape(self)
+ else:
+ return visitor.visitChildren(self)
+
+
+
+ def shape(self):
+
+ localctx = RelayParser.ShapeContext(self, self._ctx, self.state)
+ self.enterRule(localctx, 26, self.RULE_shape)
+ try:
+ self.state = 310
+ self._errHandler.sync(self)
+ token = self._input.LA(1)
+ if token in [RelayParser.T__0]:
+ localctx = RelayParser.ParensShapeContext(self, localctx)
+ self.enterOuterAlt(localctx, 1)
+ self.state = 305
+ self.match(RelayParser.T__0)
+ self.state = 306
+ self.shape()
+ self.state = 307
+ self.match(RelayParser.T__1)
+ pass
+ elif token in [RelayParser.NAT]:
+ localctx = RelayParser.IntShapeContext(self, localctx)
+ self.enterOuterAlt(localctx, 2)
+ self.state = 309
+ self.match(RelayParser.NAT)
+ pass
+ else:
+ raise NoViableAltException(self)
+
+ except RecognitionException as re:
+ localctx.exception = re
+ self._errHandler.reportError(self, re)
+ self._errHandler.recover(self, re)
+ finally:
+ self.exitRule()
+ return localctx
+
+
+ class TypeIdentContext(ParserRuleContext):
+
+ def __init__(self, parser, parent=None, invokingState=-1):
+ super(RelayParser.TypeIdentContext, self).__init__(parent, invokingState)
+ self.parser = parser
+
+ def CNAME(self):
+ return self.getToken(RelayParser.CNAME, 0)
+
+ def getRuleIndex(self):
+ return RelayParser.RULE_typeIdent
+
+ def accept(self, visitor):
+ if hasattr(visitor, "visitTypeIdent"):
+ return visitor.visitTypeIdent(self)
+ else:
+ return visitor.visitChildren(self)
+
+
+
+
+ def typeIdent(self):
+
+ localctx = RelayParser.TypeIdentContext(self, self._ctx, self.state)
+ self.enterRule(localctx, 28, self.RULE_typeIdent)
+ try:
+ self.enterOuterAlt(localctx, 1)
+ self.state = 312
+ self.match(RelayParser.CNAME)
+ except RecognitionException as re:
+ localctx.exception = re
+ self._errHandler.reportError(self, re)
+ self._errHandler.recover(self, re)
+ finally:
+ self.exitRule()
+ return localctx
+
+
+ class BodyContext(ParserRuleContext):
+
+ def __init__(self, parser, parent=None, invokingState=-1):
+ super(RelayParser.BodyContext, self).__init__(parent, invokingState)
+ self.parser = parser
+
+ def expr(self):
+ return self.getTypedRuleContext(RelayParser.ExprContext,0)
+
+
+ def getRuleIndex(self):
+ return RelayParser.RULE_body
+
+ def accept(self, visitor):
+ if hasattr(visitor, "visitBody"):
+ return visitor.visitBody(self)
+ else:
+ return visitor.visitChildren(self)
+
+
+
+
+ def body(self):
+
+ localctx = RelayParser.BodyContext(self, self._ctx, self.state)
+ self.enterRule(localctx, 30, self.RULE_body)
+ try:
+ self.enterOuterAlt(localctx, 1)
+ self.state = 314
+ self.match(RelayParser.T__10)
+ self.state = 315
+ self.expr(0)
+ self.state = 316
+ self.match(RelayParser.T__11)
+ except RecognitionException as re:
+ localctx.exception = re
+ self._errHandler.reportError(self, re)
+ self._errHandler.recover(self, re)
+ finally:
+ self.exitRule()
+ return localctx
+
+
+ class ScalarContext(ParserRuleContext):
+
+ def __init__(self, parser, parent=None, invokingState=-1):
+ super(RelayParser.ScalarContext, self).__init__(parent, invokingState)
+ self.parser = parser
+
+
+ def getRuleIndex(self):
+ return RelayParser.RULE_scalar
+
+
+ def copyFrom(self, ctx):
+ super(RelayParser.ScalarContext, self).copyFrom(ctx)
+
+
+
+ class ScalarFloatContext(ScalarContext):
+
+ def __init__(self, parser, ctx): # actually a RelayParser.ScalarContext)
+ super(RelayParser.ScalarFloatContext, self).__init__(parser)
+ self.copyFrom(ctx)
+
+ def FLOAT(self):
+ return self.getToken(RelayParser.FLOAT, 0)
+
+ def accept(self, visitor):
+ if hasattr(visitor, "visitScalarFloat"):
+ return visitor.visitScalarFloat(self)
+ else:
+ return visitor.visitChildren(self)
+
+
+ class ScalarBoolContext(ScalarContext):
+
+ def __init__(self, parser, ctx): # actually a RelayParser.ScalarContext)
+ super(RelayParser.ScalarBoolContext, self).__init__(parser)
+ self.copyFrom(ctx)
+
+ def BOOL_LIT(self):
+ return self.getToken(RelayParser.BOOL_LIT, 0)
+
+ def accept(self, visitor):
+ if hasattr(visitor, "visitScalarBool"):
+ return visitor.visitScalarBool(self)
+ else:
+ return visitor.visitChildren(self)
+
+
+ class ScalarIntContext(ScalarContext):
+
+ def __init__(self, parser, ctx): # actually a RelayParser.ScalarContext)
+ super(RelayParser.ScalarIntContext, self).__init__(parser)
+ self.copyFrom(ctx)
+
+ def NAT(self):
+ return self.getToken(RelayParser.NAT, 0)
+
+ def accept(self, visitor):
+ if hasattr(visitor, "visitScalarInt"):
+ return visitor.visitScalarInt(self)
+ else:
+ return visitor.visitChildren(self)
+
+
+
+ def scalar(self):
+
+ localctx = RelayParser.ScalarContext(self, self._ctx, self.state)
+ self.enterRule(localctx, 32, self.RULE_scalar)
+ try:
+ self.state = 321
+ self._errHandler.sync(self)
+ token = self._input.LA(1)
+ if token in [RelayParser.FLOAT]:
+ localctx = RelayParser.ScalarFloatContext(self, localctx)
+ self.enterOuterAlt(localctx, 1)
+ self.state = 318
+ self.match(RelayParser.FLOAT)
+ pass
+ elif token in [RelayParser.NAT]:
+ localctx = RelayParser.ScalarIntContext(self, localctx)
+ self.enterOuterAlt(localctx, 2)
+ self.state = 319
+ self.match(RelayParser.NAT)
+ pass
+ elif token in [RelayParser.BOOL_LIT]:
+ localctx = RelayParser.ScalarBoolContext(self, localctx)
+ self.enterOuterAlt(localctx, 3)
+ self.state = 320
+ self.match(RelayParser.BOOL_LIT)
+ pass
+ else:
+ raise NoViableAltException(self)
+
+ except RecognitionException as re:
+ localctx.exception = re
+ self._errHandler.reportError(self, re)
+ self._errHandler.recover(self, re)
+ finally:
+ self.exitRule()
+ return localctx
+
+
+ class IdentContext(ParserRuleContext):
+
+ def __init__(self, parser, parent=None, invokingState=-1):
+ super(RelayParser.IdentContext, self).__init__(parent, invokingState)
+ self.parser = parser
+
+ def opIdent(self):
+ return self.getTypedRuleContext(RelayParser.OpIdentContext,0)
+
+
+ def GLOBAL_VAR(self):
+ return self.getToken(RelayParser.GLOBAL_VAR, 0)
+
+ def LOCAL_VAR(self):
+ return self.getToken(RelayParser.LOCAL_VAR, 0)
+
+ def GRAPH_VAR(self):
+ return self.getToken(RelayParser.GRAPH_VAR, 0)
+
+ def getRuleIndex(self):
+ return RelayParser.RULE_ident
+
+ def accept(self, visitor):
+ if hasattr(visitor, "visitIdent"):
+ return visitor.visitIdent(self)
+ else:
+ return visitor.visitChildren(self)
+
+
+
+
+ def ident(self):
+
+ localctx = RelayParser.IdentContext(self, self._ctx, self.state)
+ self.enterRule(localctx, 34, self.RULE_ident)
+ try:
+ self.state = 327
+ self._errHandler.sync(self)
+ token = self._input.LA(1)
+ if token in [RelayParser.CNAME]:
+ self.enterOuterAlt(localctx, 1)
+ self.state = 323
+ self.opIdent()
+ pass
+ elif token in [RelayParser.GLOBAL_VAR]:
+ self.enterOuterAlt(localctx, 2)
+ self.state = 324
+ self.match(RelayParser.GLOBAL_VAR)
+ pass
+ elif token in [RelayParser.LOCAL_VAR]:
+ self.enterOuterAlt(localctx, 3)
+ self.state = 325
+ self.match(RelayParser.LOCAL_VAR)
+ pass
+ elif token in [RelayParser.GRAPH_VAR]:
+ self.enterOuterAlt(localctx, 4)
+ self.state = 326
+ self.match(RelayParser.GRAPH_VAR)
+ pass
+ else:
+ raise NoViableAltException(self)
+
+ except RecognitionException as re:
+ localctx.exception = re
+ self._errHandler.reportError(self, re)
+ self._errHandler.recover(self, re)
+ finally:
+ self.exitRule()
+ return localctx
+
+
+
+ def sempred(self, localctx, ruleIndex, predIndex):
+ if self._predicates == None:
+ self._predicates = dict()
+ self._predicates[2] = self.expr_sempred
+ pred = self._predicates.get(ruleIndex, None)
+ if pred is None:
+ raise Exception("No predicate with index:" + str(ruleIndex))
+ else:
+ return pred(localctx, predIndex)
+
+ def expr_sempred(self, localctx, predIndex):
+ if predIndex == 0:
+ return self.precpred(self._ctx, 16)
+
+
+ if predIndex == 1:
+ return self.precpred(self._ctx, 15)
+
+
+ if predIndex == 2:
+ return self.precpred(self._ctx, 14)
+
+
+ if predIndex == 3:
+ return self.precpred(self._ctx, 13)
+
+
+ if predIndex == 4:
+ return self.precpred(self._ctx, 4)
+
+
+ if predIndex == 5:
+ return self.precpred(self._ctx, 18)
+
+
+
+
+
--- /dev/null
+# Generated from /home/sslyu/tvm/python/tvm/relay/grammar/Relay.g4 by ANTLR 4.7.2
+from antlr4 import *
+
+# This class defines a complete generic visitor for a parse tree produced by RelayParser.
+
+class RelayVisitor(ParseTreeVisitor):
+
+ # Visit a parse tree produced by RelayParser#opIdent.
+ def visitOpIdent(self, ctx):
+ return self.visitChildren(ctx)
+
+
+ # Visit a parse tree produced by RelayParser#prog.
+ def visitProg(self, ctx):
+ return self.visitChildren(ctx)
+
+
+ # Visit a parse tree produced by RelayParser#identExpr.
+ def visitIdentExpr(self, ctx):
+ return self.visitChildren(ctx)
+
+
+ # Visit a parse tree produced by RelayParser#call.
+ def visitCall(self, ctx):
+ return self.visitChildren(ctx)
+
+
+ # Visit a parse tree produced by RelayParser#neg.
+ def visitNeg(self, ctx):
+ return self.visitChildren(ctx)
+
+
+ # Visit a parse tree produced by RelayParser#tuple.
+ def visitTuple(self, ctx):
+ return self.visitChildren(ctx)
+
+
+ # Visit a parse tree produced by RelayParser#parens.
+ def visitParens(self, ctx):
+ return self.visitChildren(ctx)
+
+
+ # Visit a parse tree produced by RelayParser#funcExpr.
+ def visitFuncExpr(self, ctx):
+ return self.visitChildren(ctx)
+
+
+ # Visit a parse tree produced by RelayParser#scalarExpr.
+ def visitScalarExpr(self, ctx):
+ return self.visitChildren(ctx)
+
+
+ # Visit a parse tree produced by RelayParser#let.
+ def visitLet(self, ctx):
+ return self.visitChildren(ctx)
+
+
+ # Visit a parse tree produced by RelayParser#tensor.
+ def visitTensor(self, ctx):
+ return self.visitChildren(ctx)
+
+
+ # Visit a parse tree produced by RelayParser#ifElse.
+ def visitIfElse(self, ctx):
+ return self.visitChildren(ctx)
+
+
+ # Visit a parse tree produced by RelayParser#graph.
+ def visitGraph(self, ctx):
+ return self.visitChildren(ctx)
+
+
+ # Visit a parse tree produced by RelayParser#binOp.
+ def visitBinOp(self, ctx):
+ return self.visitChildren(ctx)
+
+
+ # Visit a parse tree produced by RelayParser#func.
+ def visitFunc(self, ctx):
+ return self.visitChildren(ctx)
+
+
+ # Visit a parse tree produced by RelayParser#defn.
+ def visitDefn(self, ctx):
+ return self.visitChildren(ctx)
+
+
+ # Visit a parse tree produced by RelayParser#argList.
+ def visitArgList(self, ctx):
+ return self.visitChildren(ctx)
+
+
+ # Visit a parse tree produced by RelayParser#varList.
+ def visitVarList(self, ctx):
+ return self.visitChildren(ctx)
+
+
+ # Visit a parse tree produced by RelayParser#var.
+ def visitVar(self, ctx):
+ return self.visitChildren(ctx)
+
+
+ # Visit a parse tree produced by RelayParser#attrList.
+ def visitAttrList(self, ctx):
+ return self.visitChildren(ctx)
+
+
+ # Visit a parse tree produced by RelayParser#attr.
+ def visitAttr(self, ctx):
+ return self.visitChildren(ctx)
+
+
+ # Visit a parse tree produced by RelayParser#typeParamSeq.
+ def visitTypeParamSeq(self, ctx):
+ return self.visitChildren(ctx)
+
+
+ # Visit a parse tree produced by RelayParser#tupleType.
+ def visitTupleType(self, ctx):
+ return self.visitChildren(ctx)
+
+
+ # Visit a parse tree produced by RelayParser#typeIdentType.
+ def visitTypeIdentType(self, ctx):
+ return self.visitChildren(ctx)
+
+
+ # Visit a parse tree produced by RelayParser#tensorType.
+ def visitTensorType(self, ctx):
+ return self.visitChildren(ctx)
+
+
+ # Visit a parse tree produced by RelayParser#funcType.
+ def visitFuncType(self, ctx):
+ return self.visitChildren(ctx)
+
+
+ # Visit a parse tree produced by RelayParser#incompleteType.
+ def visitIncompleteType(self, ctx):
+ return self.visitChildren(ctx)
+
+
+ # Visit a parse tree produced by RelayParser#intType.
+ def visitIntType(self, ctx):
+ return self.visitChildren(ctx)
+
+
+ # Visit a parse tree produced by RelayParser#shapeSeq.
+ def visitShapeSeq(self, ctx):
+ return self.visitChildren(ctx)
+
+
+ # Visit a parse tree produced by RelayParser#parensShape.
+ def visitParensShape(self, ctx):
+ return self.visitChildren(ctx)
+
+
+ # Visit a parse tree produced by RelayParser#intShape.
+ def visitIntShape(self, ctx):
+ return self.visitChildren(ctx)
+
+
+ # Visit a parse tree produced by RelayParser#typeIdent.
+ def visitTypeIdent(self, ctx):
+ return self.visitChildren(ctx)
+
+
+ # Visit a parse tree produced by RelayParser#body.
+ def visitBody(self, ctx):
+ return self.visitChildren(ctx)
+
+
+ # Visit a parse tree produced by RelayParser#scalarFloat.
+ def visitScalarFloat(self, ctx):
+ return self.visitChildren(ctx)
+
+
+ # Visit a parse tree produced by RelayParser#scalarInt.
+ def visitScalarInt(self, ctx):
+ return self.visitChildren(ctx)
+
+
+ # Visit a parse tree produced by RelayParser#scalarBool.
+ def visitScalarBool(self, ctx):
+ return self.visitChildren(ctx)
+
+
+ # Visit a parse tree produced by RelayParser#ident.
+ def visitIdent(self, ctx):
+ return self.visitChildren(ctx)
+
+
--- /dev/null
+Relay* binary
+Relay* linguist-generated=true
+Relay* linguist-detectable=false
\ No newline at end of file
--- /dev/null
+token literal names:
+null
+'('
+')'
+','
+'['
+']'
+'if'
+'else'
+'let'
+'='
+';'
+'{'
+'}'
+'fn'
+'->'
+'def'
+':'
+'Tensor'
+'_'
+'v0.0.2'
+null
+null
+null
+'*'
+'/'
+'+'
+'-'
+'<'
+'>'
+'<='
+'>='
+'=='
+'!='
+null
+null
+null
+'mut'
+null
+null
+null
+null
+
+token symbolic names:
+null
+null
+null
+null
+null
+null
+null
+null
+null
+null
+null
+null
+null
+null
+null
+null
+null
+null
+null
+SEMVER
+WS
+LINE_COMMENT
+COMMENT
+MUL
+DIV
+ADD
+SUB
+LT
+GT
+LE
+GE
+EQ
+NE
+GLOBAL_VAR
+LOCAL_VAR
+GRAPH_VAR
+MUT
+BOOL_LIT
+FLOAT
+NAT
+CNAME
+
+rule names:
+opIdent
+prog
+expr
+func
+defn
+argList
+varList
+var
+attrList
+attr
+typeParamSeq
+type_
+shapeSeq
+shape
+typeIdent
+body
+scalar
+ident
+
+
+atn:
+[3, 24715, 42794, 33075, 47597, 16764, 15335, 30598, 22884, 3, 42, 332, 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, 4, 14, 9, 14, 4, 15, 9, 15, 4, 16, 9, 16, 4, 17, 9, 17, 4, 18, 9, 18, 4, 19, 9, 19, 3, 2, 3, 2, 3, 3, 3, 3, 7, 3, 43, 10, 3, 12, 3, 14, 3, 46, 11, 3, 3, 3, 5, 3, 49, 10, 3, 3, 3, 3, 3, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 6, 4, 72, 10, 4, 13, 4, 14, 4, 73, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 7, 4, 82, 10, 4, 12, 4, 14, 4, 85, 11, 4, 5, 4, 87, 10, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 5, 4, 100, 10, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 5, 4, 110, 10, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 5, 4, 128, 10, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 7, 4, 150, 10, 4, 12, 4, 14, 4, 153, 11, 4, 5, 4, 155, 10, 4, 3, 4, 7, 4, 158, 10, 4, 12, 4, 14, 4, 161, 11, 4, 3, 5, 3, 5, 5, 5, 165, 10, 5, 3, 5, 3, 5, 3, 5, 3, 5, 3, 5, 5, 5, 172, 10, 5, 3, 5, 3, 5, 3, 6, 3, 6, 3, 6, 5, 6, 179, 10, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 5, 6, 186, 10, 6, 3, 6, 3, 6, 3, 7, 3, 7, 3, 7, 3, 7, 3, 7, 3, 7, 5, 7, 196, 10, 7, 3, 8, 3, 8, 3, 8, 7, 8, 201, 10, 8, 12, 8, 14, 8, 204, 11, 8, 5, 8, 206, 10, 8, 3, 9, 3, 9, 3, 9, 5, 9, 211, 10, 9, 3, 10, 3, 10, 3, 10, 7, 10, 216, 10, 10, 12, 10, 14, 10, 219, 11, 10, 5, 10, 221, 10, 10, 3, 11, 3, 11, 3, 11, 3, 11, 3, 12, 3, 12, 3, 12, 3, 12, 3, 12, 3, 12, 7, 12, 233, 10, 12, 12, 12, 14, 12, 236, 11, 12, 3, 12, 3, 12, 5, 12, 240, 10, 12, 3, 13, 3, 13, 3, 13, 3, 13, 3, 13, 3, 13, 3, 13, 3, 13, 3, 13, 3, 13, 3, 13, 6, 13, 253, 10, 13, 13, 13, 14, 13, 254, 3, 13, 3, 13, 3, 13, 3, 13, 3, 13, 3, 13, 3, 13, 3, 13, 3, 13, 3, 13, 3, 13, 3, 13, 5, 13, 269, 10, 13, 3, 13, 3, 13, 3, 13, 3, 13, 7, 13, 275, 10, 13, 12, 13, 14, 13, 278, 11, 13, 5, 13, 280, 10, 13, 3, 13, 3, 13, 3, 13, 3, 13, 3, 13, 5, 13, 287, 10, 13, 3, 14, 3, 14, 3, 14, 3, 14, 3, 14, 3, 14, 3, 14, 3, 14, 3, 14, 3, 14, 3, 14, 6, 14, 300, 10, 14, 13, 14, 14, 14, 301, 3, 14, 3, 14, 5, 14, 306, 10, 14, 3, 15, 3, 15, 3, 15, 3, 15, 3, 15, 5, 15, 313, 10, 15, 3, 16, 3, 16, 3, 17, 3, 17, 3, 17, 3, 17, 3, 18, 3, 18, 3, 18, 5, 18, 324, 10, 18, 3, 19, 3, 19, 3, 19, 3, 19, 5, 19, 330, 10, 19, 3, 19, 2, 3, 6, 20, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 2, 6, 3, 2, 25, 26, 3, 2, 27, 28, 3, 2, 29, 32, 3, 2, 33, 34, 2, 373, 2, 38, 3, 2, 2, 2, 4, 40, 3, 2, 2, 2, 6, 127, 3, 2, 2, 2, 8, 162, 3, 2, 2, 2, 10, 175, 3, 2, 2, 2, 12, 195, 3, 2, 2, 2, 14, 205, 3, 2, 2, 2, 16, 207, 3, 2, 2, 2, 18, 220, 3, 2, 2, 2, 20, 222, 3, 2, 2, 2, 22, 239, 3, 2, 2, 2, 24, 286, 3, 2, 2, 2, 26, 305, 3, 2, 2, 2, 28, 312, 3, 2, 2, 2, 30, 314, 3, 2, 2, 2, 32, 316, 3, 2, 2, 2, 34, 323, 3, 2, 2, 2, 36, 329, 3, 2, 2, 2, 38, 39, 7, 42, 2, 2, 39, 3, 3, 2, 2, 2, 40, 48, 7, 21, 2, 2, 41, 43, 5, 10, 6, 2, 42, 41, 3, 2, 2, 2, 43, 46, 3, 2, 2, 2, 44, 42, 3, 2, 2, 2, 44, 45, 3, 2, 2, 2, 45, 49, 3, 2, 2, 2, 46, 44, 3, 2, 2, 2, 47, 49, 5, 6, 4, 2, 48, 44, 3, 2, 2, 2, 48, 47, 3, 2, 2, 2, 49, 50, 3, 2, 2, 2, 50, 51, 7, 2, 2, 3, 51, 5, 3, 2, 2, 2, 52, 53, 8, 4, 1, 2, 53, 54, 7, 3, 2, 2, 54, 55, 5, 6, 4, 2, 55, 56, 7, 4, 2, 2, 56, 128, 3, 2, 2, 2, 57, 58, 7, 28, 2, 2, 58, 128, 5, 6, 4, 19, 59, 128, 5, 8, 5, 2, 60, 61, 7, 3, 2, 2, 61, 128, 7, 4, 2, 2, 62, 63, 7, 3, 2, 2, 63, 64, 5, 6, 4, 2, 64, 65, 7, 5, 2, 2, 65, 66, 7, 4, 2, 2, 66, 128, 3, 2, 2, 2, 67, 68, 7, 3, 2, 2, 68, 71, 5, 6, 4, 2, 69, 70, 7, 5, 2, 2, 70, 72, 5, 6, 4, 2, 71, 69, 3, 2, 2, 2, 72, 73, 3, 2, 2, 2, 73, 71, 3, 2, 2, 2, 73, 74, 3, 2, 2, 2, 74, 75, 3, 2, 2, 2, 75, 76, 7, 4, 2, 2, 76, 128, 3, 2, 2, 2, 77, 86, 7, 6, 2, 2, 78, 83, 5, 6, 4, 2, 79, 80, 7, 5, 2, 2, 80, 82, 5, 6, 4, 2, 81, 79, 3, 2, 2, 2, 82, 85, 3, 2, 2, 2, 83, 81, 3, 2, 2, 2, 83, 84, 3, 2, 2, 2, 84, 87, 3, 2, 2, 2, 85, 83, 3, 2, 2, 2, 86, 78, 3, 2, 2, 2, 86, 87, 3, 2, 2, 2, 87, 88, 3, 2, 2, 2, 88, 128, 7, 7, 2, 2, 89, 90, 7, 8, 2, 2, 90, 91, 7, 3, 2, 2, 91, 92, 5, 6, 4, 2, 92, 93, 7, 4, 2, 2, 93, 94, 5, 32, 17, 2, 94, 95, 7, 9, 2, 2, 95, 96, 5, 32, 17, 2, 96, 128, 3, 2, 2, 2, 97, 99, 7, 10, 2, 2, 98, 100, 7, 38, 2, 2, 99, 98, 3, 2, 2, 2, 99, 100, 3, 2, 2, 2, 100, 101, 3, 2, 2, 2, 101, 102, 5, 16, 9, 2, 102, 103, 7, 11, 2, 2, 103, 104, 5, 6, 4, 2, 104, 105, 7, 12, 2, 2, 105, 106, 5, 6, 4, 8, 106, 128, 3, 2, 2, 2, 107, 109, 7, 10, 2, 2, 108, 110, 7, 38, 2, 2, 109, 108, 3, 2, 2, 2, 109, 110, 3, 2, 2, 2, 110, 111, 3, 2, 2, 2, 111, 112, 5, 16, 9, 2, 112, 113, 7, 11, 2, 2, 113, 114, 7, 13, 2, 2, 114, 115, 5, 6, 4, 2, 115, 116, 7, 14, 2, 2, 116, 117, 7, 12, 2, 2, 117, 118, 5, 6, 4, 7, 118, 128, 3, 2, 2, 2, 119, 120, 5, 36, 19, 2, 120, 121, 7, 11, 2, 2, 121, 122, 5, 6, 4, 2, 122, 123, 7, 12, 2, 2, 123, 124, 5, 6, 4, 5, 124, 128, 3, 2, 2, 2, 125, 128, 5, 36, 19, 2, 126, 128, 5, 34, 18, 2, 127, 52, 3, 2, 2, 2, 127, 57, 3, 2, 2, 2, 127, 59, 3, 2, 2, 2, 127, 60, 3, 2, 2, 2, 127, 62, 3, 2, 2, 2, 127, 67, 3, 2, 2, 2, 127, 77, 3, 2, 2, 2, 127, 89, 3, 2, 2, 2, 127, 97, 3, 2, 2, 2, 127, 107, 3, 2, 2, 2, 127, 119, 3, 2, 2, 2, 127, 125, 3, 2, 2, 2, 127, 126, 3, 2, 2, 2, 128, 159, 3, 2, 2, 2, 129, 130, 12, 18, 2, 2, 130, 131, 9, 2, 2, 2, 131, 158, 5, 6, 4, 19, 132, 133, 12, 17, 2, 2, 133, 134, 9, 3, 2, 2, 134, 158, 5, 6, 4, 18, 135, 136, 12, 16, 2, 2, 136, 137, 9, 4, 2, 2, 137, 158, 5, 6, 4, 17, 138, 139, 12, 15, 2, 2, 139, 140, 9, 5, 2, 2, 140, 158, 5, 6, 4, 16, 141, 142, 12, 6, 2, 2, 142, 143, 7, 12, 2, 2, 143, 158, 5, 6, 4, 7, 144, 145, 12, 20, 2, 2, 145, 154, 7, 3, 2, 2, 146, 151, 5, 6, 4, 2, 147, 148, 7, 5, 2, 2, 148, 150, 5, 6, 4, 2, 149, 147, 3, 2, 2, 2, 150, 153, 3, 2, 2, 2, 151, 149, 3, 2, 2, 2, 151, 152, 3, 2, 2, 2, 152, 155, 3, 2, 2, 2, 153, 151, 3, 2, 2, 2, 154, 146, 3, 2, 2, 2, 154, 155, 3, 2, 2, 2, 155, 156, 3, 2, 2, 2, 156, 158, 7, 4, 2, 2, 157, 129, 3, 2, 2, 2, 157, 132, 3, 2, 2, 2, 157, 135, 3, 2, 2, 2, 157, 138, 3, 2, 2, 2, 157, 141, 3, 2, 2, 2, 157, 144, 3, 2, 2, 2, 158, 161, 3, 2, 2, 2, 159, 157, 3, 2, 2, 2, 159, 160, 3, 2, 2, 2, 160, 7, 3, 2, 2, 2, 161, 159, 3, 2, 2, 2, 162, 164, 7, 15, 2, 2, 163, 165, 5, 22, 12, 2, 164, 163, 3, 2, 2, 2, 164, 165, 3, 2, 2, 2, 165, 166, 3, 2, 2, 2, 166, 167, 7, 3, 2, 2, 167, 168, 5, 12, 7, 2, 168, 171, 7, 4, 2, 2, 169, 170, 7, 16, 2, 2, 170, 172, 5, 24, 13, 2, 171, 169, 3, 2, 2, 2, 171, 172, 3, 2, 2, 2, 172, 173, 3, 2, 2, 2, 173, 174, 5, 32, 17, 2, 174, 9, 3, 2, 2, 2, 175, 176, 7, 17, 2, 2, 176, 178, 5, 36, 19, 2, 177, 179, 5, 22, 12, 2, 178, 177, 3, 2, 2, 2, 178, 179, 3, 2, 2, 2, 179, 180, 3, 2, 2, 2, 180, 181, 7, 3, 2, 2, 181, 182, 5, 12, 7, 2, 182, 185, 7, 4, 2, 2, 183, 184, 7, 16, 2, 2, 184, 186, 5, 24, 13, 2, 185, 183, 3, 2, 2, 2, 185, 186, 3, 2, 2, 2, 186, 187, 3, 2, 2, 2, 187, 188, 5, 32, 17, 2, 188, 11, 3, 2, 2, 2, 189, 196, 5, 14, 8, 2, 190, 196, 5, 18, 10, 2, 191, 192, 5, 14, 8, 2, 192, 193, 7, 5, 2, 2, 193, 194, 5, 18, 10, 2, 194, 196, 3, 2, 2, 2, 195, 189, 3, 2, 2, 2, 195, 190, 3, 2, 2, 2, 195, 191, 3, 2, 2, 2, 196, 13, 3, 2, 2, 2, 197, 202, 5, 16, 9, 2, 198, 199, 7, 5, 2, 2, 199, 201, 5, 16, 9, 2, 200, 198, 3, 2, 2, 2, 201, 204, 3, 2, 2, 2, 202, 200, 3, 2, 2, 2, 202, 203, 3, 2, 2, 2, 203, 206, 3, 2, 2, 2, 204, 202, 3, 2, 2, 2, 205, 197, 3, 2, 2, 2, 205, 206, 3, 2, 2, 2, 206, 15, 3, 2, 2, 2, 207, 210, 5, 36, 19, 2, 208, 209, 7, 18, 2, 2, 209, 211, 5, 24, 13, 2, 210, 208, 3, 2, 2, 2, 210, 211, 3, 2, 2, 2, 211, 17, 3, 2, 2, 2, 212, 217, 5, 20, 11, 2, 213, 214, 7, 5, 2, 2, 214, 216, 5, 20, 11, 2, 215, 213, 3, 2, 2, 2, 216, 219, 3, 2, 2, 2, 217, 215, 3, 2, 2, 2, 217, 218, 3, 2, 2, 2, 218, 221, 3, 2, 2, 2, 219, 217, 3, 2, 2, 2, 220, 212, 3, 2, 2, 2, 220, 221, 3, 2, 2, 2, 221, 19, 3, 2, 2, 2, 222, 223, 7, 42, 2, 2, 223, 224, 7, 11, 2, 2, 224, 225, 5, 6, 4, 2, 225, 21, 3, 2, 2, 2, 226, 227, 7, 6, 2, 2, 227, 240, 7, 7, 2, 2, 228, 229, 7, 6, 2, 2, 229, 234, 5, 36, 19, 2, 230, 231, 7, 5, 2, 2, 231, 233, 5, 36, 19, 2, 232, 230, 3, 2, 2, 2, 233, 236, 3, 2, 2, 2, 234, 232, 3, 2, 2, 2, 234, 235, 3, 2, 2, 2, 235, 237, 3, 2, 2, 2, 236, 234, 3, 2, 2, 2, 237, 238, 7, 7, 2, 2, 238, 240, 3, 2, 2, 2, 239, 226, 3, 2, 2, 2, 239, 228, 3, 2, 2, 2, 240, 23, 3, 2, 2, 2, 241, 242, 7, 3, 2, 2, 242, 287, 7, 4, 2, 2, 243, 244, 7, 3, 2, 2, 244, 245, 5, 24, 13, 2, 245, 246, 7, 5, 2, 2, 246, 247, 7, 4, 2, 2, 247, 287, 3, 2, 2, 2, 248, 249, 7, 3, 2, 2, 249, 252, 5, 24, 13, 2, 250, 251, 7, 5, 2, 2, 251, 253, 5, 24, 13, 2, 252, 250, 3, 2, 2, 2, 253, 254, 3, 2, 2, 2, 254, 252, 3, 2, 2, 2, 254, 255, 3, 2, 2, 2, 255, 256, 3, 2, 2, 2, 256, 257, 7, 4, 2, 2, 257, 287, 3, 2, 2, 2, 258, 287, 5, 30, 16, 2, 259, 260, 7, 19, 2, 2, 260, 261, 7, 6, 2, 2, 261, 262, 5, 26, 14, 2, 262, 263, 7, 5, 2, 2, 263, 264, 5, 24, 13, 2, 264, 265, 7, 7, 2, 2, 265, 287, 3, 2, 2, 2, 266, 268, 7, 15, 2, 2, 267, 269, 5, 22, 12, 2, 268, 267, 3, 2, 2, 2, 268, 269, 3, 2, 2, 2, 269, 270, 3, 2, 2, 2, 270, 279, 7, 3, 2, 2, 271, 276, 5, 24, 13, 2, 272, 273, 7, 5, 2, 2, 273, 275, 5, 24, 13, 2, 274, 272, 3, 2, 2, 2, 275, 278, 3, 2, 2, 2, 276, 274, 3, 2, 2, 2, 276, 277, 3, 2, 2, 2, 277, 280, 3, 2, 2, 2, 278, 276, 3, 2, 2, 2, 279, 271, 3, 2, 2, 2, 279, 280, 3, 2, 2, 2, 280, 281, 3, 2, 2, 2, 281, 282, 7, 4, 2, 2, 282, 283, 7, 16, 2, 2, 283, 287, 5, 24, 13, 2, 284, 287, 7, 20, 2, 2, 285, 287, 7, 41, 2, 2, 286, 241, 3, 2, 2, 2, 286, 243, 3, 2, 2, 2, 286, 248, 3, 2, 2, 2, 286, 258, 3, 2, 2, 2, 286, 259, 3, 2, 2, 2, 286, 266, 3, 2, 2, 2, 286, 284, 3, 2, 2, 2, 286, 285, 3, 2, 2, 2, 287, 25, 3, 2, 2, 2, 288, 289, 7, 3, 2, 2, 289, 306, 7, 4, 2, 2, 290, 291, 7, 3, 2, 2, 291, 292, 5, 28, 15, 2, 292, 293, 7, 5, 2, 2, 293, 294, 7, 4, 2, 2, 294, 306, 3, 2, 2, 2, 295, 296, 7, 3, 2, 2, 296, 299, 5, 28, 15, 2, 297, 298, 7, 5, 2, 2, 298, 300, 5, 28, 15, 2, 299, 297, 3, 2, 2, 2, 300, 301, 3, 2, 2, 2, 301, 299, 3, 2, 2, 2, 301, 302, 3, 2, 2, 2, 302, 303, 3, 2, 2, 2, 303, 304, 7, 4, 2, 2, 304, 306, 3, 2, 2, 2, 305, 288, 3, 2, 2, 2, 305, 290, 3, 2, 2, 2, 305, 295, 3, 2, 2, 2, 306, 27, 3, 2, 2, 2, 307, 308, 7, 3, 2, 2, 308, 309, 5, 28, 15, 2, 309, 310, 7, 4, 2, 2, 310, 313, 3, 2, 2, 2, 311, 313, 7, 41, 2, 2, 312, 307, 3, 2, 2, 2, 312, 311, 3, 2, 2, 2, 313, 29, 3, 2, 2, 2, 314, 315, 7, 42, 2, 2, 315, 31, 3, 2, 2, 2, 316, 317, 7, 13, 2, 2, 317, 318, 5, 6, 4, 2, 318, 319, 7, 14, 2, 2, 319, 33, 3, 2, 2, 2, 320, 324, 7, 40, 2, 2, 321, 324, 7, 41, 2, 2, 322, 324, 7, 39, 2, 2, 323, 320, 3, 2, 2, 2, 323, 321, 3, 2, 2, 2, 323, 322, 3, 2, 2, 2, 324, 35, 3, 2, 2, 2, 325, 330, 5, 2, 2, 2, 326, 330, 7, 35, 2, 2, 327, 330, 7, 36, 2, 2, 328, 330, 7, 37, 2, 2, 329, 325, 3, 2, 2, 2, 329, 326, 3, 2, 2, 2, 329, 327, 3, 2, 2, 2, 329, 328, 3, 2, 2, 2, 330, 37, 3, 2, 2, 2, 36, 44, 48, 73, 83, 86, 99, 109, 127, 151, 154, 157, 159, 164, 171, 178, 185, 195, 202, 205, 210, 217, 220, 234, 239, 254, 268, 276, 279, 286, 301, 305, 312, 323, 329]
\ No newline at end of file
--- /dev/null
+T__0=1
+T__1=2
+T__2=3
+T__3=4
+T__4=5
+T__5=6
+T__6=7
+T__7=8
+T__8=9
+T__9=10
+T__10=11
+T__11=12
+T__12=13
+T__13=14
+T__14=15
+T__15=16
+T__16=17
+T__17=18
+SEMVER=19
+WS=20
+LINE_COMMENT=21
+COMMENT=22
+MUL=23
+DIV=24
+ADD=25
+SUB=26
+LT=27
+GT=28
+LE=29
+GE=30
+EQ=31
+NE=32
+GLOBAL_VAR=33
+LOCAL_VAR=34
+GRAPH_VAR=35
+MUT=36
+BOOL_LIT=37
+FLOAT=38
+NAT=39
+CNAME=40
+'('=1
+')'=2
+','=3
+'['=4
+']'=5
+'if'=6
+'else'=7
+'let'=8
+'='=9
+';'=10
+'{'=11
+'}'=12
+'fn'=13
+'->'=14
+'def'=15
+':'=16
+'Tensor'=17
+'_'=18
+'v0.0.2'=19
+'*'=23
+'/'=24
+'+'=25
+'-'=26
+'<'=27
+'>'=28
+'<='=29
+'>='=30
+'=='=31
+'!='=32
+'mut'=36
--- /dev/null
+token literal names:
+null
+'('
+')'
+','
+'['
+']'
+'if'
+'else'
+'let'
+'='
+';'
+'{'
+'}'
+'fn'
+'->'
+'def'
+':'
+'Tensor'
+'_'
+'v0.0.2'
+null
+null
+null
+'*'
+'/'
+'+'
+'-'
+'<'
+'>'
+'<='
+'>='
+'=='
+'!='
+null
+null
+null
+'mut'
+null
+null
+null
+null
+
+token symbolic names:
+null
+null
+null
+null
+null
+null
+null
+null
+null
+null
+null
+null
+null
+null
+null
+null
+null
+null
+null
+SEMVER
+WS
+LINE_COMMENT
+COMMENT
+MUL
+DIV
+ADD
+SUB
+LT
+GT
+LE
+GE
+EQ
+NE
+GLOBAL_VAR
+LOCAL_VAR
+GRAPH_VAR
+MUT
+BOOL_LIT
+FLOAT
+NAT
+CNAME
+
+rule names:
+T__0
+T__1
+T__2
+T__3
+T__4
+T__5
+T__6
+T__7
+T__8
+T__9
+T__10
+T__11
+T__12
+T__13
+T__14
+T__15
+T__16
+T__17
+SEMVER
+WS
+LINE_COMMENT
+COMMENT
+MUL
+DIV
+ADD
+SUB
+LT
+GT
+LE
+GE
+EQ
+NE
+GLOBAL_VAR
+LOCAL_VAR
+GRAPH_VAR
+MUT
+BOOL_LIT
+FLOAT
+NAT
+EXP
+CNAME
+LETTER
+DIGIT
+
+channel names:
+DEFAULT_TOKEN_CHANNEL
+HIDDEN
+
+mode names:
+DEFAULT_MODE
+
+atn:
+[3, 24715, 42794, 33075, 47597, 16764, 15335, 30598, 22884, 2, 42, 267, 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, 4, 14, 9, 14, 4, 15, 9, 15, 4, 16, 9, 16, 4, 17, 9, 17, 4, 18, 9, 18, 4, 19, 9, 19, 4, 20, 9, 20, 4, 21, 9, 21, 4, 22, 9, 22, 4, 23, 9, 23, 4, 24, 9, 24, 4, 25, 9, 25, 4, 26, 9, 26, 4, 27, 9, 27, 4, 28, 9, 28, 4, 29, 9, 29, 4, 30, 9, 30, 4, 31, 9, 31, 4, 32, 9, 32, 4, 33, 9, 33, 4, 34, 9, 34, 4, 35, 9, 35, 4, 36, 9, 36, 4, 37, 9, 37, 4, 38, 9, 38, 4, 39, 9, 39, 4, 40, 9, 40, 4, 41, 9, 41, 4, 42, 9, 42, 4, 43, 9, 43, 4, 44, 9, 44, 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, 7, 3, 8, 3, 8, 3, 8, 3, 8, 3, 8, 3, 9, 3, 9, 3, 9, 3, 9, 3, 10, 3, 10, 3, 11, 3, 11, 3, 12, 3, 12, 3, 13, 3, 13, 3, 14, 3, 14, 3, 14, 3, 15, 3, 15, 3, 15, 3, 16, 3, 16, 3, 16, 3, 16, 3, 17, 3, 17, 3, 18, 3, 18, 3, 18, 3, 18, 3, 18, 3, 18, 3, 18, 3, 19, 3, 19, 3, 20, 3, 20, 3, 20, 3, 20, 3, 20, 3, 20, 3, 20, 3, 21, 6, 21, 149, 10, 21, 13, 21, 14, 21, 150, 3, 21, 3, 21, 3, 22, 3, 22, 3, 22, 3, 22, 7, 22, 159, 10, 22, 12, 22, 14, 22, 162, 11, 22, 3, 22, 3, 22, 3, 22, 3, 22, 3, 23, 3, 23, 3, 23, 3, 23, 7, 23, 172, 10, 23, 12, 23, 14, 23, 175, 11, 23, 3, 23, 3, 23, 3, 23, 3, 23, 3, 23, 3, 24, 3, 24, 3, 25, 3, 25, 3, 26, 3, 26, 3, 27, 3, 27, 3, 28, 3, 28, 3, 29, 3, 29, 3, 30, 3, 30, 3, 30, 3, 31, 3, 31, 3, 31, 3, 32, 3, 32, 3, 32, 3, 33, 3, 33, 3, 33, 3, 34, 3, 34, 3, 34, 3, 35, 3, 35, 3, 35, 3, 36, 3, 36, 3, 36, 3, 37, 3, 37, 3, 37, 3, 37, 3, 38, 3, 38, 3, 38, 3, 38, 3, 38, 3, 38, 3, 38, 3, 38, 3, 38, 5, 38, 228, 10, 38, 3, 39, 3, 39, 3, 39, 3, 39, 5, 39, 234, 10, 39, 3, 39, 3, 39, 3, 39, 5, 39, 239, 10, 39, 3, 40, 6, 40, 242, 10, 40, 13, 40, 14, 40, 243, 3, 41, 3, 41, 5, 41, 248, 10, 41, 3, 41, 3, 41, 3, 42, 3, 42, 5, 42, 254, 10, 42, 3, 42, 3, 42, 3, 42, 7, 42, 259, 10, 42, 12, 42, 14, 42, 262, 11, 42, 3, 43, 3, 43, 3, 44, 3, 44, 4, 160, 173, 2, 45, 3, 3, 5, 4, 7, 5, 9, 6, 11, 7, 13, 8, 15, 9, 17, 10, 19, 11, 21, 12, 23, 13, 25, 14, 27, 15, 29, 16, 31, 17, 33, 18, 35, 19, 37, 20, 39, 21, 41, 22, 43, 23, 45, 24, 47, 25, 49, 26, 51, 27, 53, 28, 55, 29, 57, 30, 59, 31, 61, 32, 63, 33, 65, 34, 67, 35, 69, 36, 71, 37, 73, 38, 75, 39, 77, 40, 79, 41, 81, 2, 83, 42, 85, 2, 87, 2, 3, 2, 7, 5, 2, 11, 12, 15, 15, 34, 34, 4, 2, 71, 71, 103, 103, 4, 2, 45, 45, 47, 47, 4, 2, 67, 92, 99, 124, 3, 2, 50, 59, 2, 275, 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, 15, 3, 2, 2, 2, 2, 17, 3, 2, 2, 2, 2, 19, 3, 2, 2, 2, 2, 21, 3, 2, 2, 2, 2, 23, 3, 2, 2, 2, 2, 25, 3, 2, 2, 2, 2, 27, 3, 2, 2, 2, 2, 29, 3, 2, 2, 2, 2, 31, 3, 2, 2, 2, 2, 33, 3, 2, 2, 2, 2, 35, 3, 2, 2, 2, 2, 37, 3, 2, 2, 2, 2, 39, 3, 2, 2, 2, 2, 41, 3, 2, 2, 2, 2, 43, 3, 2, 2, 2, 2, 45, 3, 2, 2, 2, 2, 47, 3, 2, 2, 2, 2, 49, 3, 2, 2, 2, 2, 51, 3, 2, 2, 2, 2, 53, 3, 2, 2, 2, 2, 55, 3, 2, 2, 2, 2, 57, 3, 2, 2, 2, 2, 59, 3, 2, 2, 2, 2, 61, 3, 2, 2, 2, 2, 63, 3, 2, 2, 2, 2, 65, 3, 2, 2, 2, 2, 67, 3, 2, 2, 2, 2, 69, 3, 2, 2, 2, 2, 71, 3, 2, 2, 2, 2, 73, 3, 2, 2, 2, 2, 75, 3, 2, 2, 2, 2, 77, 3, 2, 2, 2, 2, 79, 3, 2, 2, 2, 2, 83, 3, 2, 2, 2, 3, 89, 3, 2, 2, 2, 5, 91, 3, 2, 2, 2, 7, 93, 3, 2, 2, 2, 9, 95, 3, 2, 2, 2, 11, 97, 3, 2, 2, 2, 13, 99, 3, 2, 2, 2, 15, 102, 3, 2, 2, 2, 17, 107, 3, 2, 2, 2, 19, 111, 3, 2, 2, 2, 21, 113, 3, 2, 2, 2, 23, 115, 3, 2, 2, 2, 25, 117, 3, 2, 2, 2, 27, 119, 3, 2, 2, 2, 29, 122, 3, 2, 2, 2, 31, 125, 3, 2, 2, 2, 33, 129, 3, 2, 2, 2, 35, 131, 3, 2, 2, 2, 37, 138, 3, 2, 2, 2, 39, 140, 3, 2, 2, 2, 41, 148, 3, 2, 2, 2, 43, 154, 3, 2, 2, 2, 45, 167, 3, 2, 2, 2, 47, 181, 3, 2, 2, 2, 49, 183, 3, 2, 2, 2, 51, 185, 3, 2, 2, 2, 53, 187, 3, 2, 2, 2, 55, 189, 3, 2, 2, 2, 57, 191, 3, 2, 2, 2, 59, 193, 3, 2, 2, 2, 61, 196, 3, 2, 2, 2, 63, 199, 3, 2, 2, 2, 65, 202, 3, 2, 2, 2, 67, 205, 3, 2, 2, 2, 69, 208, 3, 2, 2, 2, 71, 211, 3, 2, 2, 2, 73, 214, 3, 2, 2, 2, 75, 227, 3, 2, 2, 2, 77, 238, 3, 2, 2, 2, 79, 241, 3, 2, 2, 2, 81, 245, 3, 2, 2, 2, 83, 253, 3, 2, 2, 2, 85, 263, 3, 2, 2, 2, 87, 265, 3, 2, 2, 2, 89, 90, 7, 42, 2, 2, 90, 4, 3, 2, 2, 2, 91, 92, 7, 43, 2, 2, 92, 6, 3, 2, 2, 2, 93, 94, 7, 46, 2, 2, 94, 8, 3, 2, 2, 2, 95, 96, 7, 93, 2, 2, 96, 10, 3, 2, 2, 2, 97, 98, 7, 95, 2, 2, 98, 12, 3, 2, 2, 2, 99, 100, 7, 107, 2, 2, 100, 101, 7, 104, 2, 2, 101, 14, 3, 2, 2, 2, 102, 103, 7, 103, 2, 2, 103, 104, 7, 110, 2, 2, 104, 105, 7, 117, 2, 2, 105, 106, 7, 103, 2, 2, 106, 16, 3, 2, 2, 2, 107, 108, 7, 110, 2, 2, 108, 109, 7, 103, 2, 2, 109, 110, 7, 118, 2, 2, 110, 18, 3, 2, 2, 2, 111, 112, 7, 63, 2, 2, 112, 20, 3, 2, 2, 2, 113, 114, 7, 61, 2, 2, 114, 22, 3, 2, 2, 2, 115, 116, 7, 125, 2, 2, 116, 24, 3, 2, 2, 2, 117, 118, 7, 127, 2, 2, 118, 26, 3, 2, 2, 2, 119, 120, 7, 104, 2, 2, 120, 121, 7, 112, 2, 2, 121, 28, 3, 2, 2, 2, 122, 123, 7, 47, 2, 2, 123, 124, 7, 64, 2, 2, 124, 30, 3, 2, 2, 2, 125, 126, 7, 102, 2, 2, 126, 127, 7, 103, 2, 2, 127, 128, 7, 104, 2, 2, 128, 32, 3, 2, 2, 2, 129, 130, 7, 60, 2, 2, 130, 34, 3, 2, 2, 2, 131, 132, 7, 86, 2, 2, 132, 133, 7, 103, 2, 2, 133, 134, 7, 112, 2, 2, 134, 135, 7, 117, 2, 2, 135, 136, 7, 113, 2, 2, 136, 137, 7, 116, 2, 2, 137, 36, 3, 2, 2, 2, 138, 139, 7, 97, 2, 2, 139, 38, 3, 2, 2, 2, 140, 141, 7, 120, 2, 2, 141, 142, 7, 50, 2, 2, 142, 143, 7, 48, 2, 2, 143, 144, 7, 50, 2, 2, 144, 145, 7, 48, 2, 2, 145, 146, 7, 52, 2, 2, 146, 40, 3, 2, 2, 2, 147, 149, 9, 2, 2, 2, 148, 147, 3, 2, 2, 2, 149, 150, 3, 2, 2, 2, 150, 148, 3, 2, 2, 2, 150, 151, 3, 2, 2, 2, 151, 152, 3, 2, 2, 2, 152, 153, 8, 21, 2, 2, 153, 42, 3, 2, 2, 2, 154, 155, 7, 49, 2, 2, 155, 156, 7, 49, 2, 2, 156, 160, 3, 2, 2, 2, 157, 159, 11, 2, 2, 2, 158, 157, 3, 2, 2, 2, 159, 162, 3, 2, 2, 2, 160, 161, 3, 2, 2, 2, 160, 158, 3, 2, 2, 2, 161, 163, 3, 2, 2, 2, 162, 160, 3, 2, 2, 2, 163, 164, 7, 12, 2, 2, 164, 165, 3, 2, 2, 2, 165, 166, 8, 22, 2, 2, 166, 44, 3, 2, 2, 2, 167, 168, 7, 49, 2, 2, 168, 169, 7, 44, 2, 2, 169, 173, 3, 2, 2, 2, 170, 172, 11, 2, 2, 2, 171, 170, 3, 2, 2, 2, 172, 175, 3, 2, 2, 2, 173, 174, 3, 2, 2, 2, 173, 171, 3, 2, 2, 2, 174, 176, 3, 2, 2, 2, 175, 173, 3, 2, 2, 2, 176, 177, 7, 44, 2, 2, 177, 178, 7, 49, 2, 2, 178, 179, 3, 2, 2, 2, 179, 180, 8, 23, 2, 2, 180, 46, 3, 2, 2, 2, 181, 182, 7, 44, 2, 2, 182, 48, 3, 2, 2, 2, 183, 184, 7, 49, 2, 2, 184, 50, 3, 2, 2, 2, 185, 186, 7, 45, 2, 2, 186, 52, 3, 2, 2, 2, 187, 188, 7, 47, 2, 2, 188, 54, 3, 2, 2, 2, 189, 190, 7, 62, 2, 2, 190, 56, 3, 2, 2, 2, 191, 192, 7, 64, 2, 2, 192, 58, 3, 2, 2, 2, 193, 194, 7, 62, 2, 2, 194, 195, 7, 63, 2, 2, 195, 60, 3, 2, 2, 2, 196, 197, 7, 64, 2, 2, 197, 198, 7, 63, 2, 2, 198, 62, 3, 2, 2, 2, 199, 200, 7, 63, 2, 2, 200, 201, 7, 63, 2, 2, 201, 64, 3, 2, 2, 2, 202, 203, 7, 35, 2, 2, 203, 204, 7, 63, 2, 2, 204, 66, 3, 2, 2, 2, 205, 206, 7, 66, 2, 2, 206, 207, 5, 83, 42, 2, 207, 68, 3, 2, 2, 2, 208, 209, 7, 39, 2, 2, 209, 210, 5, 83, 42, 2, 210, 70, 3, 2, 2, 2, 211, 212, 7, 39, 2, 2, 212, 213, 5, 79, 40, 2, 213, 72, 3, 2, 2, 2, 214, 215, 7, 111, 2, 2, 215, 216, 7, 119, 2, 2, 216, 217, 7, 118, 2, 2, 217, 74, 3, 2, 2, 2, 218, 219, 7, 86, 2, 2, 219, 220, 7, 116, 2, 2, 220, 221, 7, 119, 2, 2, 221, 228, 7, 103, 2, 2, 222, 223, 7, 72, 2, 2, 223, 224, 7, 99, 2, 2, 224, 225, 7, 110, 2, 2, 225, 226, 7, 117, 2, 2, 226, 228, 7, 103, 2, 2, 227, 218, 3, 2, 2, 2, 227, 222, 3, 2, 2, 2, 228, 76, 3, 2, 2, 2, 229, 230, 5, 79, 40, 2, 230, 231, 7, 48, 2, 2, 231, 233, 5, 79, 40, 2, 232, 234, 5, 81, 41, 2, 233, 232, 3, 2, 2, 2, 233, 234, 3, 2, 2, 2, 234, 239, 3, 2, 2, 2, 235, 236, 5, 79, 40, 2, 236, 237, 5, 81, 41, 2, 237, 239, 3, 2, 2, 2, 238, 229, 3, 2, 2, 2, 238, 235, 3, 2, 2, 2, 239, 78, 3, 2, 2, 2, 240, 242, 5, 87, 44, 2, 241, 240, 3, 2, 2, 2, 242, 243, 3, 2, 2, 2, 243, 241, 3, 2, 2, 2, 243, 244, 3, 2, 2, 2, 244, 80, 3, 2, 2, 2, 245, 247, 9, 3, 2, 2, 246, 248, 9, 4, 2, 2, 247, 246, 3, 2, 2, 2, 247, 248, 3, 2, 2, 2, 248, 249, 3, 2, 2, 2, 249, 250, 5, 79, 40, 2, 250, 82, 3, 2, 2, 2, 251, 254, 7, 97, 2, 2, 252, 254, 5, 85, 43, 2, 253, 251, 3, 2, 2, 2, 253, 252, 3, 2, 2, 2, 254, 260, 3, 2, 2, 2, 255, 259, 7, 97, 2, 2, 256, 259, 5, 85, 43, 2, 257, 259, 5, 87, 44, 2, 258, 255, 3, 2, 2, 2, 258, 256, 3, 2, 2, 2, 258, 257, 3, 2, 2, 2, 259, 262, 3, 2, 2, 2, 260, 258, 3, 2, 2, 2, 260, 261, 3, 2, 2, 2, 261, 84, 3, 2, 2, 2, 262, 260, 3, 2, 2, 2, 263, 264, 9, 5, 2, 2, 264, 86, 3, 2, 2, 2, 265, 266, 9, 6, 2, 2, 266, 88, 3, 2, 2, 2, 14, 2, 150, 160, 173, 227, 233, 238, 243, 247, 253, 258, 260, 3, 8, 2, 2]
\ No newline at end of file
--- /dev/null
+# Generated from /home/sslyu/tvm/python/tvm/relay/grammar/Relay.g4 by ANTLR 4.7.2
+from antlr4 import *
+from io import StringIO
+from typing.io import TextIO
+import sys
+
+
+
+def serializedATN():
+ with StringIO() as buf:
+ buf.write("\3\u608b\ua72a\u8133\ub9ed\u417c\u3be7\u7786\u5964\2*")
+ buf.write("\u010b\b\1\4\2\t\2\4\3\t\3\4\4\t\4\4\5\t\5\4\6\t\6\4\7")
+ buf.write("\t\7\4\b\t\b\4\t\t\t\4\n\t\n\4\13\t\13\4\f\t\f\4\r\t\r")
+ buf.write("\4\16\t\16\4\17\t\17\4\20\t\20\4\21\t\21\4\22\t\22\4\23")
+ buf.write("\t\23\4\24\t\24\4\25\t\25\4\26\t\26\4\27\t\27\4\30\t\30")
+ buf.write("\4\31\t\31\4\32\t\32\4\33\t\33\4\34\t\34\4\35\t\35\4\36")
+ buf.write("\t\36\4\37\t\37\4 \t \4!\t!\4\"\t\"\4#\t#\4$\t$\4%\t%")
+ buf.write("\4&\t&\4\'\t\'\4(\t(\4)\t)\4*\t*\4+\t+\4,\t,\3\2\3\2\3")
+ buf.write("\3\3\3\3\4\3\4\3\5\3\5\3\6\3\6\3\7\3\7\3\7\3\b\3\b\3\b")
+ buf.write("\3\b\3\b\3\t\3\t\3\t\3\t\3\n\3\n\3\13\3\13\3\f\3\f\3\r")
+ buf.write("\3\r\3\16\3\16\3\16\3\17\3\17\3\17\3\20\3\20\3\20\3\20")
+ buf.write("\3\21\3\21\3\22\3\22\3\22\3\22\3\22\3\22\3\22\3\23\3\23")
+ buf.write("\3\24\3\24\3\24\3\24\3\24\3\24\3\24\3\25\6\25\u0095\n")
+ buf.write("\25\r\25\16\25\u0096\3\25\3\25\3\26\3\26\3\26\3\26\7\26")
+ buf.write("\u009f\n\26\f\26\16\26\u00a2\13\26\3\26\3\26\3\26\3\26")
+ buf.write("\3\27\3\27\3\27\3\27\7\27\u00ac\n\27\f\27\16\27\u00af")
+ buf.write("\13\27\3\27\3\27\3\27\3\27\3\27\3\30\3\30\3\31\3\31\3")
+ buf.write("\32\3\32\3\33\3\33\3\34\3\34\3\35\3\35\3\36\3\36\3\36")
+ buf.write("\3\37\3\37\3\37\3 \3 \3 \3!\3!\3!\3\"\3\"\3\"\3#\3#\3")
+ buf.write("#\3$\3$\3$\3%\3%\3%\3%\3&\3&\3&\3&\3&\3&\3&\3&\3&\5&\u00e4")
+ buf.write("\n&\3\'\3\'\3\'\3\'\5\'\u00ea\n\'\3\'\3\'\3\'\5\'\u00ef")
+ buf.write("\n\'\3(\6(\u00f2\n(\r(\16(\u00f3\3)\3)\5)\u00f8\n)\3)")
+ buf.write("\3)\3*\3*\5*\u00fe\n*\3*\3*\3*\7*\u0103\n*\f*\16*\u0106")
+ buf.write("\13*\3+\3+\3,\3,\4\u00a0\u00ad\2-\3\3\5\4\7\5\t\6\13\7")
+ buf.write("\r\b\17\t\21\n\23\13\25\f\27\r\31\16\33\17\35\20\37\21")
+ buf.write("!\22#\23%\24\'\25)\26+\27-\30/\31\61\32\63\33\65\34\67")
+ buf.write("\359\36;\37= ?!A\"C#E$G%I&K\'M(O)Q\2S*U\2W\2\3\2\7\5\2")
+ buf.write("\13\f\17\17\"\"\4\2GGgg\4\2--//\4\2C\\c|\3\2\62;\2\u0113")
+ buf.write("\2\3\3\2\2\2\2\5\3\2\2\2\2\7\3\2\2\2\2\t\3\2\2\2\2\13")
+ buf.write("\3\2\2\2\2\r\3\2\2\2\2\17\3\2\2\2\2\21\3\2\2\2\2\23\3")
+ buf.write("\2\2\2\2\25\3\2\2\2\2\27\3\2\2\2\2\31\3\2\2\2\2\33\3\2")
+ buf.write("\2\2\2\35\3\2\2\2\2\37\3\2\2\2\2!\3\2\2\2\2#\3\2\2\2\2")
+ buf.write("%\3\2\2\2\2\'\3\2\2\2\2)\3\2\2\2\2+\3\2\2\2\2-\3\2\2\2")
+ buf.write("\2/\3\2\2\2\2\61\3\2\2\2\2\63\3\2\2\2\2\65\3\2\2\2\2\67")
+ buf.write("\3\2\2\2\29\3\2\2\2\2;\3\2\2\2\2=\3\2\2\2\2?\3\2\2\2\2")
+ buf.write("A\3\2\2\2\2C\3\2\2\2\2E\3\2\2\2\2G\3\2\2\2\2I\3\2\2\2")
+ buf.write("\2K\3\2\2\2\2M\3\2\2\2\2O\3\2\2\2\2S\3\2\2\2\3Y\3\2\2")
+ buf.write("\2\5[\3\2\2\2\7]\3\2\2\2\t_\3\2\2\2\13a\3\2\2\2\rc\3\2")
+ buf.write("\2\2\17f\3\2\2\2\21k\3\2\2\2\23o\3\2\2\2\25q\3\2\2\2\27")
+ buf.write("s\3\2\2\2\31u\3\2\2\2\33w\3\2\2\2\35z\3\2\2\2\37}\3\2")
+ buf.write("\2\2!\u0081\3\2\2\2#\u0083\3\2\2\2%\u008a\3\2\2\2\'\u008c")
+ buf.write("\3\2\2\2)\u0094\3\2\2\2+\u009a\3\2\2\2-\u00a7\3\2\2\2")
+ buf.write("/\u00b5\3\2\2\2\61\u00b7\3\2\2\2\63\u00b9\3\2\2\2\65\u00bb")
+ buf.write("\3\2\2\2\67\u00bd\3\2\2\29\u00bf\3\2\2\2;\u00c1\3\2\2")
+ buf.write("\2=\u00c4\3\2\2\2?\u00c7\3\2\2\2A\u00ca\3\2\2\2C\u00cd")
+ buf.write("\3\2\2\2E\u00d0\3\2\2\2G\u00d3\3\2\2\2I\u00d6\3\2\2\2")
+ buf.write("K\u00e3\3\2\2\2M\u00ee\3\2\2\2O\u00f1\3\2\2\2Q\u00f5\3")
+ buf.write("\2\2\2S\u00fd\3\2\2\2U\u0107\3\2\2\2W\u0109\3\2\2\2YZ")
+ buf.write("\7*\2\2Z\4\3\2\2\2[\\\7+\2\2\\\6\3\2\2\2]^\7.\2\2^\b\3")
+ buf.write("\2\2\2_`\7]\2\2`\n\3\2\2\2ab\7_\2\2b\f\3\2\2\2cd\7k\2")
+ buf.write("\2de\7h\2\2e\16\3\2\2\2fg\7g\2\2gh\7n\2\2hi\7u\2\2ij\7")
+ buf.write("g\2\2j\20\3\2\2\2kl\7n\2\2lm\7g\2\2mn\7v\2\2n\22\3\2\2")
+ buf.write("\2op\7?\2\2p\24\3\2\2\2qr\7=\2\2r\26\3\2\2\2st\7}\2\2")
+ buf.write("t\30\3\2\2\2uv\7\177\2\2v\32\3\2\2\2wx\7h\2\2xy\7p\2\2")
+ buf.write("y\34\3\2\2\2z{\7/\2\2{|\7@\2\2|\36\3\2\2\2}~\7f\2\2~\177")
+ buf.write("\7g\2\2\177\u0080\7h\2\2\u0080 \3\2\2\2\u0081\u0082\7")
+ buf.write("<\2\2\u0082\"\3\2\2\2\u0083\u0084\7V\2\2\u0084\u0085\7")
+ buf.write("g\2\2\u0085\u0086\7p\2\2\u0086\u0087\7u\2\2\u0087\u0088")
+ buf.write("\7q\2\2\u0088\u0089\7t\2\2\u0089$\3\2\2\2\u008a\u008b")
+ buf.write("\7a\2\2\u008b&\3\2\2\2\u008c\u008d\7x\2\2\u008d\u008e")
+ buf.write("\7\62\2\2\u008e\u008f\7\60\2\2\u008f\u0090\7\62\2\2\u0090")
+ buf.write("\u0091\7\60\2\2\u0091\u0092\7\64\2\2\u0092(\3\2\2\2\u0093")
+ buf.write("\u0095\t\2\2\2\u0094\u0093\3\2\2\2\u0095\u0096\3\2\2\2")
+ buf.write("\u0096\u0094\3\2\2\2\u0096\u0097\3\2\2\2\u0097\u0098\3")
+ buf.write("\2\2\2\u0098\u0099\b\25\2\2\u0099*\3\2\2\2\u009a\u009b")
+ buf.write("\7\61\2\2\u009b\u009c\7\61\2\2\u009c\u00a0\3\2\2\2\u009d")
+ buf.write("\u009f\13\2\2\2\u009e\u009d\3\2\2\2\u009f\u00a2\3\2\2")
+ buf.write("\2\u00a0\u00a1\3\2\2\2\u00a0\u009e\3\2\2\2\u00a1\u00a3")
+ buf.write("\3\2\2\2\u00a2\u00a0\3\2\2\2\u00a3\u00a4\7\f\2\2\u00a4")
+ buf.write("\u00a5\3\2\2\2\u00a5\u00a6\b\26\2\2\u00a6,\3\2\2\2\u00a7")
+ buf.write("\u00a8\7\61\2\2\u00a8\u00a9\7,\2\2\u00a9\u00ad\3\2\2\2")
+ buf.write("\u00aa\u00ac\13\2\2\2\u00ab\u00aa\3\2\2\2\u00ac\u00af")
+ buf.write("\3\2\2\2\u00ad\u00ae\3\2\2\2\u00ad\u00ab\3\2\2\2\u00ae")
+ buf.write("\u00b0\3\2\2\2\u00af\u00ad\3\2\2\2\u00b0\u00b1\7,\2\2")
+ buf.write("\u00b1\u00b2\7\61\2\2\u00b2\u00b3\3\2\2\2\u00b3\u00b4")
+ buf.write("\b\27\2\2\u00b4.\3\2\2\2\u00b5\u00b6\7,\2\2\u00b6\60\3")
+ buf.write("\2\2\2\u00b7\u00b8\7\61\2\2\u00b8\62\3\2\2\2\u00b9\u00ba")
+ buf.write("\7-\2\2\u00ba\64\3\2\2\2\u00bb\u00bc\7/\2\2\u00bc\66\3")
+ buf.write("\2\2\2\u00bd\u00be\7>\2\2\u00be8\3\2\2\2\u00bf\u00c0\7")
+ buf.write("@\2\2\u00c0:\3\2\2\2\u00c1\u00c2\7>\2\2\u00c2\u00c3\7")
+ buf.write("?\2\2\u00c3<\3\2\2\2\u00c4\u00c5\7@\2\2\u00c5\u00c6\7")
+ buf.write("?\2\2\u00c6>\3\2\2\2\u00c7\u00c8\7?\2\2\u00c8\u00c9\7")
+ buf.write("?\2\2\u00c9@\3\2\2\2\u00ca\u00cb\7#\2\2\u00cb\u00cc\7")
+ buf.write("?\2\2\u00ccB\3\2\2\2\u00cd\u00ce\7B\2\2\u00ce\u00cf\5")
+ buf.write("S*\2\u00cfD\3\2\2\2\u00d0\u00d1\7\'\2\2\u00d1\u00d2\5")
+ buf.write("S*\2\u00d2F\3\2\2\2\u00d3\u00d4\7\'\2\2\u00d4\u00d5\5")
+ buf.write("O(\2\u00d5H\3\2\2\2\u00d6\u00d7\7o\2\2\u00d7\u00d8\7w")
+ buf.write("\2\2\u00d8\u00d9\7v\2\2\u00d9J\3\2\2\2\u00da\u00db\7V")
+ buf.write("\2\2\u00db\u00dc\7t\2\2\u00dc\u00dd\7w\2\2\u00dd\u00e4")
+ buf.write("\7g\2\2\u00de\u00df\7H\2\2\u00df\u00e0\7c\2\2\u00e0\u00e1")
+ buf.write("\7n\2\2\u00e1\u00e2\7u\2\2\u00e2\u00e4\7g\2\2\u00e3\u00da")
+ buf.write("\3\2\2\2\u00e3\u00de\3\2\2\2\u00e4L\3\2\2\2\u00e5\u00e6")
+ buf.write("\5O(\2\u00e6\u00e7\7\60\2\2\u00e7\u00e9\5O(\2\u00e8\u00ea")
+ buf.write("\5Q)\2\u00e9\u00e8\3\2\2\2\u00e9\u00ea\3\2\2\2\u00ea\u00ef")
+ buf.write("\3\2\2\2\u00eb\u00ec\5O(\2\u00ec\u00ed\5Q)\2\u00ed\u00ef")
+ buf.write("\3\2\2\2\u00ee\u00e5\3\2\2\2\u00ee\u00eb\3\2\2\2\u00ef")
+ buf.write("N\3\2\2\2\u00f0\u00f2\5W,\2\u00f1\u00f0\3\2\2\2\u00f2")
+ buf.write("\u00f3\3\2\2\2\u00f3\u00f1\3\2\2\2\u00f3\u00f4\3\2\2\2")
+ buf.write("\u00f4P\3\2\2\2\u00f5\u00f7\t\3\2\2\u00f6\u00f8\t\4\2")
+ buf.write("\2\u00f7\u00f6\3\2\2\2\u00f7\u00f8\3\2\2\2\u00f8\u00f9")
+ buf.write("\3\2\2\2\u00f9\u00fa\5O(\2\u00faR\3\2\2\2\u00fb\u00fe")
+ buf.write("\7a\2\2\u00fc\u00fe\5U+\2\u00fd\u00fb\3\2\2\2\u00fd\u00fc")
+ buf.write("\3\2\2\2\u00fe\u0104\3\2\2\2\u00ff\u0103\7a\2\2\u0100")
+ buf.write("\u0103\5U+\2\u0101\u0103\5W,\2\u0102\u00ff\3\2\2\2\u0102")
+ buf.write("\u0100\3\2\2\2\u0102\u0101\3\2\2\2\u0103\u0106\3\2\2\2")
+ buf.write("\u0104\u0102\3\2\2\2\u0104\u0105\3\2\2\2\u0105T\3\2\2")
+ buf.write("\2\u0106\u0104\3\2\2\2\u0107\u0108\t\5\2\2\u0108V\3\2")
+ buf.write("\2\2\u0109\u010a\t\6\2\2\u010aX\3\2\2\2\16\2\u0096\u00a0")
+ buf.write("\u00ad\u00e3\u00e9\u00ee\u00f3\u00f7\u00fd\u0102\u0104")
+ buf.write("\3\b\2\2")
+ return buf.getvalue()
+
+
+class RelayLexer(Lexer):
+
+ atn = ATNDeserializer().deserialize(serializedATN())
+
+ decisionsToDFA = [ DFA(ds, i) for i, ds in enumerate(atn.decisionToState) ]
+
+ T__0 = 1
+ T__1 = 2
+ T__2 = 3
+ T__3 = 4
+ T__4 = 5
+ T__5 = 6
+ T__6 = 7
+ T__7 = 8
+ T__8 = 9
+ T__9 = 10
+ T__10 = 11
+ T__11 = 12
+ T__12 = 13
+ T__13 = 14
+ T__14 = 15
+ T__15 = 16
+ T__16 = 17
+ T__17 = 18
+ SEMVER = 19
+ WS = 20
+ LINE_COMMENT = 21
+ COMMENT = 22
+ MUL = 23
+ DIV = 24
+ ADD = 25
+ SUB = 26
+ LT = 27
+ GT = 28
+ LE = 29
+ GE = 30
+ EQ = 31
+ NE = 32
+ GLOBAL_VAR = 33
+ LOCAL_VAR = 34
+ GRAPH_VAR = 35
+ MUT = 36
+ BOOL_LIT = 37
+ FLOAT = 38
+ NAT = 39
+ CNAME = 40
+
+ channelNames = [ u"DEFAULT_TOKEN_CHANNEL", u"HIDDEN" ]
+
+ modeNames = [ "DEFAULT_MODE" ]
+
+ literalNames = [ "<INVALID>",
+ "'('", "')'", "','", "'['", "']'", "'if'", "'else'", "'let'",
+ "'='", "';'", "'{'", "'}'", "'fn'", "'->'", "'def'", "':'",
+ "'Tensor'", "'_'", "'v0.0.2'", "'*'", "'/'", "'+'", "'-'", "'<'",
+ "'>'", "'<='", "'>='", "'=='", "'!='", "'mut'" ]
+
+ symbolicNames = [ "<INVALID>",
+ "SEMVER", "WS", "LINE_COMMENT", "COMMENT", "MUL", "DIV", "ADD",
+ "SUB", "LT", "GT", "LE", "GE", "EQ", "NE", "GLOBAL_VAR", "LOCAL_VAR",
+ "GRAPH_VAR", "MUT", "BOOL_LIT", "FLOAT", "NAT", "CNAME" ]
+
+ ruleNames = [ "T__0", "T__1", "T__2", "T__3", "T__4", "T__5", "T__6",
+ "T__7", "T__8", "T__9", "T__10", "T__11", "T__12", "T__13",
+ "T__14", "T__15", "T__16", "T__17", "SEMVER", "WS", "LINE_COMMENT",
+ "COMMENT", "MUL", "DIV", "ADD", "SUB", "LT", "GT", "LE",
+ "GE", "EQ", "NE", "GLOBAL_VAR", "LOCAL_VAR", "GRAPH_VAR",
+ "MUT", "BOOL_LIT", "FLOAT", "NAT", "EXP", "CNAME", "LETTER",
+ "DIGIT" ]
+
+ grammarFileName = "Relay.g4"
+
+ def __init__(self, input=None, output:TextIO = sys.stdout):
+ super().__init__(input, output)
+ self.checkVersion("4.7.2")
+ self._interp = LexerATNSimulator(self, self.atn, self.decisionsToDFA, PredictionContextCache())
+ self._actions = None
+ self._predicates = None
+
+
--- /dev/null
+T__0=1
+T__1=2
+T__2=3
+T__3=4
+T__4=5
+T__5=6
+T__6=7
+T__7=8
+T__8=9
+T__9=10
+T__10=11
+T__11=12
+T__12=13
+T__13=14
+T__14=15
+T__15=16
+T__16=17
+T__17=18
+SEMVER=19
+WS=20
+LINE_COMMENT=21
+COMMENT=22
+MUL=23
+DIV=24
+ADD=25
+SUB=26
+LT=27
+GT=28
+LE=29
+GE=30
+EQ=31
+NE=32
+GLOBAL_VAR=33
+LOCAL_VAR=34
+GRAPH_VAR=35
+MUT=36
+BOOL_LIT=37
+FLOAT=38
+NAT=39
+CNAME=40
+'('=1
+')'=2
+','=3
+'['=4
+']'=5
+'if'=6
+'else'=7
+'let'=8
+'='=9
+';'=10
+'{'=11
+'}'=12
+'fn'=13
+'->'=14
+'def'=15
+':'=16
+'Tensor'=17
+'_'=18
+'v0.0.2'=19
+'*'=23
+'/'=24
+'+'=25
+'-'=26
+'<'=27
+'>'=28
+'<='=29
+'>='=30
+'=='=31
+'!='=32
+'mut'=36
--- /dev/null
+# Generated from /home/sslyu/tvm/python/tvm/relay/grammar/Relay.g4 by ANTLR 4.7.2
+# encoding: utf-8
+from antlr4 import *
+from io import StringIO
+from typing.io import TextIO
+import sys
+
+
+def serializedATN():
+ with StringIO() as buf:
+ buf.write("\3\u608b\ua72a\u8133\ub9ed\u417c\u3be7\u7786\u5964\3*")
+ buf.write("\u014c\4\2\t\2\4\3\t\3\4\4\t\4\4\5\t\5\4\6\t\6\4\7\t\7")
+ buf.write("\4\b\t\b\4\t\t\t\4\n\t\n\4\13\t\13\4\f\t\f\4\r\t\r\4\16")
+ buf.write("\t\16\4\17\t\17\4\20\t\20\4\21\t\21\4\22\t\22\4\23\t\23")
+ buf.write("\3\2\3\2\3\3\3\3\7\3+\n\3\f\3\16\3.\13\3\3\3\5\3\61\n")
+ buf.write("\3\3\3\3\3\3\4\3\4\3\4\3\4\3\4\3\4\3\4\3\4\3\4\3\4\3\4")
+ buf.write("\3\4\3\4\3\4\3\4\3\4\3\4\3\4\3\4\6\4H\n\4\r\4\16\4I\3")
+ buf.write("\4\3\4\3\4\3\4\3\4\3\4\7\4R\n\4\f\4\16\4U\13\4\5\4W\n")
+ buf.write("\4\3\4\3\4\3\4\3\4\3\4\3\4\3\4\3\4\3\4\3\4\3\4\5\4d\n")
+ buf.write("\4\3\4\3\4\3\4\3\4\3\4\3\4\3\4\3\4\5\4n\n\4\3\4\3\4\3")
+ buf.write("\4\3\4\3\4\3\4\3\4\3\4\3\4\3\4\3\4\3\4\3\4\3\4\3\4\3\4")
+ buf.write("\5\4\u0080\n\4\3\4\3\4\3\4\3\4\3\4\3\4\3\4\3\4\3\4\3\4")
+ buf.write("\3\4\3\4\3\4\3\4\3\4\3\4\3\4\3\4\3\4\3\4\7\4\u0096\n\4")
+ buf.write("\f\4\16\4\u0099\13\4\5\4\u009b\n\4\3\4\7\4\u009e\n\4\f")
+ buf.write("\4\16\4\u00a1\13\4\3\5\3\5\5\5\u00a5\n\5\3\5\3\5\3\5\3")
+ buf.write("\5\3\5\5\5\u00ac\n\5\3\5\3\5\3\6\3\6\3\6\5\6\u00b3\n\6")
+ buf.write("\3\6\3\6\3\6\3\6\3\6\5\6\u00ba\n\6\3\6\3\6\3\7\3\7\3\7")
+ buf.write("\3\7\3\7\3\7\5\7\u00c4\n\7\3\b\3\b\3\b\7\b\u00c9\n\b\f")
+ buf.write("\b\16\b\u00cc\13\b\5\b\u00ce\n\b\3\t\3\t\3\t\5\t\u00d3")
+ buf.write("\n\t\3\n\3\n\3\n\7\n\u00d8\n\n\f\n\16\n\u00db\13\n\5\n")
+ buf.write("\u00dd\n\n\3\13\3\13\3\13\3\13\3\f\3\f\3\f\3\f\3\f\3\f")
+ buf.write("\7\f\u00e9\n\f\f\f\16\f\u00ec\13\f\3\f\3\f\5\f\u00f0\n")
+ buf.write("\f\3\r\3\r\3\r\3\r\3\r\3\r\3\r\3\r\3\r\3\r\3\r\6\r\u00fd")
+ buf.write("\n\r\r\r\16\r\u00fe\3\r\3\r\3\r\3\r\3\r\3\r\3\r\3\r\3")
+ buf.write("\r\3\r\3\r\3\r\5\r\u010d\n\r\3\r\3\r\3\r\3\r\7\r\u0113")
+ buf.write("\n\r\f\r\16\r\u0116\13\r\5\r\u0118\n\r\3\r\3\r\3\r\3\r")
+ buf.write("\3\r\5\r\u011f\n\r\3\16\3\16\3\16\3\16\3\16\3\16\3\16")
+ buf.write("\3\16\3\16\3\16\3\16\6\16\u012c\n\16\r\16\16\16\u012d")
+ buf.write("\3\16\3\16\5\16\u0132\n\16\3\17\3\17\3\17\3\17\3\17\5")
+ buf.write("\17\u0139\n\17\3\20\3\20\3\21\3\21\3\21\3\21\3\22\3\22")
+ buf.write("\3\22\5\22\u0144\n\22\3\23\3\23\3\23\3\23\5\23\u014a\n")
+ buf.write("\23\3\23\2\3\6\24\2\4\6\b\n\f\16\20\22\24\26\30\32\34")
+ buf.write("\36 \"$\2\6\3\2\31\32\3\2\33\34\3\2\35 \3\2!\"\2\u0175")
+ buf.write("\2&\3\2\2\2\4(\3\2\2\2\6\177\3\2\2\2\b\u00a2\3\2\2\2\n")
+ buf.write("\u00af\3\2\2\2\f\u00c3\3\2\2\2\16\u00cd\3\2\2\2\20\u00cf")
+ buf.write("\3\2\2\2\22\u00dc\3\2\2\2\24\u00de\3\2\2\2\26\u00ef\3")
+ buf.write("\2\2\2\30\u011e\3\2\2\2\32\u0131\3\2\2\2\34\u0138\3\2")
+ buf.write("\2\2\36\u013a\3\2\2\2 \u013c\3\2\2\2\"\u0143\3\2\2\2$")
+ buf.write("\u0149\3\2\2\2&\'\7*\2\2\'\3\3\2\2\2(\60\7\25\2\2)+\5")
+ buf.write("\n\6\2*)\3\2\2\2+.\3\2\2\2,*\3\2\2\2,-\3\2\2\2-\61\3\2")
+ buf.write("\2\2.,\3\2\2\2/\61\5\6\4\2\60,\3\2\2\2\60/\3\2\2\2\61")
+ buf.write("\62\3\2\2\2\62\63\7\2\2\3\63\5\3\2\2\2\64\65\b\4\1\2\65")
+ buf.write("\66\7\3\2\2\66\67\5\6\4\2\678\7\4\2\28\u0080\3\2\2\29")
+ buf.write(":\7\34\2\2:\u0080\5\6\4\23;\u0080\5\b\5\2<=\7\3\2\2=\u0080")
+ buf.write("\7\4\2\2>?\7\3\2\2?@\5\6\4\2@A\7\5\2\2AB\7\4\2\2B\u0080")
+ buf.write("\3\2\2\2CD\7\3\2\2DG\5\6\4\2EF\7\5\2\2FH\5\6\4\2GE\3\2")
+ buf.write("\2\2HI\3\2\2\2IG\3\2\2\2IJ\3\2\2\2JK\3\2\2\2KL\7\4\2\2")
+ buf.write("L\u0080\3\2\2\2MV\7\6\2\2NS\5\6\4\2OP\7\5\2\2PR\5\6\4")
+ buf.write("\2QO\3\2\2\2RU\3\2\2\2SQ\3\2\2\2ST\3\2\2\2TW\3\2\2\2U")
+ buf.write("S\3\2\2\2VN\3\2\2\2VW\3\2\2\2WX\3\2\2\2X\u0080\7\7\2\2")
+ buf.write("YZ\7\b\2\2Z[\7\3\2\2[\\\5\6\4\2\\]\7\4\2\2]^\5 \21\2^")
+ buf.write("_\7\t\2\2_`\5 \21\2`\u0080\3\2\2\2ac\7\n\2\2bd\7&\2\2")
+ buf.write("cb\3\2\2\2cd\3\2\2\2de\3\2\2\2ef\5\20\t\2fg\7\13\2\2g")
+ buf.write("h\5\6\4\2hi\7\f\2\2ij\5\6\4\bj\u0080\3\2\2\2km\7\n\2\2")
+ buf.write("ln\7&\2\2ml\3\2\2\2mn\3\2\2\2no\3\2\2\2op\5\20\t\2pq\7")
+ buf.write("\13\2\2qr\7\r\2\2rs\5\6\4\2st\7\16\2\2tu\7\f\2\2uv\5\6")
+ buf.write("\4\7v\u0080\3\2\2\2wx\5$\23\2xy\7\13\2\2yz\5\6\4\2z{\7")
+ buf.write("\f\2\2{|\5\6\4\5|\u0080\3\2\2\2}\u0080\5$\23\2~\u0080")
+ buf.write("\5\"\22\2\177\64\3\2\2\2\1779\3\2\2\2\177;\3\2\2\2\177")
+ buf.write("<\3\2\2\2\177>\3\2\2\2\177C\3\2\2\2\177M\3\2\2\2\177Y")
+ buf.write("\3\2\2\2\177a\3\2\2\2\177k\3\2\2\2\177w\3\2\2\2\177}\3")
+ buf.write("\2\2\2\177~\3\2\2\2\u0080\u009f\3\2\2\2\u0081\u0082\f")
+ buf.write("\22\2\2\u0082\u0083\t\2\2\2\u0083\u009e\5\6\4\23\u0084")
+ buf.write("\u0085\f\21\2\2\u0085\u0086\t\3\2\2\u0086\u009e\5\6\4")
+ buf.write("\22\u0087\u0088\f\20\2\2\u0088\u0089\t\4\2\2\u0089\u009e")
+ buf.write("\5\6\4\21\u008a\u008b\f\17\2\2\u008b\u008c\t\5\2\2\u008c")
+ buf.write("\u009e\5\6\4\20\u008d\u008e\f\6\2\2\u008e\u008f\7\f\2")
+ buf.write("\2\u008f\u009e\5\6\4\7\u0090\u0091\f\24\2\2\u0091\u009a")
+ buf.write("\7\3\2\2\u0092\u0097\5\6\4\2\u0093\u0094\7\5\2\2\u0094")
+ buf.write("\u0096\5\6\4\2\u0095\u0093\3\2\2\2\u0096\u0099\3\2\2\2")
+ buf.write("\u0097\u0095\3\2\2\2\u0097\u0098\3\2\2\2\u0098\u009b\3")
+ buf.write("\2\2\2\u0099\u0097\3\2\2\2\u009a\u0092\3\2\2\2\u009a\u009b")
+ buf.write("\3\2\2\2\u009b\u009c\3\2\2\2\u009c\u009e\7\4\2\2\u009d")
+ buf.write("\u0081\3\2\2\2\u009d\u0084\3\2\2\2\u009d\u0087\3\2\2\2")
+ buf.write("\u009d\u008a\3\2\2\2\u009d\u008d\3\2\2\2\u009d\u0090\3")
+ buf.write("\2\2\2\u009e\u00a1\3\2\2\2\u009f\u009d\3\2\2\2\u009f\u00a0")
+ buf.write("\3\2\2\2\u00a0\7\3\2\2\2\u00a1\u009f\3\2\2\2\u00a2\u00a4")
+ buf.write("\7\17\2\2\u00a3\u00a5\5\26\f\2\u00a4\u00a3\3\2\2\2\u00a4")
+ buf.write("\u00a5\3\2\2\2\u00a5\u00a6\3\2\2\2\u00a6\u00a7\7\3\2\2")
+ buf.write("\u00a7\u00a8\5\f\7\2\u00a8\u00ab\7\4\2\2\u00a9\u00aa\7")
+ buf.write("\20\2\2\u00aa\u00ac\5\30\r\2\u00ab\u00a9\3\2\2\2\u00ab")
+ buf.write("\u00ac\3\2\2\2\u00ac\u00ad\3\2\2\2\u00ad\u00ae\5 \21\2")
+ buf.write("\u00ae\t\3\2\2\2\u00af\u00b0\7\21\2\2\u00b0\u00b2\5$\23")
+ buf.write("\2\u00b1\u00b3\5\26\f\2\u00b2\u00b1\3\2\2\2\u00b2\u00b3")
+ buf.write("\3\2\2\2\u00b3\u00b4\3\2\2\2\u00b4\u00b5\7\3\2\2\u00b5")
+ buf.write("\u00b6\5\f\7\2\u00b6\u00b9\7\4\2\2\u00b7\u00b8\7\20\2")
+ buf.write("\2\u00b8\u00ba\5\30\r\2\u00b9\u00b7\3\2\2\2\u00b9\u00ba")
+ buf.write("\3\2\2\2\u00ba\u00bb\3\2\2\2\u00bb\u00bc\5 \21\2\u00bc")
+ buf.write("\13\3\2\2\2\u00bd\u00c4\5\16\b\2\u00be\u00c4\5\22\n\2")
+ buf.write("\u00bf\u00c0\5\16\b\2\u00c0\u00c1\7\5\2\2\u00c1\u00c2")
+ buf.write("\5\22\n\2\u00c2\u00c4\3\2\2\2\u00c3\u00bd\3\2\2\2\u00c3")
+ buf.write("\u00be\3\2\2\2\u00c3\u00bf\3\2\2\2\u00c4\r\3\2\2\2\u00c5")
+ buf.write("\u00ca\5\20\t\2\u00c6\u00c7\7\5\2\2\u00c7\u00c9\5\20\t")
+ buf.write("\2\u00c8\u00c6\3\2\2\2\u00c9\u00cc\3\2\2\2\u00ca\u00c8")
+ buf.write("\3\2\2\2\u00ca\u00cb\3\2\2\2\u00cb\u00ce\3\2\2\2\u00cc")
+ buf.write("\u00ca\3\2\2\2\u00cd\u00c5\3\2\2\2\u00cd\u00ce\3\2\2\2")
+ buf.write("\u00ce\17\3\2\2\2\u00cf\u00d2\5$\23\2\u00d0\u00d1\7\22")
+ buf.write("\2\2\u00d1\u00d3\5\30\r\2\u00d2\u00d0\3\2\2\2\u00d2\u00d3")
+ buf.write("\3\2\2\2\u00d3\21\3\2\2\2\u00d4\u00d9\5\24\13\2\u00d5")
+ buf.write("\u00d6\7\5\2\2\u00d6\u00d8\5\24\13\2\u00d7\u00d5\3\2\2")
+ buf.write("\2\u00d8\u00db\3\2\2\2\u00d9\u00d7\3\2\2\2\u00d9\u00da")
+ buf.write("\3\2\2\2\u00da\u00dd\3\2\2\2\u00db\u00d9\3\2\2\2\u00dc")
+ buf.write("\u00d4\3\2\2\2\u00dc\u00dd\3\2\2\2\u00dd\23\3\2\2\2\u00de")
+ buf.write("\u00df\7*\2\2\u00df\u00e0\7\13\2\2\u00e0\u00e1\5\6\4\2")
+ buf.write("\u00e1\25\3\2\2\2\u00e2\u00e3\7\6\2\2\u00e3\u00f0\7\7")
+ buf.write("\2\2\u00e4\u00e5\7\6\2\2\u00e5\u00ea\5$\23\2\u00e6\u00e7")
+ buf.write("\7\5\2\2\u00e7\u00e9\5$\23\2\u00e8\u00e6\3\2\2\2\u00e9")
+ buf.write("\u00ec\3\2\2\2\u00ea\u00e8\3\2\2\2\u00ea\u00eb\3\2\2\2")
+ buf.write("\u00eb\u00ed\3\2\2\2\u00ec\u00ea\3\2\2\2\u00ed\u00ee\7")
+ buf.write("\7\2\2\u00ee\u00f0\3\2\2\2\u00ef\u00e2\3\2\2\2\u00ef\u00e4")
+ buf.write("\3\2\2\2\u00f0\27\3\2\2\2\u00f1\u00f2\7\3\2\2\u00f2\u011f")
+ buf.write("\7\4\2\2\u00f3\u00f4\7\3\2\2\u00f4\u00f5\5\30\r\2\u00f5")
+ buf.write("\u00f6\7\5\2\2\u00f6\u00f7\7\4\2\2\u00f7\u011f\3\2\2\2")
+ buf.write("\u00f8\u00f9\7\3\2\2\u00f9\u00fc\5\30\r\2\u00fa\u00fb")
+ buf.write("\7\5\2\2\u00fb\u00fd\5\30\r\2\u00fc\u00fa\3\2\2\2\u00fd")
+ buf.write("\u00fe\3\2\2\2\u00fe\u00fc\3\2\2\2\u00fe\u00ff\3\2\2\2")
+ buf.write("\u00ff\u0100\3\2\2\2\u0100\u0101\7\4\2\2\u0101\u011f\3")
+ buf.write("\2\2\2\u0102\u011f\5\36\20\2\u0103\u0104\7\23\2\2\u0104")
+ buf.write("\u0105\7\6\2\2\u0105\u0106\5\32\16\2\u0106\u0107\7\5\2")
+ buf.write("\2\u0107\u0108\5\30\r\2\u0108\u0109\7\7\2\2\u0109\u011f")
+ buf.write("\3\2\2\2\u010a\u010c\7\17\2\2\u010b\u010d\5\26\f\2\u010c")
+ buf.write("\u010b\3\2\2\2\u010c\u010d\3\2\2\2\u010d\u010e\3\2\2\2")
+ buf.write("\u010e\u0117\7\3\2\2\u010f\u0114\5\30\r\2\u0110\u0111")
+ buf.write("\7\5\2\2\u0111\u0113\5\30\r\2\u0112\u0110\3\2\2\2\u0113")
+ buf.write("\u0116\3\2\2\2\u0114\u0112\3\2\2\2\u0114\u0115\3\2\2\2")
+ buf.write("\u0115\u0118\3\2\2\2\u0116\u0114\3\2\2\2\u0117\u010f\3")
+ buf.write("\2\2\2\u0117\u0118\3\2\2\2\u0118\u0119\3\2\2\2\u0119\u011a")
+ buf.write("\7\4\2\2\u011a\u011b\7\20\2\2\u011b\u011f\5\30\r\2\u011c")
+ buf.write("\u011f\7\24\2\2\u011d\u011f\7)\2\2\u011e\u00f1\3\2\2\2")
+ buf.write("\u011e\u00f3\3\2\2\2\u011e\u00f8\3\2\2\2\u011e\u0102\3")
+ buf.write("\2\2\2\u011e\u0103\3\2\2\2\u011e\u010a\3\2\2\2\u011e\u011c")
+ buf.write("\3\2\2\2\u011e\u011d\3\2\2\2\u011f\31\3\2\2\2\u0120\u0121")
+ buf.write("\7\3\2\2\u0121\u0132\7\4\2\2\u0122\u0123\7\3\2\2\u0123")
+ buf.write("\u0124\5\34\17\2\u0124\u0125\7\5\2\2\u0125\u0126\7\4\2")
+ buf.write("\2\u0126\u0132\3\2\2\2\u0127\u0128\7\3\2\2\u0128\u012b")
+ buf.write("\5\34\17\2\u0129\u012a\7\5\2\2\u012a\u012c\5\34\17\2\u012b")
+ buf.write("\u0129\3\2\2\2\u012c\u012d\3\2\2\2\u012d\u012b\3\2\2\2")
+ buf.write("\u012d\u012e\3\2\2\2\u012e\u012f\3\2\2\2\u012f\u0130\7")
+ buf.write("\4\2\2\u0130\u0132\3\2\2\2\u0131\u0120\3\2\2\2\u0131\u0122")
+ buf.write("\3\2\2\2\u0131\u0127\3\2\2\2\u0132\33\3\2\2\2\u0133\u0134")
+ buf.write("\7\3\2\2\u0134\u0135\5\34\17\2\u0135\u0136\7\4\2\2\u0136")
+ buf.write("\u0139\3\2\2\2\u0137\u0139\7)\2\2\u0138\u0133\3\2\2\2")
+ buf.write("\u0138\u0137\3\2\2\2\u0139\35\3\2\2\2\u013a\u013b\7*\2")
+ buf.write("\2\u013b\37\3\2\2\2\u013c\u013d\7\r\2\2\u013d\u013e\5")
+ buf.write("\6\4\2\u013e\u013f\7\16\2\2\u013f!\3\2\2\2\u0140\u0144")
+ buf.write("\7(\2\2\u0141\u0144\7)\2\2\u0142\u0144\7\'\2\2\u0143\u0140")
+ buf.write("\3\2\2\2\u0143\u0141\3\2\2\2\u0143\u0142\3\2\2\2\u0144")
+ buf.write("#\3\2\2\2\u0145\u014a\5\2\2\2\u0146\u014a\7#\2\2\u0147")
+ buf.write("\u014a\7$\2\2\u0148\u014a\7%\2\2\u0149\u0145\3\2\2\2\u0149")
+ buf.write("\u0146\3\2\2\2\u0149\u0147\3\2\2\2\u0149\u0148\3\2\2\2")
+ buf.write("\u014a%\3\2\2\2$,\60ISVcm\177\u0097\u009a\u009d\u009f")
+ buf.write("\u00a4\u00ab\u00b2\u00b9\u00c3\u00ca\u00cd\u00d2\u00d9")
+ buf.write("\u00dc\u00ea\u00ef\u00fe\u010c\u0114\u0117\u011e\u012d")
+ buf.write("\u0131\u0138\u0143\u0149")
+ return buf.getvalue()
+
+
+class RelayParser ( Parser ):
+
+ grammarFileName = "Relay.g4"
+
+ atn = ATNDeserializer().deserialize(serializedATN())
+
+ decisionsToDFA = [ DFA(ds, i) for i, ds in enumerate(atn.decisionToState) ]
+
+ sharedContextCache = PredictionContextCache()
+
+ literalNames = [ "<INVALID>", "'('", "')'", "','", "'['", "']'", "'if'",
+ "'else'", "'let'", "'='", "';'", "'{'", "'}'", "'fn'",
+ "'->'", "'def'", "':'", "'Tensor'", "'_'", "'v0.0.2'",
+ "<INVALID>", "<INVALID>", "<INVALID>", "'*'", "'/'",
+ "'+'", "'-'", "'<'", "'>'", "'<='", "'>='", "'=='",
+ "'!='", "<INVALID>", "<INVALID>", "<INVALID>", "'mut'" ]
+
+ symbolicNames = [ "<INVALID>", "<INVALID>", "<INVALID>", "<INVALID>",
+ "<INVALID>", "<INVALID>", "<INVALID>", "<INVALID>",
+ "<INVALID>", "<INVALID>", "<INVALID>", "<INVALID>",
+ "<INVALID>", "<INVALID>", "<INVALID>", "<INVALID>",
+ "<INVALID>", "<INVALID>", "<INVALID>", "SEMVER", "WS",
+ "LINE_COMMENT", "COMMENT", "MUL", "DIV", "ADD", "SUB",
+ "LT", "GT", "LE", "GE", "EQ", "NE", "GLOBAL_VAR",
+ "LOCAL_VAR", "GRAPH_VAR", "MUT", "BOOL_LIT", "FLOAT",
+ "NAT", "CNAME" ]
+
+ RULE_opIdent = 0
+ RULE_prog = 1
+ RULE_expr = 2
+ RULE_func = 3
+ RULE_defn = 4
+ RULE_argList = 5
+ RULE_varList = 6
+ RULE_var = 7
+ RULE_attrList = 8
+ RULE_attr = 9
+ RULE_typeParamSeq = 10
+ RULE_type_ = 11
+ RULE_shapeSeq = 12
+ RULE_shape = 13
+ RULE_typeIdent = 14
+ RULE_body = 15
+ RULE_scalar = 16
+ RULE_ident = 17
+
+ ruleNames = [ "opIdent", "prog", "expr", "func", "defn", "argList",
+ "varList", "var", "attrList", "attr", "typeParamSeq",
+ "type_", "shapeSeq", "shape", "typeIdent", "body", "scalar",
+ "ident" ]
+
+ EOF = Token.EOF
+ T__0=1
+ T__1=2
+ T__2=3
+ T__3=4
+ T__4=5
+ T__5=6
+ T__6=7
+ T__7=8
+ T__8=9
+ T__9=10
+ T__10=11
+ T__11=12
+ T__12=13
+ T__13=14
+ T__14=15
+ T__15=16
+ T__16=17
+ T__17=18
+ SEMVER=19
+ WS=20
+ LINE_COMMENT=21
+ COMMENT=22
+ MUL=23
+ DIV=24
+ ADD=25
+ SUB=26
+ LT=27
+ GT=28
+ LE=29
+ GE=30
+ EQ=31
+ NE=32
+ GLOBAL_VAR=33
+ LOCAL_VAR=34
+ GRAPH_VAR=35
+ MUT=36
+ BOOL_LIT=37
+ FLOAT=38
+ NAT=39
+ CNAME=40
+
+ def __init__(self, input:TokenStream, output:TextIO = sys.stdout):
+ super().__init__(input, output)
+ self.checkVersion("4.7.2")
+ self._interp = ParserATNSimulator(self, self.atn, self.decisionsToDFA, self.sharedContextCache)
+ self._predicates = None
+
+
+
+
+ class OpIdentContext(ParserRuleContext):
+
+ def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1):
+ super().__init__(parent, invokingState)
+ self.parser = parser
+
+ def CNAME(self):
+ return self.getToken(RelayParser.CNAME, 0)
+
+ def getRuleIndex(self):
+ return RelayParser.RULE_opIdent
+
+ def accept(self, visitor:ParseTreeVisitor):
+ if hasattr( visitor, "visitOpIdent" ):
+ return visitor.visitOpIdent(self)
+ else:
+ return visitor.visitChildren(self)
+
+
+
+
+ def opIdent(self):
+
+ localctx = RelayParser.OpIdentContext(self, self._ctx, self.state)
+ self.enterRule(localctx, 0, self.RULE_opIdent)
+ try:
+ self.enterOuterAlt(localctx, 1)
+ self.state = 36
+ self.match(RelayParser.CNAME)
+ except RecognitionException as re:
+ localctx.exception = re
+ self._errHandler.reportError(self, re)
+ self._errHandler.recover(self, re)
+ finally:
+ self.exitRule()
+ return localctx
+
+
+ class ProgContext(ParserRuleContext):
+
+ def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1):
+ super().__init__(parent, invokingState)
+ self.parser = parser
+
+ def SEMVER(self):
+ return self.getToken(RelayParser.SEMVER, 0)
+
+ def EOF(self):
+ return self.getToken(RelayParser.EOF, 0)
+
+ def expr(self):
+ return self.getTypedRuleContext(RelayParser.ExprContext,0)
+
+
+ def defn(self, i:int=None):
+ if i is None:
+ return self.getTypedRuleContexts(RelayParser.DefnContext)
+ else:
+ return self.getTypedRuleContext(RelayParser.DefnContext,i)
+
+
+ def getRuleIndex(self):
+ return RelayParser.RULE_prog
+
+ def accept(self, visitor:ParseTreeVisitor):
+ if hasattr( visitor, "visitProg" ):
+ return visitor.visitProg(self)
+ else:
+ return visitor.visitChildren(self)
+
+
+
+
+ def prog(self):
+
+ localctx = RelayParser.ProgContext(self, self._ctx, self.state)
+ self.enterRule(localctx, 2, self.RULE_prog)
+ self._la = 0 # Token type
+ try:
+ self.enterOuterAlt(localctx, 1)
+ self.state = 38
+ self.match(RelayParser.SEMVER)
+ self.state = 46
+ self._errHandler.sync(self)
+ token = self._input.LA(1)
+ if token in [RelayParser.EOF, RelayParser.T__14]:
+ self.state = 42
+ self._errHandler.sync(self)
+ _la = self._input.LA(1)
+ while _la==RelayParser.T__14:
+ self.state = 39
+ self.defn()
+ self.state = 44
+ self._errHandler.sync(self)
+ _la = self._input.LA(1)
+
+ pass
+ elif token in [RelayParser.T__0, RelayParser.T__3, RelayParser.T__5, RelayParser.T__7, RelayParser.T__12, RelayParser.SUB, RelayParser.GLOBAL_VAR, RelayParser.LOCAL_VAR, RelayParser.GRAPH_VAR, RelayParser.BOOL_LIT, RelayParser.FLOAT, RelayParser.NAT, RelayParser.CNAME]:
+ self.state = 45
+ self.expr(0)
+ pass
+ else:
+ raise NoViableAltException(self)
+
+ self.state = 48
+ self.match(RelayParser.EOF)
+ except RecognitionException as re:
+ localctx.exception = re
+ self._errHandler.reportError(self, re)
+ self._errHandler.recover(self, re)
+ finally:
+ self.exitRule()
+ return localctx
+
+
+ class ExprContext(ParserRuleContext):
+
+ def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1):
+ super().__init__(parent, invokingState)
+ self.parser = parser
+
+
+ def getRuleIndex(self):
+ return RelayParser.RULE_expr
+
+
+ def copyFrom(self, ctx:ParserRuleContext):
+ super().copyFrom(ctx)
+
+
+ class IdentExprContext(ExprContext):
+
+ def __init__(self, parser, ctx:ParserRuleContext): # actually a RelayParser.ExprContext
+ super().__init__(parser)
+ self.copyFrom(ctx)
+
+ def ident(self):
+ return self.getTypedRuleContext(RelayParser.IdentContext,0)
+
+
+ def accept(self, visitor:ParseTreeVisitor):
+ if hasattr( visitor, "visitIdentExpr" ):
+ return visitor.visitIdentExpr(self)
+ else:
+ return visitor.visitChildren(self)
+
+
+ class CallContext(ExprContext):
+
+ def __init__(self, parser, ctx:ParserRuleContext): # actually a RelayParser.ExprContext
+ super().__init__(parser)
+ self.copyFrom(ctx)
+
+ def expr(self, i:int=None):
+ if i is None:
+ return self.getTypedRuleContexts(RelayParser.ExprContext)
+ else:
+ return self.getTypedRuleContext(RelayParser.ExprContext,i)
+
+
+ def accept(self, visitor:ParseTreeVisitor):
+ if hasattr( visitor, "visitCall" ):
+ return visitor.visitCall(self)
+ else:
+ return visitor.visitChildren(self)
+
+
+ class NegContext(ExprContext):
+
+ def __init__(self, parser, ctx:ParserRuleContext): # actually a RelayParser.ExprContext
+ super().__init__(parser)
+ self.copyFrom(ctx)
+
+ def SUB(self):
+ return self.getToken(RelayParser.SUB, 0)
+ def expr(self):
+ return self.getTypedRuleContext(RelayParser.ExprContext,0)
+
+
+ def accept(self, visitor:ParseTreeVisitor):
+ if hasattr( visitor, "visitNeg" ):
+ return visitor.visitNeg(self)
+ else:
+ return visitor.visitChildren(self)
+
+
+ class TupleContext(ExprContext):
+
+ def __init__(self, parser, ctx:ParserRuleContext): # actually a RelayParser.ExprContext
+ super().__init__(parser)
+ self.copyFrom(ctx)
+
+ def expr(self, i:int=None):
+ if i is None:
+ return self.getTypedRuleContexts(RelayParser.ExprContext)
+ else:
+ return self.getTypedRuleContext(RelayParser.ExprContext,i)
+
+
+ def accept(self, visitor:ParseTreeVisitor):
+ if hasattr( visitor, "visitTuple" ):
+ return visitor.visitTuple(self)
+ else:
+ return visitor.visitChildren(self)
+
+
+ class ParensContext(ExprContext):
+
+ def __init__(self, parser, ctx:ParserRuleContext): # actually a RelayParser.ExprContext
+ super().__init__(parser)
+ self.copyFrom(ctx)
+
+ def expr(self):
+ return self.getTypedRuleContext(RelayParser.ExprContext,0)
+
+
+ def accept(self, visitor:ParseTreeVisitor):
+ if hasattr( visitor, "visitParens" ):
+ return visitor.visitParens(self)
+ else:
+ return visitor.visitChildren(self)
+
+
+ class FuncExprContext(ExprContext):
+
+ def __init__(self, parser, ctx:ParserRuleContext): # actually a RelayParser.ExprContext
+ super().__init__(parser)
+ self.copyFrom(ctx)
+
+ def func(self):
+ return self.getTypedRuleContext(RelayParser.FuncContext,0)
+
+
+ def accept(self, visitor:ParseTreeVisitor):
+ if hasattr( visitor, "visitFuncExpr" ):
+ return visitor.visitFuncExpr(self)
+ else:
+ return visitor.visitChildren(self)
+
+
+ class ScalarExprContext(ExprContext):
+
+ def __init__(self, parser, ctx:ParserRuleContext): # actually a RelayParser.ExprContext
+ super().__init__(parser)
+ self.copyFrom(ctx)
+
+ def scalar(self):
+ return self.getTypedRuleContext(RelayParser.ScalarContext,0)
+
+
+ def accept(self, visitor:ParseTreeVisitor):
+ if hasattr( visitor, "visitScalarExpr" ):
+ return visitor.visitScalarExpr(self)
+ else:
+ return visitor.visitChildren(self)
+
+
+ class LetContext(ExprContext):
+
+ def __init__(self, parser, ctx:ParserRuleContext): # actually a RelayParser.ExprContext
+ super().__init__(parser)
+ self.copyFrom(ctx)
+
+ def var(self):
+ return self.getTypedRuleContext(RelayParser.VarContext,0)
+
+ def expr(self, i:int=None):
+ if i is None:
+ return self.getTypedRuleContexts(RelayParser.ExprContext)
+ else:
+ return self.getTypedRuleContext(RelayParser.ExprContext,i)
+
+ def MUT(self):
+ return self.getToken(RelayParser.MUT, 0)
+
+ def accept(self, visitor:ParseTreeVisitor):
+ if hasattr( visitor, "visitLet" ):
+ return visitor.visitLet(self)
+ else:
+ return visitor.visitChildren(self)
+
+
+ class TensorContext(ExprContext):
+
+ def __init__(self, parser, ctx:ParserRuleContext): # actually a RelayParser.ExprContext
+ super().__init__(parser)
+ self.copyFrom(ctx)
+
+ def expr(self, i:int=None):
+ if i is None:
+ return self.getTypedRuleContexts(RelayParser.ExprContext)
+ else:
+ return self.getTypedRuleContext(RelayParser.ExprContext,i)
+
+
+ def accept(self, visitor:ParseTreeVisitor):
+ if hasattr( visitor, "visitTensor" ):
+ return visitor.visitTensor(self)
+ else:
+ return visitor.visitChildren(self)
+
+
+ class IfElseContext(ExprContext):
+
+ def __init__(self, parser, ctx:ParserRuleContext): # actually a RelayParser.ExprContext
+ super().__init__(parser)
+ self.copyFrom(ctx)
+
+ def expr(self):
+ return self.getTypedRuleContext(RelayParser.ExprContext,0)
+
+ def body(self, i:int=None):
+ if i is None:
+ return self.getTypedRuleContexts(RelayParser.BodyContext)
+ else:
+ return self.getTypedRuleContext(RelayParser.BodyContext,i)
+
+
+ def accept(self, visitor:ParseTreeVisitor):
+ if hasattr( visitor, "visitIfElse" ):
+ return visitor.visitIfElse(self)
+ else:
+ return visitor.visitChildren(self)
+
+
+ class GraphContext(ExprContext):
+
+ def __init__(self, parser, ctx:ParserRuleContext): # actually a RelayParser.ExprContext
+ super().__init__(parser)
+ self.copyFrom(ctx)
+
+ def ident(self):
+ return self.getTypedRuleContext(RelayParser.IdentContext,0)
+
+ def expr(self, i:int=None):
+ if i is None:
+ return self.getTypedRuleContexts(RelayParser.ExprContext)
+ else:
+ return self.getTypedRuleContext(RelayParser.ExprContext,i)
+
+
+ def accept(self, visitor:ParseTreeVisitor):
+ if hasattr( visitor, "visitGraph" ):
+ return visitor.visitGraph(self)
+ else:
+ return visitor.visitChildren(self)
+
+
+ class BinOpContext(ExprContext):
+
+ def __init__(self, parser, ctx:ParserRuleContext): # actually a RelayParser.ExprContext
+ super().__init__(parser)
+ self.op = None # Token
+ self.copyFrom(ctx)
+
+ def expr(self, i:int=None):
+ if i is None:
+ return self.getTypedRuleContexts(RelayParser.ExprContext)
+ else:
+ return self.getTypedRuleContext(RelayParser.ExprContext,i)
+
+ def MUL(self):
+ return self.getToken(RelayParser.MUL, 0)
+ def DIV(self):
+ return self.getToken(RelayParser.DIV, 0)
+ def ADD(self):
+ return self.getToken(RelayParser.ADD, 0)
+ def SUB(self):
+ return self.getToken(RelayParser.SUB, 0)
+ def LT(self):
+ return self.getToken(RelayParser.LT, 0)
+ def GT(self):
+ return self.getToken(RelayParser.GT, 0)
+ def LE(self):
+ return self.getToken(RelayParser.LE, 0)
+ def GE(self):
+ return self.getToken(RelayParser.GE, 0)
+ def EQ(self):
+ return self.getToken(RelayParser.EQ, 0)
+ def NE(self):
+ return self.getToken(RelayParser.NE, 0)
+
+ def accept(self, visitor:ParseTreeVisitor):
+ if hasattr( visitor, "visitBinOp" ):
+ return visitor.visitBinOp(self)
+ else:
+ return visitor.visitChildren(self)
+
+
+
+ def expr(self, _p:int=0):
+ _parentctx = self._ctx
+ _parentState = self.state
+ localctx = RelayParser.ExprContext(self, self._ctx, _parentState)
+ _prevctx = localctx
+ _startState = 4
+ self.enterRecursionRule(localctx, 4, self.RULE_expr, _p)
+ self._la = 0 # Token type
+ try:
+ self.enterOuterAlt(localctx, 1)
+ self.state = 125
+ self._errHandler.sync(self)
+ la_ = self._interp.adaptivePredict(self._input,7,self._ctx)
+ if la_ == 1:
+ localctx = RelayParser.ParensContext(self, localctx)
+ self._ctx = localctx
+ _prevctx = localctx
+
+ self.state = 51
+ self.match(RelayParser.T__0)
+ self.state = 52
+ self.expr(0)
+ self.state = 53
+ self.match(RelayParser.T__1)
+ pass
+
+ elif la_ == 2:
+ localctx = RelayParser.NegContext(self, localctx)
+ self._ctx = localctx
+ _prevctx = localctx
+ self.state = 55
+ self.match(RelayParser.SUB)
+ self.state = 56
+ self.expr(17)
+ pass
+
+ elif la_ == 3:
+ localctx = RelayParser.FuncExprContext(self, localctx)
+ self._ctx = localctx
+ _prevctx = localctx
+ self.state = 57
+ self.func()
+ pass
+
+ elif la_ == 4:
+ localctx = RelayParser.TupleContext(self, localctx)
+ self._ctx = localctx
+ _prevctx = localctx
+ self.state = 58
+ self.match(RelayParser.T__0)
+ self.state = 59
+ self.match(RelayParser.T__1)
+ pass
+
+ elif la_ == 5:
+ localctx = RelayParser.TupleContext(self, localctx)
+ self._ctx = localctx
+ _prevctx = localctx
+ self.state = 60
+ self.match(RelayParser.T__0)
+ self.state = 61
+ self.expr(0)
+ self.state = 62
+ self.match(RelayParser.T__2)
+ self.state = 63
+ self.match(RelayParser.T__1)
+ pass
+
+ elif la_ == 6:
+ localctx = RelayParser.TupleContext(self, localctx)
+ self._ctx = localctx
+ _prevctx = localctx
+ self.state = 65
+ self.match(RelayParser.T__0)
+ self.state = 66
+ self.expr(0)
+ self.state = 69
+ self._errHandler.sync(self)
+ _la = self._input.LA(1)
+ while True:
+ self.state = 67
+ self.match(RelayParser.T__2)
+ self.state = 68
+ self.expr(0)
+ self.state = 71
+ self._errHandler.sync(self)
+ _la = self._input.LA(1)
+ if not (_la==RelayParser.T__2):
+ break
+
+ self.state = 73
+ self.match(RelayParser.T__1)
+ pass
+
+ elif la_ == 7:
+ localctx = RelayParser.TensorContext(self, localctx)
+ self._ctx = localctx
+ _prevctx = localctx
+ self.state = 75
+ self.match(RelayParser.T__3)
+ self.state = 84
+ self._errHandler.sync(self)
+ _la = self._input.LA(1)
+ if (((_la) & ~0x3f) == 0 and ((1 << _la) & ((1 << RelayParser.T__0) | (1 << RelayParser.T__3) | (1 << RelayParser.T__5) | (1 << RelayParser.T__7) | (1 << RelayParser.T__12) | (1 << RelayParser.SUB) | (1 << RelayParser.GLOBAL_VAR) | (1 << RelayParser.LOCAL_VAR) | (1 << RelayParser.GRAPH_VAR) | (1 << RelayParser.BOOL_LIT) | (1 << RelayParser.FLOAT) | (1 << RelayParser.NAT) | (1 << RelayParser.CNAME))) != 0):
+ self.state = 76
+ self.expr(0)
+ self.state = 81
+ self._errHandler.sync(self)
+ _la = self._input.LA(1)
+ while _la==RelayParser.T__2:
+ self.state = 77
+ self.match(RelayParser.T__2)
+ self.state = 78
+ self.expr(0)
+ self.state = 83
+ self._errHandler.sync(self)
+ _la = self._input.LA(1)
+
+
+
+ self.state = 86
+ self.match(RelayParser.T__4)
+ pass
+
+ elif la_ == 8:
+ localctx = RelayParser.IfElseContext(self, localctx)
+ self._ctx = localctx
+ _prevctx = localctx
+ self.state = 87
+ self.match(RelayParser.T__5)
+ self.state = 88
+ self.match(RelayParser.T__0)
+ self.state = 89
+ self.expr(0)
+ self.state = 90
+ self.match(RelayParser.T__1)
+ self.state = 91
+ self.body()
+ self.state = 92
+ self.match(RelayParser.T__6)
+ self.state = 93
+ self.body()
+ pass
+
+ elif la_ == 9:
+ localctx = RelayParser.LetContext(self, localctx)
+ self._ctx = localctx
+ _prevctx = localctx
+ self.state = 95
+ self.match(RelayParser.T__7)
+ self.state = 97
+ self._errHandler.sync(self)
+ _la = self._input.LA(1)
+ if _la==RelayParser.MUT:
+ self.state = 96
+ self.match(RelayParser.MUT)
+
+
+ self.state = 99
+ self.var()
+ self.state = 100
+ self.match(RelayParser.T__8)
+ self.state = 101
+ self.expr(0)
+ self.state = 102
+ self.match(RelayParser.T__9)
+ self.state = 103
+ self.expr(6)
+ pass
+
+ elif la_ == 10:
+ localctx = RelayParser.LetContext(self, localctx)
+ self._ctx = localctx
+ _prevctx = localctx
+ self.state = 105
+ self.match(RelayParser.T__7)
+ self.state = 107
+ self._errHandler.sync(self)
+ _la = self._input.LA(1)
+ if _la==RelayParser.MUT:
+ self.state = 106
+ self.match(RelayParser.MUT)
+
+
+ self.state = 109
+ self.var()
+ self.state = 110
+ self.match(RelayParser.T__8)
+ self.state = 111
+ self.match(RelayParser.T__10)
+ self.state = 112
+ self.expr(0)
+ self.state = 113
+ self.match(RelayParser.T__11)
+ self.state = 114
+ self.match(RelayParser.T__9)
+ self.state = 115
+ self.expr(5)
+ pass
+
+ elif la_ == 11:
+ localctx = RelayParser.GraphContext(self, localctx)
+ self._ctx = localctx
+ _prevctx = localctx
+ self.state = 117
+ self.ident()
+ self.state = 118
+ self.match(RelayParser.T__8)
+ self.state = 119
+ self.expr(0)
+ self.state = 120
+ self.match(RelayParser.T__9)
+ self.state = 121
+ self.expr(3)
+ pass
+
+ elif la_ == 12:
+ localctx = RelayParser.IdentExprContext(self, localctx)
+ self._ctx = localctx
+ _prevctx = localctx
+ self.state = 123
+ self.ident()
+ pass
+
+ elif la_ == 13:
+ localctx = RelayParser.ScalarExprContext(self, localctx)
+ self._ctx = localctx
+ _prevctx = localctx
+ self.state = 124
+ self.scalar()
+ pass
+
+
+ self._ctx.stop = self._input.LT(-1)
+ self.state = 157
+ self._errHandler.sync(self)
+ _alt = self._interp.adaptivePredict(self._input,11,self._ctx)
+ while _alt!=2 and _alt!=ATN.INVALID_ALT_NUMBER:
+ if _alt==1:
+ if self._parseListeners is not None:
+ self.triggerExitRuleEvent()
+ _prevctx = localctx
+ self.state = 155
+ self._errHandler.sync(self)
+ la_ = self._interp.adaptivePredict(self._input,10,self._ctx)
+ if la_ == 1:
+ localctx = RelayParser.BinOpContext(self, RelayParser.ExprContext(self, _parentctx, _parentState))
+ self.pushNewRecursionContext(localctx, _startState, self.RULE_expr)
+ self.state = 127
+ if not self.precpred(self._ctx, 16):
+ from antlr4.error.Errors import FailedPredicateException
+ raise FailedPredicateException(self, "self.precpred(self._ctx, 16)")
+ self.state = 128
+ localctx.op = self._input.LT(1)
+ _la = self._input.LA(1)
+ if not(_la==RelayParser.MUL or _la==RelayParser.DIV):
+ localctx.op = self._errHandler.recoverInline(self)
+ else:
+ self._errHandler.reportMatch(self)
+ self.consume()
+ self.state = 129
+ self.expr(17)
+ pass
+
+ elif la_ == 2:
+ localctx = RelayParser.BinOpContext(self, RelayParser.ExprContext(self, _parentctx, _parentState))
+ self.pushNewRecursionContext(localctx, _startState, self.RULE_expr)
+ self.state = 130
+ if not self.precpred(self._ctx, 15):
+ from antlr4.error.Errors import FailedPredicateException
+ raise FailedPredicateException(self, "self.precpred(self._ctx, 15)")
+ self.state = 131
+ localctx.op = self._input.LT(1)
+ _la = self._input.LA(1)
+ if not(_la==RelayParser.ADD or _la==RelayParser.SUB):
+ localctx.op = self._errHandler.recoverInline(self)
+ else:
+ self._errHandler.reportMatch(self)
+ self.consume()
+ self.state = 132
+ self.expr(16)
+ pass
+
+ elif la_ == 3:
+ localctx = RelayParser.BinOpContext(self, RelayParser.ExprContext(self, _parentctx, _parentState))
+ self.pushNewRecursionContext(localctx, _startState, self.RULE_expr)
+ self.state = 133
+ if not self.precpred(self._ctx, 14):
+ from antlr4.error.Errors import FailedPredicateException
+ raise FailedPredicateException(self, "self.precpred(self._ctx, 14)")
+ self.state = 134
+ localctx.op = self._input.LT(1)
+ _la = self._input.LA(1)
+ if not((((_la) & ~0x3f) == 0 and ((1 << _la) & ((1 << RelayParser.LT) | (1 << RelayParser.GT) | (1 << RelayParser.LE) | (1 << RelayParser.GE))) != 0)):
+ localctx.op = self._errHandler.recoverInline(self)
+ else:
+ self._errHandler.reportMatch(self)
+ self.consume()
+ self.state = 135
+ self.expr(15)
+ pass
+
+ elif la_ == 4:
+ localctx = RelayParser.BinOpContext(self, RelayParser.ExprContext(self, _parentctx, _parentState))
+ self.pushNewRecursionContext(localctx, _startState, self.RULE_expr)
+ self.state = 136
+ if not self.precpred(self._ctx, 13):
+ from antlr4.error.Errors import FailedPredicateException
+ raise FailedPredicateException(self, "self.precpred(self._ctx, 13)")
+ self.state = 137
+ localctx.op = self._input.LT(1)
+ _la = self._input.LA(1)
+ if not(_la==RelayParser.EQ or _la==RelayParser.NE):
+ localctx.op = self._errHandler.recoverInline(self)
+ else:
+ self._errHandler.reportMatch(self)
+ self.consume()
+ self.state = 138
+ self.expr(14)
+ pass
+
+ elif la_ == 5:
+ localctx = RelayParser.LetContext(self, RelayParser.ExprContext(self, _parentctx, _parentState))
+ self.pushNewRecursionContext(localctx, _startState, self.RULE_expr)
+ self.state = 139
+ if not self.precpred(self._ctx, 4):
+ from antlr4.error.Errors import FailedPredicateException
+ raise FailedPredicateException(self, "self.precpred(self._ctx, 4)")
+ self.state = 140
+ self.match(RelayParser.T__9)
+ self.state = 141
+ self.expr(5)
+ pass
+
+ elif la_ == 6:
+ localctx = RelayParser.CallContext(self, RelayParser.ExprContext(self, _parentctx, _parentState))
+ self.pushNewRecursionContext(localctx, _startState, self.RULE_expr)
+ self.state = 142
+ if not self.precpred(self._ctx, 18):
+ from antlr4.error.Errors import FailedPredicateException
+ raise FailedPredicateException(self, "self.precpred(self._ctx, 18)")
+ self.state = 143
+ self.match(RelayParser.T__0)
+ self.state = 152
+ self._errHandler.sync(self)
+ _la = self._input.LA(1)
+ if (((_la) & ~0x3f) == 0 and ((1 << _la) & ((1 << RelayParser.T__0) | (1 << RelayParser.T__3) | (1 << RelayParser.T__5) | (1 << RelayParser.T__7) | (1 << RelayParser.T__12) | (1 << RelayParser.SUB) | (1 << RelayParser.GLOBAL_VAR) | (1 << RelayParser.LOCAL_VAR) | (1 << RelayParser.GRAPH_VAR) | (1 << RelayParser.BOOL_LIT) | (1 << RelayParser.FLOAT) | (1 << RelayParser.NAT) | (1 << RelayParser.CNAME))) != 0):
+ self.state = 144
+ self.expr(0)
+ self.state = 149
+ self._errHandler.sync(self)
+ _la = self._input.LA(1)
+ while _la==RelayParser.T__2:
+ self.state = 145
+ self.match(RelayParser.T__2)
+ self.state = 146
+ self.expr(0)
+ self.state = 151
+ self._errHandler.sync(self)
+ _la = self._input.LA(1)
+
+
+
+ self.state = 154
+ self.match(RelayParser.T__1)
+ pass
+
+
+ self.state = 159
+ self._errHandler.sync(self)
+ _alt = self._interp.adaptivePredict(self._input,11,self._ctx)
+
+ except RecognitionException as re:
+ localctx.exception = re
+ self._errHandler.reportError(self, re)
+ self._errHandler.recover(self, re)
+ finally:
+ self.unrollRecursionContexts(_parentctx)
+ return localctx
+
+
+ class FuncContext(ParserRuleContext):
+
+ def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1):
+ super().__init__(parent, invokingState)
+ self.parser = parser
+
+ def argList(self):
+ return self.getTypedRuleContext(RelayParser.ArgListContext,0)
+
+
+ def body(self):
+ return self.getTypedRuleContext(RelayParser.BodyContext,0)
+
+
+ def typeParamSeq(self):
+ return self.getTypedRuleContext(RelayParser.TypeParamSeqContext,0)
+
+
+ def type_(self):
+ return self.getTypedRuleContext(RelayParser.Type_Context,0)
+
+
+ def getRuleIndex(self):
+ return RelayParser.RULE_func
+
+ def accept(self, visitor:ParseTreeVisitor):
+ if hasattr( visitor, "visitFunc" ):
+ return visitor.visitFunc(self)
+ else:
+ return visitor.visitChildren(self)
+
+
+
+
+ def func(self):
+
+ localctx = RelayParser.FuncContext(self, self._ctx, self.state)
+ self.enterRule(localctx, 6, self.RULE_func)
+ self._la = 0 # Token type
+ try:
+ self.enterOuterAlt(localctx, 1)
+ self.state = 160
+ self.match(RelayParser.T__12)
+ self.state = 162
+ self._errHandler.sync(self)
+ _la = self._input.LA(1)
+ if _la==RelayParser.T__3:
+ self.state = 161
+ self.typeParamSeq()
+
+
+ self.state = 164
+ self.match(RelayParser.T__0)
+ self.state = 165
+ self.argList()
+ self.state = 166
+ self.match(RelayParser.T__1)
+ self.state = 169
+ self._errHandler.sync(self)
+ _la = self._input.LA(1)
+ if _la==RelayParser.T__13:
+ self.state = 167
+ self.match(RelayParser.T__13)
+ self.state = 168
+ self.type_()
+
+
+ self.state = 171
+ self.body()
+ except RecognitionException as re:
+ localctx.exception = re
+ self._errHandler.reportError(self, re)
+ self._errHandler.recover(self, re)
+ finally:
+ self.exitRule()
+ return localctx
+
+
+ class DefnContext(ParserRuleContext):
+
+ def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1):
+ super().__init__(parent, invokingState)
+ self.parser = parser
+
+ def ident(self):
+ return self.getTypedRuleContext(RelayParser.IdentContext,0)
+
+
+ def argList(self):
+ return self.getTypedRuleContext(RelayParser.ArgListContext,0)
+
+
+ def body(self):
+ return self.getTypedRuleContext(RelayParser.BodyContext,0)
+
+
+ def typeParamSeq(self):
+ return self.getTypedRuleContext(RelayParser.TypeParamSeqContext,0)
+
+
+ def type_(self):
+ return self.getTypedRuleContext(RelayParser.Type_Context,0)
+
+
+ def getRuleIndex(self):
+ return RelayParser.RULE_defn
+
+ def accept(self, visitor:ParseTreeVisitor):
+ if hasattr( visitor, "visitDefn" ):
+ return visitor.visitDefn(self)
+ else:
+ return visitor.visitChildren(self)
+
+
+
+
+ def defn(self):
+
+ localctx = RelayParser.DefnContext(self, self._ctx, self.state)
+ self.enterRule(localctx, 8, self.RULE_defn)
+ self._la = 0 # Token type
+ try:
+ self.enterOuterAlt(localctx, 1)
+ self.state = 173
+ self.match(RelayParser.T__14)
+ self.state = 174
+ self.ident()
+ self.state = 176
+ self._errHandler.sync(self)
+ _la = self._input.LA(1)
+ if _la==RelayParser.T__3:
+ self.state = 175
+ self.typeParamSeq()
+
+
+ self.state = 178
+ self.match(RelayParser.T__0)
+ self.state = 179
+ self.argList()
+ self.state = 180
+ self.match(RelayParser.T__1)
+ self.state = 183
+ self._errHandler.sync(self)
+ _la = self._input.LA(1)
+ if _la==RelayParser.T__13:
+ self.state = 181
+ self.match(RelayParser.T__13)
+ self.state = 182
+ self.type_()
+
+
+ self.state = 185
+ self.body()
+ except RecognitionException as re:
+ localctx.exception = re
+ self._errHandler.reportError(self, re)
+ self._errHandler.recover(self, re)
+ finally:
+ self.exitRule()
+ return localctx
+
+
+ class ArgListContext(ParserRuleContext):
+
+ def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1):
+ super().__init__(parent, invokingState)
+ self.parser = parser
+
+ def varList(self):
+ return self.getTypedRuleContext(RelayParser.VarListContext,0)
+
+
+ def attrList(self):
+ return self.getTypedRuleContext(RelayParser.AttrListContext,0)
+
+
+ def getRuleIndex(self):
+ return RelayParser.RULE_argList
+
+ def accept(self, visitor:ParseTreeVisitor):
+ if hasattr( visitor, "visitArgList" ):
+ return visitor.visitArgList(self)
+ else:
+ return visitor.visitChildren(self)
+
+
+
+
+ def argList(self):
+
+ localctx = RelayParser.ArgListContext(self, self._ctx, self.state)
+ self.enterRule(localctx, 10, self.RULE_argList)
+ try:
+ self.state = 193
+ self._errHandler.sync(self)
+ la_ = self._interp.adaptivePredict(self._input,16,self._ctx)
+ if la_ == 1:
+ self.enterOuterAlt(localctx, 1)
+ self.state = 187
+ self.varList()
+ pass
+
+ elif la_ == 2:
+ self.enterOuterAlt(localctx, 2)
+ self.state = 188
+ self.attrList()
+ pass
+
+ elif la_ == 3:
+ self.enterOuterAlt(localctx, 3)
+ self.state = 189
+ self.varList()
+ self.state = 190
+ self.match(RelayParser.T__2)
+ self.state = 191
+ self.attrList()
+ pass
+
+
+ except RecognitionException as re:
+ localctx.exception = re
+ self._errHandler.reportError(self, re)
+ self._errHandler.recover(self, re)
+ finally:
+ self.exitRule()
+ return localctx
+
+
+ class VarListContext(ParserRuleContext):
+
+ def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1):
+ super().__init__(parent, invokingState)
+ self.parser = parser
+
+ def var(self, i:int=None):
+ if i is None:
+ return self.getTypedRuleContexts(RelayParser.VarContext)
+ else:
+ return self.getTypedRuleContext(RelayParser.VarContext,i)
+
+
+ def getRuleIndex(self):
+ return RelayParser.RULE_varList
+
+ def accept(self, visitor:ParseTreeVisitor):
+ if hasattr( visitor, "visitVarList" ):
+ return visitor.visitVarList(self)
+ else:
+ return visitor.visitChildren(self)
+
+
+
+
+ def varList(self):
+
+ localctx = RelayParser.VarListContext(self, self._ctx, self.state)
+ self.enterRule(localctx, 12, self.RULE_varList)
+ self._la = 0 # Token type
+ try:
+ self.enterOuterAlt(localctx, 1)
+ self.state = 203
+ self._errHandler.sync(self)
+ _la = self._input.LA(1)
+ if (((_la) & ~0x3f) == 0 and ((1 << _la) & ((1 << RelayParser.GLOBAL_VAR) | (1 << RelayParser.LOCAL_VAR) | (1 << RelayParser.GRAPH_VAR) | (1 << RelayParser.CNAME))) != 0):
+ self.state = 195
+ self.var()
+ self.state = 200
+ self._errHandler.sync(self)
+ _alt = self._interp.adaptivePredict(self._input,17,self._ctx)
+ while _alt!=2 and _alt!=ATN.INVALID_ALT_NUMBER:
+ if _alt==1:
+ self.state = 196
+ self.match(RelayParser.T__2)
+ self.state = 197
+ self.var()
+ self.state = 202
+ self._errHandler.sync(self)
+ _alt = self._interp.adaptivePredict(self._input,17,self._ctx)
+
+
+
+ except RecognitionException as re:
+ localctx.exception = re
+ self._errHandler.reportError(self, re)
+ self._errHandler.recover(self, re)
+ finally:
+ self.exitRule()
+ return localctx
+
+
+ class VarContext(ParserRuleContext):
+
+ def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1):
+ super().__init__(parent, invokingState)
+ self.parser = parser
+
+ def ident(self):
+ return self.getTypedRuleContext(RelayParser.IdentContext,0)
+
+
+ def type_(self):
+ return self.getTypedRuleContext(RelayParser.Type_Context,0)
+
+
+ def getRuleIndex(self):
+ return RelayParser.RULE_var
+
+ def accept(self, visitor:ParseTreeVisitor):
+ if hasattr( visitor, "visitVar" ):
+ return visitor.visitVar(self)
+ else:
+ return visitor.visitChildren(self)
+
+
+
+
+ def var(self):
+
+ localctx = RelayParser.VarContext(self, self._ctx, self.state)
+ self.enterRule(localctx, 14, self.RULE_var)
+ self._la = 0 # Token type
+ try:
+ self.enterOuterAlt(localctx, 1)
+ self.state = 205
+ self.ident()
+ self.state = 208
+ self._errHandler.sync(self)
+ _la = self._input.LA(1)
+ if _la==RelayParser.T__15:
+ self.state = 206
+ self.match(RelayParser.T__15)
+ self.state = 207
+ self.type_()
+
+
+ except RecognitionException as re:
+ localctx.exception = re
+ self._errHandler.reportError(self, re)
+ self._errHandler.recover(self, re)
+ finally:
+ self.exitRule()
+ return localctx
+
+
+ class AttrListContext(ParserRuleContext):
+
+ def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1):
+ super().__init__(parent, invokingState)
+ self.parser = parser
+
+ def attr(self, i:int=None):
+ if i is None:
+ return self.getTypedRuleContexts(RelayParser.AttrContext)
+ else:
+ return self.getTypedRuleContext(RelayParser.AttrContext,i)
+
+
+ def getRuleIndex(self):
+ return RelayParser.RULE_attrList
+
+ def accept(self, visitor:ParseTreeVisitor):
+ if hasattr( visitor, "visitAttrList" ):
+ return visitor.visitAttrList(self)
+ else:
+ return visitor.visitChildren(self)
+
+
+
+
+ def attrList(self):
+
+ localctx = RelayParser.AttrListContext(self, self._ctx, self.state)
+ self.enterRule(localctx, 16, self.RULE_attrList)
+ self._la = 0 # Token type
+ try:
+ self.enterOuterAlt(localctx, 1)
+ self.state = 218
+ self._errHandler.sync(self)
+ _la = self._input.LA(1)
+ if _la==RelayParser.CNAME:
+ self.state = 210
+ self.attr()
+ self.state = 215
+ self._errHandler.sync(self)
+ _la = self._input.LA(1)
+ while _la==RelayParser.T__2:
+ self.state = 211
+ self.match(RelayParser.T__2)
+ self.state = 212
+ self.attr()
+ self.state = 217
+ self._errHandler.sync(self)
+ _la = self._input.LA(1)
+
+
+
+ except RecognitionException as re:
+ localctx.exception = re
+ self._errHandler.reportError(self, re)
+ self._errHandler.recover(self, re)
+ finally:
+ self.exitRule()
+ return localctx
+
+
+ class AttrContext(ParserRuleContext):
+
+ def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1):
+ super().__init__(parent, invokingState)
+ self.parser = parser
+
+ def CNAME(self):
+ return self.getToken(RelayParser.CNAME, 0)
+
+ def expr(self):
+ return self.getTypedRuleContext(RelayParser.ExprContext,0)
+
+
+ def getRuleIndex(self):
+ return RelayParser.RULE_attr
+
+ def accept(self, visitor:ParseTreeVisitor):
+ if hasattr( visitor, "visitAttr" ):
+ return visitor.visitAttr(self)
+ else:
+ return visitor.visitChildren(self)
+
+
+
+
+ def attr(self):
+
+ localctx = RelayParser.AttrContext(self, self._ctx, self.state)
+ self.enterRule(localctx, 18, self.RULE_attr)
+ try:
+ self.enterOuterAlt(localctx, 1)
+ self.state = 220
+ self.match(RelayParser.CNAME)
+ self.state = 221
+ self.match(RelayParser.T__8)
+ self.state = 222
+ self.expr(0)
+ except RecognitionException as re:
+ localctx.exception = re
+ self._errHandler.reportError(self, re)
+ self._errHandler.recover(self, re)
+ finally:
+ self.exitRule()
+ return localctx
+
+
+ class TypeParamSeqContext(ParserRuleContext):
+
+ def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1):
+ super().__init__(parent, invokingState)
+ self.parser = parser
+
+ def ident(self, i:int=None):
+ if i is None:
+ return self.getTypedRuleContexts(RelayParser.IdentContext)
+ else:
+ return self.getTypedRuleContext(RelayParser.IdentContext,i)
+
+
+ def getRuleIndex(self):
+ return RelayParser.RULE_typeParamSeq
+
+ def accept(self, visitor:ParseTreeVisitor):
+ if hasattr( visitor, "visitTypeParamSeq" ):
+ return visitor.visitTypeParamSeq(self)
+ else:
+ return visitor.visitChildren(self)
+
+
+
+
+ def typeParamSeq(self):
+
+ localctx = RelayParser.TypeParamSeqContext(self, self._ctx, self.state)
+ self.enterRule(localctx, 20, self.RULE_typeParamSeq)
+ self._la = 0 # Token type
+ try:
+ self.state = 237
+ self._errHandler.sync(self)
+ la_ = self._interp.adaptivePredict(self._input,23,self._ctx)
+ if la_ == 1:
+ self.enterOuterAlt(localctx, 1)
+ self.state = 224
+ self.match(RelayParser.T__3)
+ self.state = 225
+ self.match(RelayParser.T__4)
+ pass
+
+ elif la_ == 2:
+ self.enterOuterAlt(localctx, 2)
+ self.state = 226
+ self.match(RelayParser.T__3)
+ self.state = 227
+ self.ident()
+ self.state = 232
+ self._errHandler.sync(self)
+ _la = self._input.LA(1)
+ while _la==RelayParser.T__2:
+ self.state = 228
+ self.match(RelayParser.T__2)
+ self.state = 229
+ self.ident()
+ self.state = 234
+ self._errHandler.sync(self)
+ _la = self._input.LA(1)
+
+ self.state = 235
+ self.match(RelayParser.T__4)
+ pass
+
+
+ except RecognitionException as re:
+ localctx.exception = re
+ self._errHandler.reportError(self, re)
+ self._errHandler.recover(self, re)
+ finally:
+ self.exitRule()
+ return localctx
+
+
+ class Type_Context(ParserRuleContext):
+
+ def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1):
+ super().__init__(parent, invokingState)
+ self.parser = parser
+
+
+ def getRuleIndex(self):
+ return RelayParser.RULE_type_
+
+
+ def copyFrom(self, ctx:ParserRuleContext):
+ super().copyFrom(ctx)
+
+
+
+ class IntTypeContext(Type_Context):
+
+ def __init__(self, parser, ctx:ParserRuleContext): # actually a RelayParser.Type_Context
+ super().__init__(parser)
+ self.copyFrom(ctx)
+
+ def NAT(self):
+ return self.getToken(RelayParser.NAT, 0)
+
+ def accept(self, visitor:ParseTreeVisitor):
+ if hasattr( visitor, "visitIntType" ):
+ return visitor.visitIntType(self)
+ else:
+ return visitor.visitChildren(self)
+
+
+ class TupleTypeContext(Type_Context):
+
+ def __init__(self, parser, ctx:ParserRuleContext): # actually a RelayParser.Type_Context
+ super().__init__(parser)
+ self.copyFrom(ctx)
+
+ def type_(self, i:int=None):
+ if i is None:
+ return self.getTypedRuleContexts(RelayParser.Type_Context)
+ else:
+ return self.getTypedRuleContext(RelayParser.Type_Context,i)
+
+
+ def accept(self, visitor:ParseTreeVisitor):
+ if hasattr( visitor, "visitTupleType" ):
+ return visitor.visitTupleType(self)
+ else:
+ return visitor.visitChildren(self)
+
+
+ class TypeIdentTypeContext(Type_Context):
+
+ def __init__(self, parser, ctx:ParserRuleContext): # actually a RelayParser.Type_Context
+ super().__init__(parser)
+ self.copyFrom(ctx)
+
+ def typeIdent(self):
+ return self.getTypedRuleContext(RelayParser.TypeIdentContext,0)
+
+
+ def accept(self, visitor:ParseTreeVisitor):
+ if hasattr( visitor, "visitTypeIdentType" ):
+ return visitor.visitTypeIdentType(self)
+ else:
+ return visitor.visitChildren(self)
+
+
+ class IncompleteTypeContext(Type_Context):
+
+ def __init__(self, parser, ctx:ParserRuleContext): # actually a RelayParser.Type_Context
+ super().__init__(parser)
+ self.copyFrom(ctx)
+
+
+ def accept(self, visitor:ParseTreeVisitor):
+ if hasattr( visitor, "visitIncompleteType" ):
+ return visitor.visitIncompleteType(self)
+ else:
+ return visitor.visitChildren(self)
+
+
+ class TensorTypeContext(Type_Context):
+
+ def __init__(self, parser, ctx:ParserRuleContext): # actually a RelayParser.Type_Context
+ super().__init__(parser)
+ self.copyFrom(ctx)
+
+ def shapeSeq(self):
+ return self.getTypedRuleContext(RelayParser.ShapeSeqContext,0)
+
+ def type_(self):
+ return self.getTypedRuleContext(RelayParser.Type_Context,0)
+
+
+ def accept(self, visitor:ParseTreeVisitor):
+ if hasattr( visitor, "visitTensorType" ):
+ return visitor.visitTensorType(self)
+ else:
+ return visitor.visitChildren(self)
+
+
+ class FuncTypeContext(Type_Context):
+
+ def __init__(self, parser, ctx:ParserRuleContext): # actually a RelayParser.Type_Context
+ super().__init__(parser)
+ self.copyFrom(ctx)
+
+ def type_(self, i:int=None):
+ if i is None:
+ return self.getTypedRuleContexts(RelayParser.Type_Context)
+ else:
+ return self.getTypedRuleContext(RelayParser.Type_Context,i)
+
+ def typeParamSeq(self):
+ return self.getTypedRuleContext(RelayParser.TypeParamSeqContext,0)
+
+
+ def accept(self, visitor:ParseTreeVisitor):
+ if hasattr( visitor, "visitFuncType" ):
+ return visitor.visitFuncType(self)
+ else:
+ return visitor.visitChildren(self)
+
+
+
+ def type_(self):
+
+ localctx = RelayParser.Type_Context(self, self._ctx, self.state)
+ self.enterRule(localctx, 22, self.RULE_type_)
+ self._la = 0 # Token type
+ try:
+ self.state = 284
+ self._errHandler.sync(self)
+ la_ = self._interp.adaptivePredict(self._input,28,self._ctx)
+ if la_ == 1:
+ localctx = RelayParser.TupleTypeContext(self, localctx)
+ self.enterOuterAlt(localctx, 1)
+ self.state = 239
+ self.match(RelayParser.T__0)
+ self.state = 240
+ self.match(RelayParser.T__1)
+ pass
+
+ elif la_ == 2:
+ localctx = RelayParser.TupleTypeContext(self, localctx)
+ self.enterOuterAlt(localctx, 2)
+ self.state = 241
+ self.match(RelayParser.T__0)
+ self.state = 242
+ self.type_()
+ self.state = 243
+ self.match(RelayParser.T__2)
+ self.state = 244
+ self.match(RelayParser.T__1)
+ pass
+
+ elif la_ == 3:
+ localctx = RelayParser.TupleTypeContext(self, localctx)
+ self.enterOuterAlt(localctx, 3)
+ self.state = 246
+ self.match(RelayParser.T__0)
+ self.state = 247
+ self.type_()
+ self.state = 250
+ self._errHandler.sync(self)
+ _la = self._input.LA(1)
+ while True:
+ self.state = 248
+ self.match(RelayParser.T__2)
+ self.state = 249
+ self.type_()
+ self.state = 252
+ self._errHandler.sync(self)
+ _la = self._input.LA(1)
+ if not (_la==RelayParser.T__2):
+ break
+
+ self.state = 254
+ self.match(RelayParser.T__1)
+ pass
+
+ elif la_ == 4:
+ localctx = RelayParser.TypeIdentTypeContext(self, localctx)
+ self.enterOuterAlt(localctx, 4)
+ self.state = 256
+ self.typeIdent()
+ pass
+
+ elif la_ == 5:
+ localctx = RelayParser.TensorTypeContext(self, localctx)
+ self.enterOuterAlt(localctx, 5)
+ self.state = 257
+ self.match(RelayParser.T__16)
+ self.state = 258
+ self.match(RelayParser.T__3)
+ self.state = 259
+ self.shapeSeq()
+ self.state = 260
+ self.match(RelayParser.T__2)
+ self.state = 261
+ self.type_()
+ self.state = 262
+ self.match(RelayParser.T__4)
+ pass
+
+ elif la_ == 6:
+ localctx = RelayParser.FuncTypeContext(self, localctx)
+ self.enterOuterAlt(localctx, 6)
+ self.state = 264
+ self.match(RelayParser.T__12)
+ self.state = 266
+ self._errHandler.sync(self)
+ _la = self._input.LA(1)
+ if _la==RelayParser.T__3:
+ self.state = 265
+ self.typeParamSeq()
+
+
+ self.state = 268
+ self.match(RelayParser.T__0)
+ self.state = 277
+ self._errHandler.sync(self)
+ _la = self._input.LA(1)
+ if (((_la) & ~0x3f) == 0 and ((1 << _la) & ((1 << RelayParser.T__0) | (1 << RelayParser.T__12) | (1 << RelayParser.T__16) | (1 << RelayParser.T__17) | (1 << RelayParser.NAT) | (1 << RelayParser.CNAME))) != 0):
+ self.state = 269
+ self.type_()
+ self.state = 274
+ self._errHandler.sync(self)
+ _la = self._input.LA(1)
+ while _la==RelayParser.T__2:
+ self.state = 270
+ self.match(RelayParser.T__2)
+ self.state = 271
+ self.type_()
+ self.state = 276
+ self._errHandler.sync(self)
+ _la = self._input.LA(1)
+
+
+
+ self.state = 279
+ self.match(RelayParser.T__1)
+ self.state = 280
+ self.match(RelayParser.T__13)
+ self.state = 281
+ self.type_()
+ pass
+
+ elif la_ == 7:
+ localctx = RelayParser.IncompleteTypeContext(self, localctx)
+ self.enterOuterAlt(localctx, 7)
+ self.state = 282
+ self.match(RelayParser.T__17)
+ pass
+
+ elif la_ == 8:
+ localctx = RelayParser.IntTypeContext(self, localctx)
+ self.enterOuterAlt(localctx, 8)
+ self.state = 283
+ self.match(RelayParser.NAT)
+ pass
+
+
+ except RecognitionException as re:
+ localctx.exception = re
+ self._errHandler.reportError(self, re)
+ self._errHandler.recover(self, re)
+ finally:
+ self.exitRule()
+ return localctx
+
+
+ class ShapeSeqContext(ParserRuleContext):
+
+ def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1):
+ super().__init__(parent, invokingState)
+ self.parser = parser
+
+ def shape(self, i:int=None):
+ if i is None:
+ return self.getTypedRuleContexts(RelayParser.ShapeContext)
+ else:
+ return self.getTypedRuleContext(RelayParser.ShapeContext,i)
+
+
+ def getRuleIndex(self):
+ return RelayParser.RULE_shapeSeq
+
+ def accept(self, visitor:ParseTreeVisitor):
+ if hasattr( visitor, "visitShapeSeq" ):
+ return visitor.visitShapeSeq(self)
+ else:
+ return visitor.visitChildren(self)
+
+
+
+
+ def shapeSeq(self):
+
+ localctx = RelayParser.ShapeSeqContext(self, self._ctx, self.state)
+ self.enterRule(localctx, 24, self.RULE_shapeSeq)
+ self._la = 0 # Token type
+ try:
+ self.state = 303
+ self._errHandler.sync(self)
+ la_ = self._interp.adaptivePredict(self._input,30,self._ctx)
+ if la_ == 1:
+ self.enterOuterAlt(localctx, 1)
+ self.state = 286
+ self.match(RelayParser.T__0)
+ self.state = 287
+ self.match(RelayParser.T__1)
+ pass
+
+ elif la_ == 2:
+ self.enterOuterAlt(localctx, 2)
+ self.state = 288
+ self.match(RelayParser.T__0)
+ self.state = 289
+ self.shape()
+ self.state = 290
+ self.match(RelayParser.T__2)
+ self.state = 291
+ self.match(RelayParser.T__1)
+ pass
+
+ elif la_ == 3:
+ self.enterOuterAlt(localctx, 3)
+ self.state = 293
+ self.match(RelayParser.T__0)
+ self.state = 294
+ self.shape()
+ self.state = 297
+ self._errHandler.sync(self)
+ _la = self._input.LA(1)
+ while True:
+ self.state = 295
+ self.match(RelayParser.T__2)
+ self.state = 296
+ self.shape()
+ self.state = 299
+ self._errHandler.sync(self)
+ _la = self._input.LA(1)
+ if not (_la==RelayParser.T__2):
+ break
+
+ self.state = 301
+ self.match(RelayParser.T__1)
+ pass
+
+
+ except RecognitionException as re:
+ localctx.exception = re
+ self._errHandler.reportError(self, re)
+ self._errHandler.recover(self, re)
+ finally:
+ self.exitRule()
+ return localctx
+
+
+ class ShapeContext(ParserRuleContext):
+
+ def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1):
+ super().__init__(parent, invokingState)
+ self.parser = parser
+
+
+ def getRuleIndex(self):
+ return RelayParser.RULE_shape
+
+
+ def copyFrom(self, ctx:ParserRuleContext):
+ super().copyFrom(ctx)
+
+
+
+ class ParensShapeContext(ShapeContext):
+
+ def __init__(self, parser, ctx:ParserRuleContext): # actually a RelayParser.ShapeContext
+ super().__init__(parser)
+ self.copyFrom(ctx)
+
+ def shape(self):
+ return self.getTypedRuleContext(RelayParser.ShapeContext,0)
+
+
+ def accept(self, visitor:ParseTreeVisitor):
+ if hasattr( visitor, "visitParensShape" ):
+ return visitor.visitParensShape(self)
+ else:
+ return visitor.visitChildren(self)
+
+
+ class IntShapeContext(ShapeContext):
+
+ def __init__(self, parser, ctx:ParserRuleContext): # actually a RelayParser.ShapeContext
+ super().__init__(parser)
+ self.copyFrom(ctx)
+
+ def NAT(self):
+ return self.getToken(RelayParser.NAT, 0)
+
+ def accept(self, visitor:ParseTreeVisitor):
+ if hasattr( visitor, "visitIntShape" ):
+ return visitor.visitIntShape(self)
+ else:
+ return visitor.visitChildren(self)
+
+
+
+ def shape(self):
+
+ localctx = RelayParser.ShapeContext(self, self._ctx, self.state)
+ self.enterRule(localctx, 26, self.RULE_shape)
+ try:
+ self.state = 310
+ self._errHandler.sync(self)
+ token = self._input.LA(1)
+ if token in [RelayParser.T__0]:
+ localctx = RelayParser.ParensShapeContext(self, localctx)
+ self.enterOuterAlt(localctx, 1)
+ self.state = 305
+ self.match(RelayParser.T__0)
+ self.state = 306
+ self.shape()
+ self.state = 307
+ self.match(RelayParser.T__1)
+ pass
+ elif token in [RelayParser.NAT]:
+ localctx = RelayParser.IntShapeContext(self, localctx)
+ self.enterOuterAlt(localctx, 2)
+ self.state = 309
+ self.match(RelayParser.NAT)
+ pass
+ else:
+ raise NoViableAltException(self)
+
+ except RecognitionException as re:
+ localctx.exception = re
+ self._errHandler.reportError(self, re)
+ self._errHandler.recover(self, re)
+ finally:
+ self.exitRule()
+ return localctx
+
+
+ class TypeIdentContext(ParserRuleContext):
+
+ def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1):
+ super().__init__(parent, invokingState)
+ self.parser = parser
+
+ def CNAME(self):
+ return self.getToken(RelayParser.CNAME, 0)
+
+ def getRuleIndex(self):
+ return RelayParser.RULE_typeIdent
+
+ def accept(self, visitor:ParseTreeVisitor):
+ if hasattr( visitor, "visitTypeIdent" ):
+ return visitor.visitTypeIdent(self)
+ else:
+ return visitor.visitChildren(self)
+
+
+
+
+ def typeIdent(self):
+
+ localctx = RelayParser.TypeIdentContext(self, self._ctx, self.state)
+ self.enterRule(localctx, 28, self.RULE_typeIdent)
+ try:
+ self.enterOuterAlt(localctx, 1)
+ self.state = 312
+ self.match(RelayParser.CNAME)
+ except RecognitionException as re:
+ localctx.exception = re
+ self._errHandler.reportError(self, re)
+ self._errHandler.recover(self, re)
+ finally:
+ self.exitRule()
+ return localctx
+
+
+ class BodyContext(ParserRuleContext):
+
+ def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1):
+ super().__init__(parent, invokingState)
+ self.parser = parser
+
+ def expr(self):
+ return self.getTypedRuleContext(RelayParser.ExprContext,0)
+
+
+ def getRuleIndex(self):
+ return RelayParser.RULE_body
+
+ def accept(self, visitor:ParseTreeVisitor):
+ if hasattr( visitor, "visitBody" ):
+ return visitor.visitBody(self)
+ else:
+ return visitor.visitChildren(self)
+
+
+
+
+ def body(self):
+
+ localctx = RelayParser.BodyContext(self, self._ctx, self.state)
+ self.enterRule(localctx, 30, self.RULE_body)
+ try:
+ self.enterOuterAlt(localctx, 1)
+ self.state = 314
+ self.match(RelayParser.T__10)
+ self.state = 315
+ self.expr(0)
+ self.state = 316
+ self.match(RelayParser.T__11)
+ except RecognitionException as re:
+ localctx.exception = re
+ self._errHandler.reportError(self, re)
+ self._errHandler.recover(self, re)
+ finally:
+ self.exitRule()
+ return localctx
+
+
+ class ScalarContext(ParserRuleContext):
+
+ def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1):
+ super().__init__(parent, invokingState)
+ self.parser = parser
+
+
+ def getRuleIndex(self):
+ return RelayParser.RULE_scalar
+
+
+ def copyFrom(self, ctx:ParserRuleContext):
+ super().copyFrom(ctx)
+
+
+
+ class ScalarFloatContext(ScalarContext):
+
+ def __init__(self, parser, ctx:ParserRuleContext): # actually a RelayParser.ScalarContext
+ super().__init__(parser)
+ self.copyFrom(ctx)
+
+ def FLOAT(self):
+ return self.getToken(RelayParser.FLOAT, 0)
+
+ def accept(self, visitor:ParseTreeVisitor):
+ if hasattr( visitor, "visitScalarFloat" ):
+ return visitor.visitScalarFloat(self)
+ else:
+ return visitor.visitChildren(self)
+
+
+ class ScalarBoolContext(ScalarContext):
+
+ def __init__(self, parser, ctx:ParserRuleContext): # actually a RelayParser.ScalarContext
+ super().__init__(parser)
+ self.copyFrom(ctx)
+
+ def BOOL_LIT(self):
+ return self.getToken(RelayParser.BOOL_LIT, 0)
+
+ def accept(self, visitor:ParseTreeVisitor):
+ if hasattr( visitor, "visitScalarBool" ):
+ return visitor.visitScalarBool(self)
+ else:
+ return visitor.visitChildren(self)
+
+
+ class ScalarIntContext(ScalarContext):
+
+ def __init__(self, parser, ctx:ParserRuleContext): # actually a RelayParser.ScalarContext
+ super().__init__(parser)
+ self.copyFrom(ctx)
+
+ def NAT(self):
+ return self.getToken(RelayParser.NAT, 0)
+
+ def accept(self, visitor:ParseTreeVisitor):
+ if hasattr( visitor, "visitScalarInt" ):
+ return visitor.visitScalarInt(self)
+ else:
+ return visitor.visitChildren(self)
+
+
+
+ def scalar(self):
+
+ localctx = RelayParser.ScalarContext(self, self._ctx, self.state)
+ self.enterRule(localctx, 32, self.RULE_scalar)
+ try:
+ self.state = 321
+ self._errHandler.sync(self)
+ token = self._input.LA(1)
+ if token in [RelayParser.FLOAT]:
+ localctx = RelayParser.ScalarFloatContext(self, localctx)
+ self.enterOuterAlt(localctx, 1)
+ self.state = 318
+ self.match(RelayParser.FLOAT)
+ pass
+ elif token in [RelayParser.NAT]:
+ localctx = RelayParser.ScalarIntContext(self, localctx)
+ self.enterOuterAlt(localctx, 2)
+ self.state = 319
+ self.match(RelayParser.NAT)
+ pass
+ elif token in [RelayParser.BOOL_LIT]:
+ localctx = RelayParser.ScalarBoolContext(self, localctx)
+ self.enterOuterAlt(localctx, 3)
+ self.state = 320
+ self.match(RelayParser.BOOL_LIT)
+ pass
+ else:
+ raise NoViableAltException(self)
+
+ except RecognitionException as re:
+ localctx.exception = re
+ self._errHandler.reportError(self, re)
+ self._errHandler.recover(self, re)
+ finally:
+ self.exitRule()
+ return localctx
+
+
+ class IdentContext(ParserRuleContext):
+
+ def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1):
+ super().__init__(parent, invokingState)
+ self.parser = parser
+
+ def opIdent(self):
+ return self.getTypedRuleContext(RelayParser.OpIdentContext,0)
+
+
+ def GLOBAL_VAR(self):
+ return self.getToken(RelayParser.GLOBAL_VAR, 0)
+
+ def LOCAL_VAR(self):
+ return self.getToken(RelayParser.LOCAL_VAR, 0)
+
+ def GRAPH_VAR(self):
+ return self.getToken(RelayParser.GRAPH_VAR, 0)
+
+ def getRuleIndex(self):
+ return RelayParser.RULE_ident
+
+ def accept(self, visitor:ParseTreeVisitor):
+ if hasattr( visitor, "visitIdent" ):
+ return visitor.visitIdent(self)
+ else:
+ return visitor.visitChildren(self)
+
+
+
+
+ def ident(self):
+
+ localctx = RelayParser.IdentContext(self, self._ctx, self.state)
+ self.enterRule(localctx, 34, self.RULE_ident)
+ try:
+ self.state = 327
+ self._errHandler.sync(self)
+ token = self._input.LA(1)
+ if token in [RelayParser.CNAME]:
+ self.enterOuterAlt(localctx, 1)
+ self.state = 323
+ self.opIdent()
+ pass
+ elif token in [RelayParser.GLOBAL_VAR]:
+ self.enterOuterAlt(localctx, 2)
+ self.state = 324
+ self.match(RelayParser.GLOBAL_VAR)
+ pass
+ elif token in [RelayParser.LOCAL_VAR]:
+ self.enterOuterAlt(localctx, 3)
+ self.state = 325
+ self.match(RelayParser.LOCAL_VAR)
+ pass
+ elif token in [RelayParser.GRAPH_VAR]:
+ self.enterOuterAlt(localctx, 4)
+ self.state = 326
+ self.match(RelayParser.GRAPH_VAR)
+ pass
+ else:
+ raise NoViableAltException(self)
+
+ except RecognitionException as re:
+ localctx.exception = re
+ self._errHandler.reportError(self, re)
+ self._errHandler.recover(self, re)
+ finally:
+ self.exitRule()
+ return localctx
+
+
+
+ def sempred(self, localctx:RuleContext, ruleIndex:int, predIndex:int):
+ if self._predicates == None:
+ self._predicates = dict()
+ self._predicates[2] = self.expr_sempred
+ pred = self._predicates.get(ruleIndex, None)
+ if pred is None:
+ raise Exception("No predicate with index:" + str(ruleIndex))
+ else:
+ return pred(localctx, predIndex)
+
+ def expr_sempred(self, localctx:ExprContext, predIndex:int):
+ if predIndex == 0:
+ return self.precpred(self._ctx, 16)
+
+
+ if predIndex == 1:
+ return self.precpred(self._ctx, 15)
+
+
+ if predIndex == 2:
+ return self.precpred(self._ctx, 14)
+
+
+ if predIndex == 3:
+ return self.precpred(self._ctx, 13)
+
+
+ if predIndex == 4:
+ return self.precpred(self._ctx, 4)
+
+
+ if predIndex == 5:
+ return self.precpred(self._ctx, 18)
+
+
+
+
+
--- /dev/null
+# Generated from /home/sslyu/tvm/python/tvm/relay/grammar/Relay.g4 by ANTLR 4.7.2
+from antlr4 import *
+if __name__ is not None and "." in __name__:
+ from .RelayParser import RelayParser
+else:
+ from RelayParser import RelayParser
+
+# This class defines a complete generic visitor for a parse tree produced by RelayParser.
+
+class RelayVisitor(ParseTreeVisitor):
+
+ # Visit a parse tree produced by RelayParser#opIdent.
+ def visitOpIdent(self, ctx:RelayParser.OpIdentContext):
+ return self.visitChildren(ctx)
+
+
+ # Visit a parse tree produced by RelayParser#prog.
+ def visitProg(self, ctx:RelayParser.ProgContext):
+ return self.visitChildren(ctx)
+
+
+ # Visit a parse tree produced by RelayParser#identExpr.
+ def visitIdentExpr(self, ctx:RelayParser.IdentExprContext):
+ return self.visitChildren(ctx)
+
+
+ # Visit a parse tree produced by RelayParser#call.
+ def visitCall(self, ctx:RelayParser.CallContext):
+ return self.visitChildren(ctx)
+
+
+ # Visit a parse tree produced by RelayParser#neg.
+ def visitNeg(self, ctx:RelayParser.NegContext):
+ return self.visitChildren(ctx)
+
+
+ # Visit a parse tree produced by RelayParser#tuple.
+ def visitTuple(self, ctx:RelayParser.TupleContext):
+ return self.visitChildren(ctx)
+
+
+ # Visit a parse tree produced by RelayParser#parens.
+ def visitParens(self, ctx:RelayParser.ParensContext):
+ return self.visitChildren(ctx)
+
+
+ # Visit a parse tree produced by RelayParser#funcExpr.
+ def visitFuncExpr(self, ctx:RelayParser.FuncExprContext):
+ return self.visitChildren(ctx)
+
+
+ # Visit a parse tree produced by RelayParser#scalarExpr.
+ def visitScalarExpr(self, ctx:RelayParser.ScalarExprContext):
+ return self.visitChildren(ctx)
+
+
+ # Visit a parse tree produced by RelayParser#let.
+ def visitLet(self, ctx:RelayParser.LetContext):
+ return self.visitChildren(ctx)
+
+
+ # Visit a parse tree produced by RelayParser#tensor.
+ def visitTensor(self, ctx:RelayParser.TensorContext):
+ return self.visitChildren(ctx)
+
+
+ # Visit a parse tree produced by RelayParser#ifElse.
+ def visitIfElse(self, ctx:RelayParser.IfElseContext):
+ return self.visitChildren(ctx)
+
+
+ # Visit a parse tree produced by RelayParser#graph.
+ def visitGraph(self, ctx:RelayParser.GraphContext):
+ return self.visitChildren(ctx)
+
+
+ # Visit a parse tree produced by RelayParser#binOp.
+ def visitBinOp(self, ctx:RelayParser.BinOpContext):
+ return self.visitChildren(ctx)
+
+
+ # Visit a parse tree produced by RelayParser#func.
+ def visitFunc(self, ctx:RelayParser.FuncContext):
+ return self.visitChildren(ctx)
+
+
+ # Visit a parse tree produced by RelayParser#defn.
+ def visitDefn(self, ctx:RelayParser.DefnContext):
+ return self.visitChildren(ctx)
+
+
+ # Visit a parse tree produced by RelayParser#argList.
+ def visitArgList(self, ctx:RelayParser.ArgListContext):
+ return self.visitChildren(ctx)
+
+
+ # Visit a parse tree produced by RelayParser#varList.
+ def visitVarList(self, ctx:RelayParser.VarListContext):
+ return self.visitChildren(ctx)
+
+
+ # Visit a parse tree produced by RelayParser#var.
+ def visitVar(self, ctx:RelayParser.VarContext):
+ return self.visitChildren(ctx)
+
+
+ # Visit a parse tree produced by RelayParser#attrList.
+ def visitAttrList(self, ctx:RelayParser.AttrListContext):
+ return self.visitChildren(ctx)
+
+
+ # Visit a parse tree produced by RelayParser#attr.
+ def visitAttr(self, ctx:RelayParser.AttrContext):
+ return self.visitChildren(ctx)
+
+
+ # Visit a parse tree produced by RelayParser#typeParamSeq.
+ def visitTypeParamSeq(self, ctx:RelayParser.TypeParamSeqContext):
+ return self.visitChildren(ctx)
+
+
+ # Visit a parse tree produced by RelayParser#tupleType.
+ def visitTupleType(self, ctx:RelayParser.TupleTypeContext):
+ return self.visitChildren(ctx)
+
+
+ # Visit a parse tree produced by RelayParser#typeIdentType.
+ def visitTypeIdentType(self, ctx:RelayParser.TypeIdentTypeContext):
+ return self.visitChildren(ctx)
+
+
+ # Visit a parse tree produced by RelayParser#tensorType.
+ def visitTensorType(self, ctx:RelayParser.TensorTypeContext):
+ return self.visitChildren(ctx)
+
+
+ # Visit a parse tree produced by RelayParser#funcType.
+ def visitFuncType(self, ctx:RelayParser.FuncTypeContext):
+ return self.visitChildren(ctx)
+
+
+ # Visit a parse tree produced by RelayParser#incompleteType.
+ def visitIncompleteType(self, ctx:RelayParser.IncompleteTypeContext):
+ return self.visitChildren(ctx)
+
+
+ # Visit a parse tree produced by RelayParser#intType.
+ def visitIntType(self, ctx:RelayParser.IntTypeContext):
+ return self.visitChildren(ctx)
+
+
+ # Visit a parse tree produced by RelayParser#shapeSeq.
+ def visitShapeSeq(self, ctx:RelayParser.ShapeSeqContext):
+ return self.visitChildren(ctx)
+
+
+ # Visit a parse tree produced by RelayParser#parensShape.
+ def visitParensShape(self, ctx:RelayParser.ParensShapeContext):
+ return self.visitChildren(ctx)
+
+
+ # Visit a parse tree produced by RelayParser#intShape.
+ def visitIntShape(self, ctx:RelayParser.IntShapeContext):
+ return self.visitChildren(ctx)
+
+
+ # Visit a parse tree produced by RelayParser#typeIdent.
+ def visitTypeIdent(self, ctx:RelayParser.TypeIdentContext):
+ return self.visitChildren(ctx)
+
+
+ # Visit a parse tree produced by RelayParser#body.
+ def visitBody(self, ctx:RelayParser.BodyContext):
+ return self.visitChildren(ctx)
+
+
+ # Visit a parse tree produced by RelayParser#scalarFloat.
+ def visitScalarFloat(self, ctx:RelayParser.ScalarFloatContext):
+ return self.visitChildren(ctx)
+
+
+ # Visit a parse tree produced by RelayParser#scalarInt.
+ def visitScalarInt(self, ctx:RelayParser.ScalarIntContext):
+ return self.visitChildren(ctx)
+
+
+ # Visit a parse tree produced by RelayParser#scalarBool.
+ def visitScalarBool(self, ctx:RelayParser.ScalarBoolContext):
+ return self.visitChildren(ctx)
+
+
+ # Visit a parse tree produced by RelayParser#ident.
+ def visitIdent(self, ctx:RelayParser.IdentContext):
+ return self.visitChildren(ctx)
+
+
+
+del RelayParser
\ No newline at end of file
from __future__ import absolute_import
from .. import register_func
-def enabled():
- """Checks whether the parser is enabled, this allows users to
- optionally support building the parser.
-
- We use this check before importing the parser.
- """
- try:
- # pylint: disable=unused-variable
- from tvm.relay import _parser
- return True
- # pylint: disable=broad-except
- except Exception:
- return False
@register_func("relay.fromtext")
def fromtext(data, source_name=None):
# specific language governing permissions and limitations
# under the License.
# pylint: disable=no-else-return, unidiomatic-typecheck, invalid-name
-"""Adds certain standard global functions and ADT definitions to the module."""
+"""A prelude containing useful global functions and ADT definitions."""
+import os
from .ty import GlobalTypeVar, TypeVar, FuncType, TupleType, scalar_type
from .expr import Var, Function, GlobalVar, Let, If, Tuple, TupleGetItem, const
from .op.tensor import add, subtract, equal
from .adt import Constructor, TypeData, Clause, Match
from .adt import PatternConstructor, PatternVar, PatternWildcard
+from .parser import fromtext
+
+__PRELUDE_PATH__ = os.path.dirname(os.path.realpath(__file__))
class Prelude:
"""Contains standard definitions."""
Match(t, [rose_case]), scalar_type('int32'), [a])
- def define_id(self):
- """Defines a function that return its argument.
-
- Signature: fn<a>(x : a) -> a
- """
- self.id = GlobalVar("id")
- a = TypeVar("a")
- x = Var("x", a)
- self.mod[self.id] = Function([x], x, a, [a])
-
-
- def define_compose(self):
- """Defines a function that composes two function.
-
- Signature: fn<a, b, c>(f : fn(b) -> c, g : fn(a) -> b) -> fn(a) -> c
- """
- self.compose = GlobalVar("compose")
- a = TypeVar("a")
- b = TypeVar("b")
- c = TypeVar("c")
- f = Var("f", FuncType([b], c))
- g = Var("g", FuncType([a], b))
- x = Var("x")
- self.mod[self.compose] = Function([f, g],
- Function([x], f(g(x))),
- FuncType([a], c),
- [a, b, c])
-
-
def define_iterate(self):
"""Defines a function that take a number n and a function f;
returns a closure that takes an argument and applies f
FuncType([a], a),
[a])
+ def load_prelude(self):
+ """
+ Parses the portions of the Prelude written in Relay's text format and adds
+ them to the module.
+ """
+ prelude_file = os.path.join(__PRELUDE_PATH__, "prelude.rly")
+ with open(prelude_file) as prelude:
+ prelude = fromtext(prelude.read())
+ self.mod.update(prelude)
+ self.id = self.mod["id"]
+ self.compose = self.mod["compose"]
+
def __init__(self, mod):
self.mod = mod
+ self.load_prelude()
+
self.define_list_adt()
self.define_list_hd()
self.define_list_tl()
self.define_tree_map()
self.define_tree_size()
- self.define_id()
- self.define_compose()
self.define_iterate()
--- /dev/null
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+v0.0.2
+
+def @id[a](%x: a) -> a {
+ %x
+}
+
+def @compose[a, b, c](%f: fn(b) -> c, %g: fn(a) -> b) {
+ fn (%x: a) -> c {
+ %f(%g(%x))
+ }
+}
"pxi",
"pyd",
"pyx",
+ # relay text format
+ "rly",
# configurations
"mk",
"in",
"sbt",
"properties",
"v",
+ # generated parser
+ "interp",
+ "tokens"
}
# List of file names allowed
ALLOW_FILE_NAME = {
".gitignore",
+ ".gitattributes",
"README",
"Makefile",
"Doxyfile",
report += "\nFound %d files that are now allowed\n" % len(error_list)
report += ("We do not check in binary files into the repo.\n"
"If necessary, please discuss with committers and"
- "modify tests/scripts/check_file_type.py to enable the file you need.\n")
+ "modify tests/lint/check_file_type.py to enable the file you need.\n")
sys.stderr.write(report)
sys.stderr.flush()
sys.exit(-1)
.*\.csv
.*\.mk
.*\.log
+.*\.interp
+.*\.tokens
# Generated modules
.*\.egg-info
.*~
\#..*\#
+# Relay parser
+RelayLexer.py
+RelayParser.py
+RelayVisitor.py
+
# Specific files
package-list
MANIFEST
.gitignore
+.gitattributes
.gitmodules
.clang-format
.bash_history
# under the License.
import tvm
from tvm import relay
-from tvm.relay.parser import enabled
from tvm.relay.ir_pass import alpha_equal
-from nose import SkipTest
from nose.tools import nottest, raises
from numpy import isclose
from typing import Union
from functools import wraps
-if enabled():
- raises_parse_error = raises(tvm._ffi.base.TVMError)
-else:
- raises_parse_error = lambda x: x
+raises_parse_error = raises(tvm._ffi.base.TVMError)
-SEMVER = "v0.0.1"
+SEMVER = "v0.0.2"
BINARY_OPS = {
"*": relay.multiply,
"float16x4",
}
+def parse_text(code):
+ return relay.fromtext(SEMVER + "\n" + code)
+
def parses_as(code, expr):
# type: (str, relay.Expr) -> bool
- return alpha_equal(relay.fromtext(SEMVER + "\n" + code), expr)
+ return alpha_equal(parse_text(code), expr)
def get_scalar(x):
# type: (relay.Constant) -> (Union[float, int, bool])
UNIT = relay.Tuple([])
-# decorator to determine if parser is enabled
-def if_parser_enabled(func):
- # https://stackoverflow.com/q/7727678
- @wraps(func)
- def wrapper():
- if not enabled():
- raise SkipTest("ANTLR is not installed!")
- func()
- return wrapper
-
-@if_parser_enabled
+
def test_comments():
assert parses_as(
"""
UNIT
)
-@if_parser_enabled
+
def test_int_literal():
- assert isinstance(relay.fromtext(SEMVER+"1"), relay.Constant)
- assert isinstance(relay.fromtext(SEMVER+"1").data, tvm.ndarray.NDArray)
+ assert isinstance(parse_text("1"), relay.Constant)
+ assert isinstance(parse_text("1").data, tvm.ndarray.NDArray)
+
+ assert get_scalar(parse_text("1")) == 1
+ assert get_scalar(parse_text("10")) == 10
+ assert get_scalar(parse_text("0")) == 0
+ assert get_scalar(parse_text("-100")) == -100
+ assert get_scalar(parse_text("-05")) == -5
- assert get_scalar(relay.fromtext(SEMVER+"1")) == 1
- assert get_scalar(relay.fromtext(SEMVER+"10")) == 10
- assert get_scalar(relay.fromtext(SEMVER+"0")) == 0
- assert get_scalar(relay.fromtext(SEMVER+"-100")) == -100
- assert get_scalar(relay.fromtext(SEMVER+"-05")) == -5
-@if_parser_enabled
def test_float_literal():
- assert get_scalar(relay.fromtext(SEMVER+"1.0")) == 1.0
- assert isclose(get_scalar(relay.fromtext(SEMVER+"1.56667")), 1.56667)
- assert get_scalar(relay.fromtext(SEMVER+"0.0")) == 0.0
- assert get_scalar(relay.fromtext(SEMVER+"-10.0")) == -10.0
+ assert get_scalar(parse_text("1.0")) == 1.0
+ assert isclose(get_scalar(parse_text("1.56667")), 1.56667)
+ assert get_scalar(parse_text("0.0")) == 0.0
+ assert get_scalar(parse_text("-10.0")) == -10.0
# scientific notation
- assert isclose(get_scalar(relay.fromtext(SEMVER+"1e-1")), 1e-1)
- assert get_scalar(relay.fromtext(SEMVER+"1e+1")) == 1e+1
- assert isclose(get_scalar(relay.fromtext(SEMVER+"1E-1")), 1E-1)
- assert get_scalar(relay.fromtext(SEMVER+"1E+1")) == 1E+1
- assert isclose(get_scalar(relay.fromtext(SEMVER+"1.0e-1")), 1.0e-1)
- assert get_scalar(relay.fromtext(SEMVER+"1.0e+1")) == 1.0e+1
- assert isclose(get_scalar(relay.fromtext(SEMVER+"1.0E-1")), 1.0E-1)
- assert get_scalar(relay.fromtext(SEMVER+"1.0E+1")) == 1.0E+1
-
-@if_parser_enabled
+ assert isclose(get_scalar(parse_text("1e-1")), 1e-1)
+ assert get_scalar(parse_text("1e+1")) == 1e+1
+ assert isclose(get_scalar(parse_text("1E-1")), 1E-1)
+ assert get_scalar(parse_text("1E+1")) == 1E+1
+ assert isclose(get_scalar(parse_text("1.0e-1")), 1.0e-1)
+ assert get_scalar(parse_text("1.0e+1")) == 1.0e+1
+ assert isclose(get_scalar(parse_text("1.0E-1")), 1.0E-1)
+ assert get_scalar(parse_text("1.0E+1")) == 1.0E+1
+
+
def test_bool_literal():
- assert get_scalar(relay.fromtext(SEMVER+"True")) == True
- assert get_scalar(relay.fromtext(SEMVER+"False")) == False
+ assert get_scalar(parse_text("True")) == True
+ assert get_scalar(parse_text("False")) == False
+
-@if_parser_enabled
def test_negative():
- assert isinstance(relay.fromtext(SEMVER+"let %x = 1; -%x").body, relay.Call)
- assert get_scalar(relay.fromtext(SEMVER+"--10")) == 10
- assert get_scalar(relay.fromtext(SEMVER+"---10")) == -10
+ assert isinstance(parse_text("let %x = 1; -%x").body, relay.Call)
+ assert get_scalar(parse_text("--10")) == 10
+ assert get_scalar(parse_text("---10")) == -10
+
-@if_parser_enabled
def test_bin_op():
for bin_op in BINARY_OPS.keys():
assert parses_as(
BINARY_OPS.get(bin_op)(relay.const(1), relay.const(1))
)
-@if_parser_enabled
+
def test_parens():
- assert alpha_equal(relay.fromtext(SEMVER+"1 * 1 + 1"), relay.fromtext(SEMVER+"(1 * 1) + 1"))
- assert not alpha_equal(relay.fromtext(SEMVER+"1 * 1 + 1"), relay.fromtext(SEMVER+"1 * (1 + 1)"))
+ assert alpha_equal(parse_text("1 * 1 + 1"), parse_text("(1 * 1) + 1"))
+ assert not alpha_equal(parse_text("1 * 1 + 1"), parse_text("1 * (1 + 1)"))
+
-@if_parser_enabled
def test_op_assoc():
- assert alpha_equal(relay.fromtext(SEMVER+"1 * 1 + 1 < 1 == 1"), relay.fromtext(SEMVER+"(((1 * 1) + 1) < 1) == 1"))
- assert alpha_equal(relay.fromtext(SEMVER+"1 == 1 < 1 + 1 * 1"), relay.fromtext(SEMVER+"1 == (1 < (1 + (1 * 1)))"))
+ assert alpha_equal(parse_text("1 * 1 + 1 < 1 == 1"), parse_text("(((1 * 1) + 1) < 1) == 1"))
+ assert alpha_equal(parse_text("1 == 1 < 1 + 1 * 1"), parse_text("1 == (1 < (1 + (1 * 1)))"))
+
@nottest
-@if_parser_enabled
def test_vars():
# temp vars won't work b/c they start with a digit
# # temp var
# assert temp_var.name == "1"
# var
- var = relay.fromtext(SEMVER+"let %foo = (); %foo")
+ var = parse_text("let %foo = (); %foo")
assert isinstance(var.body, relay.Var)
assert var.body.name_hint == "foo"
# global var
- global_var = relay.fromtext(SEMVER+"@foo")
+ global_var = parse_text("@foo")
assert isinstance(global_var, relay.GlobalVar)
assert global_var.name_hint == "foo"
# operator id
- op = relay.fromtext(SEMVER+"foo")
+ op = parse_text("foo")
assert isinstance(op, relay.Op)
assert op.name == "foo"
-@if_parser_enabled
+
def test_let():
assert parses_as(
"let %x = 1; ()",
)
)
-@if_parser_enabled
+
def test_seq():
assert parses_as(
"(); ()",
)
)
-@if_parser_enabled
+
def test_graph():
assert parses_as(
"%0 = (); %1 = 1; (%0, %0, %1)",
relay.Tuple([relay.Tuple([]), relay.Tuple([]), relay.const(1)])
)
+
@raises_parse_error
-@if_parser_enabled
def test_graph_wrong_order():
- relay.fromtext(SEMVER+"%1 = (); %1")
+ parse_text("%1 = (); %1")
+
@raises_parse_error
-@if_parser_enabled
def test_let_global_var():
- relay.fromtext(SEMVER+"let @x = 1; ()")
+ parse_text("let @x = 1; ()")
+
@raises_parse_error
-@if_parser_enabled
def test_let_op():
- relay.fromtext(SEMVER+"let x = 1; ()")
+ parse_text("let x = 1; ()")
+
-@if_parser_enabled
def test_tuple():
assert parses_as("()", relay.Tuple([]))
assert parses_as("(0, 1, 2)", relay.Tuple([relay.const(0), relay.const(1), relay.const(2)]))
-@if_parser_enabled
+
def test_func():
# 0 args
assert parses_as(
relay.Function([], UNIT, None, None, tvm.make.node("DictAttrs", n=relay.const(5)))
)
+
# TODO(@jmp): Crashes if %x isn't annnotated.
-@if_parser_enabled
def test_defn():
id_defn = relay.fromtext(
SEMVER+
""")
assert isinstance(id_defn, relay.Module)
-@if_parser_enabled
+
def test_recursive_call():
id_defn = relay.fromtext(
SEMVER+
""")
assert isinstance(id_defn, relay.Module)
-@if_parser_enabled
+
def test_ifelse():
assert parses_as(
"""
)
)
+
@raises_parse_error
-@if_parser_enabled
def test_ifelse_scope():
relay.fromtext(
SEMVER+
"""
)
-@if_parser_enabled
+
def test_call():
# select right function to call: simple ident case
id_func = relay.Var("id")
# Types
-@if_parser_enabled
+
def test_incomplete_type():
assert parses_as(
"let %_ : _ = (); ()",
)
)
-@if_parser_enabled
+
def test_builtin_types():
for builtin_type in TYPES:
- relay.fromtext(SEMVER+"let %_ : {} = (); ()".format(builtin_type))
+ parse_text("let %_ : {} = (); ()".format(builtin_type))
+
@nottest
-@if_parser_enabled
def test_call_type():
assert False
-@if_parser_enabled
+
def test_tensor_type():
assert parses_as(
"let %_ : Tensor[(), float32] = (); ()",
)
)
-@if_parser_enabled
+
def test_function_type():
assert parses_as(
"""
)
)
-@if_parser_enabled
+
def test_tuple_type():
assert parses_as(
"""