Skip to content

Instantly share code, notes, and snippets.

@exerro
Created June 19, 2016 00:03
Show Gist options
  • Save exerro/b34887f58d05f4f3f749e9de45b6e578 to your computer and use it in GitHub Desktop.
Save exerro/b34887f58d05f4f3f749e9de45b6e578 to your computer and use it in GitHub Desktop.
Position: { "source" = string, "line" = number, "character" = number, "strline" = string }
HasPosition: { "position" = Position }
ConstantExpressionType: "CharacterConstant" | "StringConstant" | "FloatConstant" | "IntegerConstant" | "ByteConstant" | "HexadecimalConstant" | "BinaryConstant"
ConstantExpression: { "type" = ConstantExpressionType, "value" = string } & HasPosition
ThrowExpression: { "type" = "ThrowExpression", "value" = Expression } & HasPosition
FunctionExpression: { "type" = "FunctionExpression", "returns" = Type | nil, "parameters" = { number = { "name" = string, "class" = Type } } | {}, "body" = Block | nil } & HasPosition
BracketExpression: { "type" = "BracketExpression", "value" = Expression }
TableExpression: { "type" = "TableExpression", "value" = { number = { "index" = Expression, "value" = Expression } } | {} } & HasPosition
ArrayExpression: { "type" = "ArrayExpression", "value" = { number = Expression } | {} } & HasPosition
Reference: { "type" = "Reference", "name" = string } & HasPosition
PrimaryExpression: ConstantExpression | ThrowExpression | FunctionExpression | BracketExpression | TableExpression | ArrayExpression
LeftUnaryOperator: "++" | "--" | "-" | "~" | "#" | "!"
RightUnaryOperator: "++" | "--"
FunctionCall: { "type" = "FunctionCall", "value" = Expression, "parameters" = { number = Expression } | {} } & HasPosition
MethodCall: { "type" = "MethodCall", "value" = Expression, "name" = string, "parameters" = { number = Expression } | {} } & HasPosition
Index: { "type" = "Index", "value" = Expression, "index" = { number = Expression } } & HasPosition
DotIndex: { "type" = "DotIndex", "value" = Expression, "index" = string } & HasPosition
Cast: { "type" = "Cast", "lvalue" = Expression, "rvalue" = Expression } & HasPosition
OperatorImplements: { "type" = "OperatorImplements", "lvalue" = Expression, "rvalue" = Expression } & HasPosition
OperatorTypeOf: { "type" = "OperatorTypeOf", "lvalue" = Expression | nil, "rvalue" = Expression } & HasPosition
OperatorExtends: { "type" = "OperatorExtends", "lvalue" = Expression, "rvalue" = Expression } & HasPosition
RightUnaryExpression: { "type" = "RightUnaryExpression", "value" = Expression, "operator" = RightUnaryOperator } & HasPosition
LeftUnaryExpression: { "type" = "LeftUnaryExpression", "value" = Expression, "operator" = LeftUnaryOperator } & HasPosition
UnaryExpression:
LeftUnaryExpression | RightUnaryExpression
| FunctionCall | MethodCall
| Index | DotIndex
| Cast
| OperatorImplements | OperatorTypeOf | OperatorExtends
BinaryOperator:
"+" | "-" | "*" | "/" | "%" | "**"
| "&" | "|" | "^" | "<<" | ">>"
| "==" | "!=" | "<" | ">" | "<=" | ">="
| "||" | "&&"
| ".."
| "=" | "+=" | "-=" | "*=" | "/=" | "%=" | "**=" | "&=" | "|=" | "^=" | "<<=" | ">>="
| "and" | "or"
BinaryExpression:
{ "type" = "BinaryExpression", "lvalue" = Expression, "rvalue" = Expression, "operator" = BinaryOperator } & HasPosition
| { "type" = "BinaryExpressionCall", "lvalue" = Expression | nil, "rvalue" = Expression | nil, "operator" = string } & HasPosition
Expression: PrimaryExpression | BinaryExpression | UnaryExpression
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment