示例#1
0
文件: grammar.py 项目: weisserw/itte
def rune_lit():        return _, [r(r"r'(\\[^\n]|[^\\\"\n])*'"), r('r"(\\[^\n]|[^\\\'\n])*"')]
def string_lit():      return _, [single_string, double_string, raw_string]
示例#2
0
文件: grammar.py 项目: weisserw/itte
def GotoStmt():        return _, r(r'\bgoto\b'), ident
def FallStmt():        return _, r(r'\bfallthrough\b')
示例#3
0
文件: grammar.py 项目: weisserw/itte
def IfStmt():          return _, r(r'\bif\b'), Optional(SimpleStmt, _, ';'), Expression, Block, ZeroOrMore(_, r(r'\belse\b'), _, r(r'\bif\b'), Expression, Block), Optional(_, r(r'\belse\b'), Block)
def SwitchStmt():      return _, r(r'\bswitch\b'), Optional(SimpleStmt, _, ';'), [ExprSwitchStmt, TypeSwitchStmt]
示例#4
0
文件: grammar.py 项目: weisserw/itte
def GoStmt():          return _, r(r'\bgo\b'), Expression
def ReturnStmt():      return _, r(r'\breturn\b'), Optional(ExpressionList)
示例#5
0
文件: grammar.py 项目: weisserw/itte
def BreakStmt():       return _, r(r'\bbreak\b'), Optional(ident)
def ContinueStmt():    return _, r(r'\bcontinue\b'), Optional(ident)
示例#6
0
文件: grammar.py 项目: weisserw/itte
def ChannelType():     return _, r('<-?'), Type, _, r('-?>')
def FunctionLit():     return _, r(r'\bfunc\b'), Function
示例#7
0
文件: grammar.py 项目: weisserw/itte
def TypeAssertion():   return _, r(r'\bas\b'), Type

# statements
def Block():           return _, '{', Optional(StatementList), _, '}'
示例#8
0
文件: grammar.py 项目: weisserw/itte
def ImportDecl():      return _, r(r'\bimport\b'), ImportSpec, ZeroOrMore(_, ',', ImportSpec), Optional(_, ',')
def ImportSpec():      return _, r(import_re), Optional(_, r(r'\bas\b'), ident)
示例#9
0
文件: grammar.py 项目: weisserw/itte
def ImportSpec():      return _, r(import_re), Optional(_, r(r'\bas\b'), ident)
def TopLevelDecls():   return TopLevelDecl, ZeroOrMore(nl, TopLevelDecl), Optional(nl)
示例#10
0
文件: grammar.py 项目: weisserw/itte
def NotKeyword():     return _, Not(r(r'\b(as|break|case|const|continue|default|defer|else|fallthrough|for|while|func|go|goto|if|import|interface|return|select|struct|switch|type|var)\b'))
def nl():              return r(r'[ \t\r]*[\n;]')
示例#11
0
文件: grammar.py 项目: weisserw/itte
def nl():              return r(r'[ \t\r]*[\n;]')
def _():               return r(r'[ \t\r\n]*')
示例#12
0
文件: grammar.py 项目: weisserw/itte
def raw_string():      return r("`[^`]*`")
def ident():           return NotKeyword, r(id_re)
示例#13
0
文件: grammar.py 项目: weisserw/itte
def double_string():   return r(r'\$?"(\\[^\n]|[^\\\'\n])*"')
def raw_string():      return r("`[^`]*`")
示例#14
0
文件: grammar.py 项目: weisserw/itte
def single_string():   return r(r"\$?'(\\[^\n]|[^\\\"\n])*'")
def double_string():   return r(r'\$?"(\\[^\n]|[^\\\'\n])*"')
示例#15
0
文件: grammar.py 项目: weisserw/itte
def FunctionType():    return _, r(r'\bfunc\b'), Signature
def Signature():       return _, '(', ParameterList, _, ')', Optional(Result)
示例#16
0
文件: grammar.py 项目: weisserw/itte
def ConstDecl():       return _, r(r'\bconst\b'), IdentifierList, _, '=', ExpressionList
def IdentifierList():  return ident, ZeroOrMore(_, ',', ident), Optional(_, ',')
示例#17
0
文件: grammar.py 项目: weisserw/itte
def InterfaceType():   return _, r(r'\binterface\b'), InterfaceBody
def InterfaceBody():   return _, '{', Optional(MethodSpec, ZeroOrMore(nl, MethodSpec), Optional(nl)), _, '}'
示例#18
0
文件: grammar.py 项目: weisserw/itte
def TypeDecl():        return _, r(r'\btype\b'), TypeSpec, ZeroOrMore(_, ',', TypeSpec), Optional(_, ',')
def TypeSpec():        return Type, ident
示例#19
0
文件: grammar.py 项目: weisserw/itte
def FunctionLit():     return _, r(r'\bfunc\b'), Function
def Function():        return _, Signature, Block
示例#20
0
文件: grammar.py 项目: weisserw/itte
def FunctionDecl():    return _, r(r'\bfunc\b'), ident, [Function, Signature]
def MethodDecl():      return _, r(r'\bfunc\b'), Receiver, ident, [Function, Signature]
示例#21
0
文件: grammar.py 项目: weisserw/itte
def ShortVarDecl():    return _, r(r'\bvar\b'), IdentifierList, _, '=', ExpressionList   
def GoStmt():          return _, r(r'\bgo\b'), Expression
示例#22
0
文件: grammar.py 项目: weisserw/itte
def MethodDecl():      return _, r(r'\bfunc\b'), Receiver, ident, [Function, Signature]
def Receiver():        return _, '(', Type, Optional(ident), _, ')'
示例#23
0
文件: grammar.py 项目: weisserw/itte
def ReturnStmt():      return _, r(r'\breturn\b'), Optional(ExpressionList)
def BreakStmt():       return _, r(r'\bbreak\b'), Optional(ident)
示例#24
0
文件: grammar.py 项目: weisserw/itte
def StructDecl():      return _, r(r'\bstruct\b'), ident, StructBody
def InterfaceDecl():   return _, r(r'\binterface\b'), ident, InterfaceBody
示例#25
0
文件: grammar.py 项目: weisserw/itte
def ContinueStmt():    return _, r(r'\bcontinue\b'), Optional(ident)
def GotoStmt():        return _, r(r'\bgoto\b'), ident
示例#26
0
文件: grammar.py 项目: weisserw/itte
def InterfaceDecl():   return _, r(r'\binterface\b'), ident, InterfaceBody

# expressions
def Expression():      return Optional(unary_op), SubExpr, ZeroOrMore(TailExpr)
示例#27
0
文件: grammar.py 项目: weisserw/itte
def FallStmt():        return _, r(r'\bfallthrough\b')
def IfStmt():          return _, r(r'\bif\b'), Optional(SimpleStmt, _, ';'), Expression, Block, ZeroOrMore(_, r(r'\belse\b'), _, r(r'\bif\b'), Expression, Block), Optional(_, r(r'\belse\b'), Block)
示例#28
0
文件: grammar.py 项目: weisserw/itte
def StructType():      return _, r(r'\bstruct\b'), StructBody
def StructBody():      return _, '{', Optional(FieldDecl, ZeroOrMore(nl, FieldDecl), Optional(nl)), _, '}'
示例#29
0
文件: grammar.py 项目: weisserw/itte
def SwitchStmt():      return _, r(r'\bswitch\b'), Optional(SimpleStmt, _, ';'), [ExprSwitchStmt, TypeSwitchStmt]
def ExprSwitchStmt():  return Optional(Expression), _, '{', ZeroOrMore(ExprCaseClause), _, '}'
示例#30
0
文件: grammar.py 项目: weisserw/itte
def imaginary_lit():   return _, [float_lit, r('[0-9]+')], 'i'
def rune_lit():        return _, [r(r"r'(\\[^\n]|[^\\\"\n])*'"), r('r"(\\[^\n]|[^\\\'\n])*"')]