-
Notifications
You must be signed in to change notification settings - Fork 548
GoPlus Syntax Spec
xushiwei edited this page Jun 18, 2022
·
7 revisions
Operand =
Ident | BasicLit |
ParenExpr |
FuncType | FuncLit |
CompositeLit | ComprehensionExpr |
ArrayType | SliceLit |
StructType | PointerType | InterfaceType | MapType | ChanType
ParenExpr =
'(' Expr ')'
PrimaryExpr =
Operand *primaryExprSuffix
primaryExprSuffix =
selectorExprSuffix | typeAssertExprSuffix |
sliceExprSuffix | indexExprSuffix |
callExprSuffix | commandExprSuffix |
compositeLitSuffix |
errWrapExprSuffix
selectorExprSuffix = '.' Ident
typeAssertExprSuffix = '.' '(' Type ')'
sliceExprSuffix = '[' ... ']'
indexExprSuffix = '[' ... ']'
callExprSuffix = '(' Args ')'
commandExprSuffix = Args
compositeLitSuffix = '{' Elements '}'
errWrapExprSuffix = '!' | '?'
ErrWrapExpr =
PrimaryExpr ?("?:" UnaryExpr)
UnaryExpr =
('+' | '-' | '!' | '^' | '&' | "<-") UnaryExpr |
StarExpr |
ErrWrapExpr
StarExpr = '*' UnaryExpr
BinaryExpr =
UnaryExpr BinaryOp BinaryExpr
RangeExpr =
?BinaryExpr ':' BinaryExpr ?(':' BinaryExpr)
LambdaExpr =
?(Ident | tupleExpr) "=>" lambdaExprBody
tupleExpr =
'(' Idents ')'
lambdaExprBody =
'(' Exprs ')' |
'{' ... '}' |
Expr
Expr =
BinaryExpr | RangeExpr | LambdaExpr