mirror of
https://github.com/luau-lang/luau.git
synced 2024-12-13 21:40:43 +00:00
d01addc625
Co-authored-by: Rodactor <rodactor@roblox.com>
342 lines
5.6 KiB
Protocol Buffer
342 lines
5.6 KiB
Protocol Buffer
// This file is part of the Luau programming language and is licensed under MIT License; see LICENSE.txt for details
|
|
syntax = "proto2";
|
|
package luau;
|
|
|
|
message Expr {
|
|
oneof expr_oneof {
|
|
ExprGroup group = 1;
|
|
ExprConstantNil nil = 2;
|
|
ExprConstantBool bool = 3;
|
|
ExprConstantNumber number = 4;
|
|
ExprConstantString string = 5;
|
|
ExprLocal local = 6;
|
|
ExprGlobal global = 7;
|
|
ExprVarargs varargs = 8;
|
|
ExprCall call = 9;
|
|
ExprIndexName index_name = 10;
|
|
ExprIndexExpr index_expr = 11;
|
|
ExprFunction function = 12;
|
|
ExprTable table = 13;
|
|
ExprUnary unary = 14;
|
|
ExprBinary binary = 15;
|
|
}
|
|
}
|
|
|
|
message ExprPrefix {
|
|
oneof expr_oneof {
|
|
ExprGroup group = 1;
|
|
ExprLocal local = 2;
|
|
ExprGlobal global = 3;
|
|
ExprCall call = 4;
|
|
ExprIndexName index_name = 5;
|
|
ExprIndexExpr index_expr = 6;
|
|
}
|
|
}
|
|
|
|
message Local {
|
|
required int32 name = 1;
|
|
}
|
|
|
|
message Typename {
|
|
required int32 index = 1;
|
|
}
|
|
|
|
message Name {
|
|
oneof name_oneof {
|
|
int32 builtin = 1;
|
|
int32 custom = 2;
|
|
}
|
|
}
|
|
|
|
message ExprGroup {
|
|
required Expr expr = 1;
|
|
}
|
|
|
|
message ExprConstantNil {
|
|
}
|
|
|
|
message ExprConstantBool {
|
|
required bool val = 1;
|
|
}
|
|
|
|
message ExprConstantNumber {
|
|
required int32 val = 1;
|
|
}
|
|
|
|
message ExprConstantString {
|
|
required string val = 1;
|
|
}
|
|
|
|
message ExprLocal {
|
|
required Local var = 1;
|
|
}
|
|
|
|
message ExprGlobal {
|
|
required Name name = 1;
|
|
}
|
|
|
|
message ExprVarargs {
|
|
}
|
|
|
|
message ExprCall {
|
|
required ExprPrefix func = 1;
|
|
required bool self = 2;
|
|
repeated Expr args = 3;
|
|
}
|
|
|
|
message ExprIndexName {
|
|
required ExprPrefix expr = 1;
|
|
required Name index = 2;
|
|
}
|
|
|
|
message ExprIndexExpr {
|
|
required ExprPrefix expr = 1;
|
|
required Expr index = 2;
|
|
}
|
|
|
|
message ExprFunction {
|
|
repeated Local args = 1;
|
|
required bool vararg = 2;
|
|
required StatBlock body = 3;
|
|
repeated Type types = 4;
|
|
repeated Type rettypes = 5;
|
|
}
|
|
|
|
message TableItem {
|
|
oneof item_oneof {
|
|
Name key_name = 1;
|
|
Expr key_expr = 2;
|
|
}
|
|
required Expr value = 3;
|
|
}
|
|
|
|
message ExprTable {
|
|
repeated TableItem items = 1;
|
|
}
|
|
|
|
message ExprUnary {
|
|
enum Op {
|
|
Not = 0;
|
|
Minus = 1;
|
|
Len = 2;
|
|
}
|
|
|
|
required Op op = 1;
|
|
required Expr expr = 2;
|
|
}
|
|
|
|
message ExprBinary {
|
|
enum Op {
|
|
Add = 0;
|
|
Sub = 1;
|
|
Mul = 2;
|
|
Div = 3;
|
|
Mod = 4;
|
|
Pow = 5;
|
|
Concat = 6;
|
|
CompareNe = 7;
|
|
CompareEq = 8;
|
|
CompareLt = 9;
|
|
CompareLe = 10;
|
|
CompareGt = 11;
|
|
CompareGe = 12;
|
|
And = 13;
|
|
Or = 14;
|
|
}
|
|
|
|
required Op op = 1;
|
|
required Expr left = 2;
|
|
required Expr right = 3;
|
|
}
|
|
|
|
message LValue {
|
|
oneof lvalue_oneof {
|
|
ExprLocal local = 1;
|
|
ExprGlobal global = 2;
|
|
ExprIndexName index_name = 3;
|
|
ExprIndexExpr index_expr = 4;
|
|
}
|
|
}
|
|
|
|
message Stat {
|
|
oneof stat_oneof {
|
|
StatBlock block = 1;
|
|
StatIf if = 2;
|
|
StatWhile while = 3;
|
|
StatRepeat repeat = 4;
|
|
StatBreak break = 5;
|
|
StatContinue continue = 6;
|
|
StatReturn return = 7;
|
|
StatCall call = 8;
|
|
StatLocal local = 9;
|
|
StatFor for = 10;
|
|
StatForIn for_in = 11;
|
|
StatAssign assign = 12;
|
|
StatCompoundAssign compound_assign = 13;
|
|
StatFunction function = 14;
|
|
StatLocalFunction local_function = 15;
|
|
StatTypeAlias type_alias = 16;
|
|
}
|
|
}
|
|
|
|
message StatBlock {
|
|
repeated Stat body = 1;
|
|
}
|
|
|
|
message StatIf {
|
|
required Expr cond = 1;
|
|
required StatBlock then = 2;
|
|
oneof else_oneof {
|
|
StatBlock else = 3;
|
|
StatIf elseif = 4;
|
|
}
|
|
}
|
|
|
|
message StatWhile {
|
|
required Expr cond = 1;
|
|
required StatBlock body = 2;
|
|
}
|
|
|
|
message StatRepeat {
|
|
required StatBlock body = 1;
|
|
required Expr cond = 2;
|
|
}
|
|
|
|
message StatBreak {
|
|
}
|
|
|
|
message StatContinue {
|
|
}
|
|
|
|
message StatReturn {
|
|
repeated Expr list = 1;
|
|
}
|
|
|
|
message StatCall {
|
|
required ExprCall expr = 1;
|
|
}
|
|
|
|
message StatLocal {
|
|
repeated Local vars = 1;
|
|
repeated Expr values = 2;
|
|
repeated Type types = 3;
|
|
}
|
|
|
|
message StatFor {
|
|
required Local var = 1;
|
|
required Expr from = 2;
|
|
required Expr to = 3;
|
|
optional Expr step = 4;
|
|
required StatBlock body = 5;
|
|
}
|
|
|
|
message StatForIn {
|
|
repeated Local vars = 1;
|
|
repeated Expr values = 2;
|
|
required StatBlock body = 5;
|
|
}
|
|
|
|
message StatAssign {
|
|
repeated LValue vars = 1;
|
|
repeated Expr values = 2;
|
|
}
|
|
|
|
message StatCompoundAssign {
|
|
enum Op {
|
|
Add = 0;
|
|
Sub = 1;
|
|
Mul = 2;
|
|
Div = 3;
|
|
Mod = 4;
|
|
Pow = 5;
|
|
Concat = 6;
|
|
};
|
|
|
|
required Op op = 1;
|
|
required LValue var = 2;
|
|
required Expr value = 3;
|
|
}
|
|
|
|
message StatFunction {
|
|
required LValue var = 1;
|
|
required ExprFunction func = 2;
|
|
required bool self = 3;
|
|
}
|
|
|
|
message StatLocalFunction {
|
|
required Local var = 1;
|
|
required ExprFunction func = 2;
|
|
}
|
|
|
|
message StatTypeAlias {
|
|
required Typename name = 1;
|
|
required Type type = 2;
|
|
repeated Typename generics = 3;
|
|
}
|
|
|
|
message Type {
|
|
oneof type_oneof {
|
|
TypePrimitive primitive = 1;
|
|
TypeLiteral literal = 2;
|
|
TypeTable table = 3;
|
|
TypeFunction function = 4;
|
|
TypeTypeof typeof = 5;
|
|
TypeUnion union = 6;
|
|
TypeIntersection intersection = 7;
|
|
TypeClass class = 8;
|
|
TypeRef ref = 9;
|
|
}
|
|
}
|
|
|
|
message TypePrimitive {
|
|
required int32 kind = 1;
|
|
}
|
|
|
|
message TypeLiteral {
|
|
required Typename name = 1;
|
|
repeated Typename generics = 2;
|
|
}
|
|
|
|
message TypeTableItem {
|
|
required Name key = 1;
|
|
required Type type = 2;
|
|
}
|
|
|
|
message TypeTableIndexer {
|
|
required Type key = 1;
|
|
required Type value = 2;
|
|
}
|
|
|
|
message TypeTable {
|
|
repeated TypeTableItem items = 1;
|
|
optional TypeTableIndexer indexer = 2;
|
|
}
|
|
|
|
message TypeFunction {
|
|
repeated Type args = 1;
|
|
repeated Type rets = 2;
|
|
// TODO: vararg?
|
|
}
|
|
|
|
message TypeTypeof {
|
|
required Expr expr = 1;
|
|
}
|
|
|
|
message TypeUnion {
|
|
required Type left = 1;
|
|
required Type right = 2;
|
|
}
|
|
|
|
message TypeIntersection {
|
|
required Type left = 1;
|
|
required Type right = 2;
|
|
}
|
|
|
|
message TypeClass {
|
|
required int32 kind = 1;
|
|
}
|
|
|
|
message TypeRef {
|
|
required Local prefix = 1;
|
|
required Typename index = 2;
|
|
}
|