Documentation
¶
Index ¶
- Constants
- Variables
- type Parser
- func (p *Parser) AddExpr() (r []int32)
- func (p *Parser) AndExpr() (r []int32)
- func (p *Parser) ArgList() (r []int32)
- func (p *Parser) ArrayLit() (r []int32)
- func (p *Parser) AssignOrExpr() (r []int32)
- func (p *Parser) BenchDef() (r []int32)
- func (p *Parser) Body() (r []int32)
- func (p *Parser) BreakStmt() (r []int32)
- func (p *Parser) CompExpr() (r []int32)
- func (p *Parser) EOF() bool
- func (p *Parser) Expr() (r []int32)
- func (p *Parser) FnExpr() (r []int32)
- func (p *Parser) ForStmt() (r []int32)
- func (p *Parser) FuncDef() (r []int32)
- func (p *Parser) HashEntry() (r []int32)
- func (p *Parser) HashLit() (r []int32)
- func (p *Parser) IfStmt() (r []int32)
- func (p *Parser) ImportStmt() (r []int32)
- func (p *Parser) MulExpr() (r []int32)
- func (p *Parser) NextStmt() (r []int32)
- func (p *Parser) OrExpr() (r []int32)
- func (p *Parser) ParallelExpr() (r []int32)
- func (p *Parser) Param() (r []int32)
- func (p *Parser) ParamList() (r []int32)
- func (p *Parser) Parse(name string, src []byte) (ast []int32, err error)
- func (p *Parser) Postfix() (r []int32)
- func (p *Parser) Primary() (r []int32)
- func (p *Parser) Program() (r []int32)
- func (p *Parser) RequireStmt() (r []int32)
- func (p *Parser) ReturnStmt() (r []int32)
- func (p *Parser) SandboxList() (r []int32)
- func (p *Parser) SandboxPerm() (r []int32)
- func (p *Parser) SandboxStmt() (r []int32)
- func (p *Parser) Scan() (r scanner.Token)
- func (p *Parser) SpawnExpr() (r []int32)
- func (p *Parser) Statement() (r []int32)
- func (p *Parser) Suffix() (r []int32)
- func (p *Parser) TestDef() (r []int32)
- func (p *Parser) Token(n int32) (r scanner.Token)
- func (p *Parser) TryExpr() (r []int32)
- func (p *Parser) UnaryExpr() (r []int32)
- func (p *Parser) UseStmt() (r []int32)
- func (p *Parser) WhileStmt() (r []int32)
- type Symbol
Constants ¶
const ( RugoTOK_EOF = Symbol(0) // EOF RugoTOK_00260026 = Symbol(1) // "&&" RugoTOK_003d003e = Symbol(2) // "=>" RugoTOK_as = Symbol(3) // "as" RugoTOK_bench = Symbol(4) // "bench" RugoTOK_break = Symbol(5) // "break" RugoTOK_def = Symbol(6) // "def" RugoTOK_else = Symbol(7) // "else" RugoTOK_elsif = Symbol(8) // "elsif" RugoTOK_end = Symbol(9) // "end" RugoTOK_false = Symbol(10) // "false" RugoTOK_fn = Symbol(11) // "fn" RugoTOK_for = Symbol(12) // "for" RugoTOK_if = Symbol(13) // "if" RugoTOK_import = Symbol(14) // "import" RugoTOK_in = Symbol(15) // "in" RugoTOK_next = Symbol(16) // "next" RugoTOK_nil = Symbol(17) // "nil" RugoTOK_or = Symbol(18) // "or" RugoTOK_parallel = Symbol(19) // "parallel" RugoTOK_rats = Symbol(20) // "rats" RugoTOK_require = Symbol(21) // "require" RugoTOK_return = Symbol(22) // "return" RugoTOK_sandbox = Symbol(23) // "sandbox" RugoTOK_spawn = Symbol(24) // "spawn" RugoTOK_true = Symbol(25) // "true" RugoTOK_try = Symbol(26) // "try" RugoTOK_use = Symbol(27) // "use" RugoTOK_while = Symbol(28) // "while" RugoTOK_with = Symbol(29) // "with" RugoTOK_007c007c = Symbol(30) // "||" RugoTOK_0021 = Symbol(31) // '!' RugoTOK_0025 = Symbol(32) // '%' RugoTOK_0028 = Symbol(33) // '(' RugoTOK_0029 = Symbol(34) // ')' RugoTOK_002a = Symbol(35) // '*' RugoTOK_002b = Symbol(36) // '+' RugoTOK_002c = Symbol(37) // ',' RugoTOK_002d = Symbol(38) // '-' RugoTOK_002e = Symbol(39) // '.' RugoTOK_002f = Symbol(40) // '/' RugoTOK_003a = Symbol(41) // ':' RugoTOK_003b = Symbol(42) // ';' RugoTOK_003d = Symbol(43) // '=' RugoTOK_005b = Symbol(44) // '[' RugoTOK_005d = Symbol(45) // ']' RugoTOK_007b = Symbol(46) // '{' RugoTOK_007d = Symbol(47) // '}' Rugocomp_op = Symbol(48) // comp_op Rugofloat_lit = Symbol(49) // float_lit Rugoident = Symbol(50) // ident Rugointeger = Symbol(51) // integer Rugoraw_str_lit = Symbol(52) // raw_str_lit Rugostr_lit = Symbol(53) // str_lit Rugowhite_space = Symbol(54) // white_space RugoProgram = Symbol(55) // Program RugoStatement = Symbol(56) // Statement RugoUseStmt = Symbol(57) // UseStmt RugoImportStmt = Symbol(58) // ImportStmt RugoRequireStmt = Symbol(59) // RequireStmt RugoSandboxStmt = Symbol(60) // SandboxStmt RugoSandboxPerm = Symbol(61) // SandboxPerm RugoSandboxList = Symbol(62) // SandboxList RugoFuncDef = Symbol(63) // FuncDef RugoTestDef = Symbol(64) // TestDef RugoBenchDef = Symbol(65) // BenchDef RugoParamList = Symbol(66) // ParamList RugoParam = Symbol(67) // Param RugoBody = Symbol(68) // Body RugoIfStmt = Symbol(69) // IfStmt RugoWhileStmt = Symbol(70) // WhileStmt RugoForStmt = Symbol(71) // ForStmt RugoBreakStmt = Symbol(72) // BreakStmt RugoNextStmt = Symbol(73) // NextStmt RugoReturnStmt = Symbol(74) // ReturnStmt RugoAssignOrExpr = Symbol(75) // AssignOrExpr RugoExpr = Symbol(76) // Expr RugoOrExpr = Symbol(77) // OrExpr RugoAndExpr = Symbol(78) // AndExpr RugoCompExpr = Symbol(79) // CompExpr RugoAddExpr = Symbol(80) // AddExpr RugoMulExpr = Symbol(81) // MulExpr RugoUnaryExpr = Symbol(82) // UnaryExpr RugoPostfix = Symbol(83) // Postfix RugoSuffix = Symbol(84) // Suffix RugoArgList = Symbol(85) // ArgList RugoPrimary = Symbol(86) // Primary RugoTryExpr = Symbol(87) // TryExpr RugoSpawnExpr = Symbol(88) // SpawnExpr RugoParallelExpr = Symbol(89) // ParallelExpr RugoFnExpr = Symbol(90) // FnExpr RugoArrayLit = Symbol(91) // ArrayLit RugoHashLit = Symbol(92) // HashLit RugoHashEntry = Symbol(93) // HashEntry )
Symbols
const RugoSymbolNames = "" /* 660-byte string literal not displayed */
Variables ¶
var Source []byte
Source contains the parser source code for embedding into the AST cache.
var SymbolIndex = [...]uint16{0, 3, 7, 11, 15, 22, 29, 34, 40, 47, 52, 59, 63, 68, 72, 80, 84, 90, 95, 99, 109, 115, 124, 132, 141, 148, 154, 159, 164, 171, 177, 181, 184, 187, 190, 193, 196, 199, 202, 205, 208, 211, 214, 217, 220, 223, 226, 229, 232, 239, 248, 253, 260, 271, 278, 289, 296, 305, 312, 322, 333, 344, 355, 366, 373, 380, 388, 397, 402, 406, 412, 421, 428, 437, 445, 455, 467, 471, 477, 484, 492, 499, 506, 515, 522, 528, 535, 542, 549, 558, 570, 576, 584, 591, 600}
Functions ¶
This section is empty.
Types ¶
type Parser ¶
type Parser struct {
// contains filtered or unexported fields
}
func (*Parser) AddExpr ¶
AddExpr grammar:
AddExpr = MulExpr { ('+' | '-') MulExpr } .
State 0
on "false", "fn", "nil", "parallel", "spawn", "true", "try", '!', '(', '-', '[', '{', float_lit, ident, integer, raw_str_lit, str_lit, UnaryExpr, Postfix, Primary, TryExpr, SpawnExpr, ParallelExpr, FnExpr, ArrayLit, HashLit
call MulExpr and goto state 1
State 1
Accept
on '+', '-'
shift and goto state 0
AddExpr is used internally from Parse.
func (*Parser) AndExpr ¶
AndExpr grammar:
AndExpr = CompExpr { "&&" CompExpr } .
State 0
on "false", "fn", "nil", "parallel", "spawn", "true", "try", '!', '(', '-', '[', '{', float_lit, ident, integer, raw_str_lit, str_lit, AddExpr, MulExpr, UnaryExpr, Postfix, Primary, TryExpr, SpawnExpr, ParallelExpr, FnExpr, ArrayLit, HashLit
call CompExpr and goto state 1
State 1
Accept
on "&&"
shift and goto state 0
AndExpr is used internally from Parse.
func (*Parser) ArgList ¶
ArgList grammar:
ArgList = Expr { ',' Expr } .
State 0
on "false", "fn", "nil", "parallel", "spawn", "true", "try", '!', '(', '-', '[', '{', float_lit, ident, integer, raw_str_lit, str_lit, OrExpr, AndExpr, CompExpr, AddExpr, MulExpr, UnaryExpr, Postfix, Primary, TryExpr, SpawnExpr, ParallelExpr, FnExpr, ArrayLit, HashLit
call Expr and goto state 1
State 1
Accept
on ','
shift and goto state 0
ArgList is used internally from Parse.
func (*Parser) ArrayLit ¶
ArrayLit grammar:
ArrayLit = '[' [ Expr { ',' Expr } ] ']' .
State 0
on '['
shift and goto state 1
State 1
on ']'
shift and goto state 2
on "false", "fn", "nil", "parallel", "spawn", "true", "try", '!', '(', '-', '[', '{', float_lit, ident, integer, raw_str_lit, str_lit, OrExpr, AndExpr, CompExpr, AddExpr, MulExpr, UnaryExpr, Postfix, Primary, TryExpr, SpawnExpr, ParallelExpr, FnExpr, ArrayLit, HashLit
call Expr and goto state 3
State 2
Accept
State 3
on ']'
shift and goto state 2
on ','
shift and goto state 4
State 4
on "false", "fn", "nil", "parallel", "spawn", "true", "try", '!', '(', '-', '[', '{', float_lit, ident, integer, raw_str_lit, str_lit, OrExpr, AndExpr, CompExpr, AddExpr, MulExpr, UnaryExpr, Postfix, Primary, TryExpr, SpawnExpr, ParallelExpr, FnExpr, ArrayLit, HashLit
call Expr and goto state 3
ArrayLit is used internally from Parse.
func (*Parser) AssignOrExpr ¶
AssignOrExpr grammar:
AssignOrExpr = Expr [ '=' Expr ] .
State 0
on "false", "fn", "nil", "parallel", "spawn", "true", "try", '!', '(', '-', '[', '{', float_lit, ident, integer, raw_str_lit, str_lit, OrExpr, AndExpr, CompExpr, AddExpr, MulExpr, UnaryExpr, Postfix, Primary, TryExpr, SpawnExpr, ParallelExpr, FnExpr, ArrayLit, HashLit
call Expr and goto state 1
State 1
Accept
on '='
shift and goto state 2
State 2
on "false", "fn", "nil", "parallel", "spawn", "true", "try", '!', '(', '-', '[', '{', float_lit, ident, integer, raw_str_lit, str_lit, OrExpr, AndExpr, CompExpr, AddExpr, MulExpr, UnaryExpr, Postfix, Primary, TryExpr, SpawnExpr, ParallelExpr, FnExpr, ArrayLit, HashLit
call Expr and goto state 3
State 3
Accept
AssignOrExpr is used internally from Parse.
func (*Parser) BenchDef ¶
BenchDef grammar:
BenchDef = "bench" str_lit Body "end" .
State 0
on "bench"
shift and goto state 1
State 1
on str_lit
shift and goto state 2
State 2
on "end"
shift and goto state 3
on "bench", "break", "def", "false", "fn", "for", "if", "import", "next", "nil", "parallel", "rats", "require", "return", "sandbox", "spawn", "true", "try", "use", "while", '!', '(', '-', ';', '[', '{', float_lit, ident, integer, raw_str_lit, str_lit, Statement, UseStmt, ImportStmt, RequireStmt, SandboxStmt, FuncDef, TestDef, BenchDef, IfStmt, WhileStmt, ForStmt, BreakStmt, NextStmt, ReturnStmt, AssignOrExpr, Expr, OrExpr, AndExpr, CompExpr, AddExpr, MulExpr, UnaryExpr, Postfix, Primary, TryExpr, SpawnExpr, ParallelExpr, FnExpr, ArrayLit, HashLit
call Body and goto state 4
State 3
Accept
State 4
on "end"
shift and goto state 3
BenchDef is used internally from Parse.
func (*Parser) Body ¶
Body grammar:
Body = { Statement | ';' } .
State 0
Accept
on ';'
shift and goto state 1
on "bench", "break", "def", "false", "fn", "for", "if", "import", "next", "nil", "parallel", "rats", "require", "return", "sandbox", "spawn", "true", "try", "use", "while", '!', '(', '-', '[', '{', float_lit, ident, integer, raw_str_lit, str_lit, UseStmt, ImportStmt, RequireStmt, SandboxStmt, FuncDef, TestDef, BenchDef, IfStmt, WhileStmt, ForStmt, BreakStmt, NextStmt, ReturnStmt, AssignOrExpr, Expr, OrExpr, AndExpr, CompExpr, AddExpr, MulExpr, UnaryExpr, Postfix, Primary, TryExpr, SpawnExpr, ParallelExpr, FnExpr, ArrayLit, HashLit
call Statement and goto state 1
State 1
Accept
on ';'
shift and goto state 1
on "bench", "break", "def", "false", "fn", "for", "if", "import", "next", "nil", "parallel", "rats", "require", "return", "sandbox", "spawn", "true", "try", "use", "while", '!', '(', '-', '[', '{', float_lit, ident, integer, raw_str_lit, str_lit, UseStmt, ImportStmt, RequireStmt, SandboxStmt, FuncDef, TestDef, BenchDef, IfStmt, WhileStmt, ForStmt, BreakStmt, NextStmt, ReturnStmt, AssignOrExpr, Expr, OrExpr, AndExpr, CompExpr, AddExpr, MulExpr, UnaryExpr, Postfix, Primary, TryExpr, SpawnExpr, ParallelExpr, FnExpr, ArrayLit, HashLit
call Statement and goto state 1
Body is used internally from Parse.
func (*Parser) BreakStmt ¶
BreakStmt grammar:
BreakStmt = "break" . State 0 on "break" shift and goto state 1 State 1 Accept
BreakStmt is used internally from Parse.
func (*Parser) CompExpr ¶
CompExpr grammar:
CompExpr = AddExpr [ comp_op AddExpr ] .
State 0
on "false", "fn", "nil", "parallel", "spawn", "true", "try", '!', '(', '-', '[', '{', float_lit, ident, integer, raw_str_lit, str_lit, MulExpr, UnaryExpr, Postfix, Primary, TryExpr, SpawnExpr, ParallelExpr, FnExpr, ArrayLit, HashLit
call AddExpr and goto state 1
State 1
Accept
on comp_op
shift and goto state 2
State 2
on "false", "fn", "nil", "parallel", "spawn", "true", "try", '!', '(', '-', '[', '{', float_lit, ident, integer, raw_str_lit, str_lit, MulExpr, UnaryExpr, Postfix, Primary, TryExpr, SpawnExpr, ParallelExpr, FnExpr, ArrayLit, HashLit
call AddExpr and goto state 3
State 3
Accept
CompExpr is used internally from Parse.
func (*Parser) Expr ¶
Expr grammar:
# Expressions (lowest to highest precedence)
Expr = OrExpr .
State 0
on "false", "fn", "nil", "parallel", "spawn", "true", "try", '!', '(', '-', '[', '{', float_lit, ident, integer, raw_str_lit, str_lit, AndExpr, CompExpr, AddExpr, MulExpr, UnaryExpr, Postfix, Primary, TryExpr, SpawnExpr, ParallelExpr, FnExpr, ArrayLit, HashLit
call OrExpr and goto state 1
State 1
Accept
Expr is used internally from Parse.
func (*Parser) FnExpr ¶
FnExpr grammar:
FnExpr = "fn" '(' [ ParamList ] ')' Body "end" .
State 0
on "fn"
shift and goto state 1
State 1
on '('
shift and goto state 2
State 2
on ')'
shift and goto state 3
on ident, Param
call ParamList and goto state 6
State 3
on "end"
shift and goto state 4
on "bench", "break", "def", "false", "fn", "for", "if", "import", "next", "nil", "parallel", "rats", "require", "return", "sandbox", "spawn", "true", "try", "use", "while", '!', '(', '-', ';', '[', '{', float_lit, ident, integer, raw_str_lit, str_lit, Statement, UseStmt, ImportStmt, RequireStmt, SandboxStmt, FuncDef, TestDef, BenchDef, IfStmt, WhileStmt, ForStmt, BreakStmt, NextStmt, ReturnStmt, AssignOrExpr, Expr, OrExpr, AndExpr, CompExpr, AddExpr, MulExpr, UnaryExpr, Postfix, Primary, TryExpr, SpawnExpr, ParallelExpr, FnExpr, ArrayLit, HashLit
call Body and goto state 5
State 4
Accept
State 5
on "end"
shift and goto state 4
State 6
on ')'
shift and goto state 3
FnExpr is used internally from Parse.
func (*Parser) ForStmt ¶
ForStmt grammar:
ForStmt = "for" ident [ ',' ident ] "in" Expr Body "end" .
State 0
on "for"
shift and goto state 1
State 1
on ident
shift and goto state 2
State 2
on "in"
shift and goto state 3
on ','
shift and goto state 7
State 3
on "false", "fn", "nil", "parallel", "spawn", "true", "try", '!', '(', '-', '[', '{', float_lit, ident, integer, raw_str_lit, str_lit, OrExpr, AndExpr, CompExpr, AddExpr, MulExpr, UnaryExpr, Postfix, Primary, TryExpr, SpawnExpr, ParallelExpr, FnExpr, ArrayLit, HashLit
call Expr and goto state 4
State 4
on "end"
shift and goto state 5
on "bench", "break", "def", "false", "fn", "for", "if", "import", "next", "nil", "parallel", "rats", "require", "return", "sandbox", "spawn", "true", "try", "use", "while", '!', '(', '-', ';', '[', '{', float_lit, ident, integer, raw_str_lit, str_lit, Statement, UseStmt, ImportStmt, RequireStmt, SandboxStmt, FuncDef, TestDef, BenchDef, IfStmt, WhileStmt, ForStmt, BreakStmt, NextStmt, ReturnStmt, AssignOrExpr, Expr, OrExpr, AndExpr, CompExpr, AddExpr, MulExpr, UnaryExpr, Postfix, Primary, TryExpr, SpawnExpr, ParallelExpr, FnExpr, ArrayLit, HashLit
call Body and goto state 6
State 5
Accept
State 6
on "end"
shift and goto state 5
State 7
on ident
shift and goto state 8
State 8
on "in"
shift and goto state 3
ForStmt is used internally from Parse.
func (*Parser) FuncDef ¶
FuncDef grammar:
FuncDef = "def" ident '(' [ ParamList ] ')' Body "end" .
State 0
on "def"
shift and goto state 1
State 1
on ident
shift and goto state 2
State 2
on '('
shift and goto state 3
State 3
on ')'
shift and goto state 4
on ident, Param
call ParamList and goto state 7
State 4
on "end"
shift and goto state 5
on "bench", "break", "def", "false", "fn", "for", "if", "import", "next", "nil", "parallel", "rats", "require", "return", "sandbox", "spawn", "true", "try", "use", "while", '!', '(', '-', ';', '[', '{', float_lit, ident, integer, raw_str_lit, str_lit, Statement, UseStmt, ImportStmt, RequireStmt, SandboxStmt, FuncDef, TestDef, BenchDef, IfStmt, WhileStmt, ForStmt, BreakStmt, NextStmt, ReturnStmt, AssignOrExpr, Expr, OrExpr, AndExpr, CompExpr, AddExpr, MulExpr, UnaryExpr, Postfix, Primary, TryExpr, SpawnExpr, ParallelExpr, FnExpr, ArrayLit, HashLit
call Body and goto state 6
State 5
Accept
State 6
on "end"
shift and goto state 5
State 7
on ')'
shift and goto state 4
FuncDef is used internally from Parse.
func (*Parser) HashEntry ¶
HashEntry grammar:
HashEntry = Expr "=>" Expr .
State 0
on "false", "fn", "nil", "parallel", "spawn", "true", "try", '!', '(', '-', '[', '{', float_lit, ident, integer, raw_str_lit, str_lit, OrExpr, AndExpr, CompExpr, AddExpr, MulExpr, UnaryExpr, Postfix, Primary, TryExpr, SpawnExpr, ParallelExpr, FnExpr, ArrayLit, HashLit
call Expr and goto state 1
State 1
on "=>"
shift and goto state 2
State 2
on "false", "fn", "nil", "parallel", "spawn", "true", "try", '!', '(', '-', '[', '{', float_lit, ident, integer, raw_str_lit, str_lit, OrExpr, AndExpr, CompExpr, AddExpr, MulExpr, UnaryExpr, Postfix, Primary, TryExpr, SpawnExpr, ParallelExpr, FnExpr, ArrayLit, HashLit
call Expr and goto state 3
State 3
Accept
HashEntry is used internally from Parse.
func (*Parser) HashLit ¶
HashLit grammar:
HashLit = '{' [ HashEntry { ',' HashEntry } ] '}' .
State 0
on '{'
shift and goto state 1
State 1
on '}'
shift and goto state 2
on "false", "fn", "nil", "parallel", "spawn", "true", "try", '!', '(', '-', '[', '{', float_lit, ident, integer, raw_str_lit, str_lit, Expr, OrExpr, AndExpr, CompExpr, AddExpr, MulExpr, UnaryExpr, Postfix, Primary, TryExpr, SpawnExpr, ParallelExpr, FnExpr, ArrayLit, HashLit
call HashEntry and goto state 3
State 2
Accept
State 3
on '}'
shift and goto state 2
on ','
shift and goto state 4
State 4
on "false", "fn", "nil", "parallel", "spawn", "true", "try", '!', '(', '-', '[', '{', float_lit, ident, integer, raw_str_lit, str_lit, Expr, OrExpr, AndExpr, CompExpr, AddExpr, MulExpr, UnaryExpr, Postfix, Primary, TryExpr, SpawnExpr, ParallelExpr, FnExpr, ArrayLit, HashLit
call HashEntry and goto state 3
HashLit is used internally from Parse.
func (*Parser) IfStmt ¶
IfStmt grammar:
IfStmt = "if" Expr Body { "elsif" Expr Body } [ "else" Body ] "end" .
State 0
on "if"
shift and goto state 1
State 1
on "false", "fn", "nil", "parallel", "spawn", "true", "try", '!', '(', '-', '[', '{', float_lit, ident, integer, raw_str_lit, str_lit, OrExpr, AndExpr, CompExpr, AddExpr, MulExpr, UnaryExpr, Postfix, Primary, TryExpr, SpawnExpr, ParallelExpr, FnExpr, ArrayLit, HashLit
call Expr and goto state 2
State 2
on "elsif"
shift and goto state 1
on "else"
shift and goto state 3
on "end"
shift and goto state 4
on "bench", "break", "def", "false", "fn", "for", "if", "import", "next", "nil", "parallel", "rats", "require", "return", "sandbox", "spawn", "true", "try", "use", "while", '!', '(', '-', ';', '[', '{', float_lit, ident, integer, raw_str_lit, str_lit, Statement, UseStmt, ImportStmt, RequireStmt, SandboxStmt, FuncDef, TestDef, BenchDef, IfStmt, WhileStmt, ForStmt, BreakStmt, NextStmt, ReturnStmt, AssignOrExpr, Expr, OrExpr, AndExpr, CompExpr, AddExpr, MulExpr, UnaryExpr, Postfix, Primary, TryExpr, SpawnExpr, ParallelExpr, FnExpr, ArrayLit, HashLit
call Body and goto state 6
State 3
on "end"
shift and goto state 4
on "bench", "break", "def", "false", "fn", "for", "if", "import", "next", "nil", "parallel", "rats", "require", "return", "sandbox", "spawn", "true", "try", "use", "while", '!', '(', '-', ';', '[', '{', float_lit, ident, integer, raw_str_lit, str_lit, Statement, UseStmt, ImportStmt, RequireStmt, SandboxStmt, FuncDef, TestDef, BenchDef, IfStmt, WhileStmt, ForStmt, BreakStmt, NextStmt, ReturnStmt, AssignOrExpr, Expr, OrExpr, AndExpr, CompExpr, AddExpr, MulExpr, UnaryExpr, Postfix, Primary, TryExpr, SpawnExpr, ParallelExpr, FnExpr, ArrayLit, HashLit
call Body and goto state 5
State 4
Accept
State 5
on "end"
shift and goto state 4
State 6
on "elsif"
shift and goto state 1
on "else"
shift and goto state 3
on "end"
shift and goto state 4
IfStmt is used internally from Parse.
func (*Parser) ImportStmt ¶
ImportStmt grammar:
ImportStmt = "import" str_lit [ "as" ident ] . State 0 on "import" shift and goto state 1 State 1 on str_lit shift and goto state 2 State 2 Accept on "as" shift and goto state 3 State 3 on ident shift and goto state 4 State 4 Accept
ImportStmt is used internally from Parse.
func (*Parser) MulExpr ¶
MulExpr grammar:
MulExpr = UnaryExpr { ('*' | '/' | '%') UnaryExpr } .
State 0
on "false", "fn", "nil", "parallel", "spawn", "true", "try", '!', '(', '-', '[', '{', float_lit, ident, integer, raw_str_lit, str_lit, Postfix, Primary, TryExpr, SpawnExpr, ParallelExpr, FnExpr, ArrayLit, HashLit
call UnaryExpr and goto state 1
State 1
Accept
on '%', '*', '/'
shift and goto state 0
MulExpr is used internally from Parse.
func (*Parser) NextStmt ¶
NextStmt grammar:
NextStmt = "next" . State 0 on "next" shift and goto state 1 State 1 Accept
NextStmt is used internally from Parse.
func (*Parser) OrExpr ¶
OrExpr grammar:
OrExpr = AndExpr { "||" AndExpr } .
State 0
on "false", "fn", "nil", "parallel", "spawn", "true", "try", '!', '(', '-', '[', '{', float_lit, ident, integer, raw_str_lit, str_lit, CompExpr, AddExpr, MulExpr, UnaryExpr, Postfix, Primary, TryExpr, SpawnExpr, ParallelExpr, FnExpr, ArrayLit, HashLit
call AndExpr and goto state 1
State 1
Accept
on "||"
shift and goto state 0
OrExpr is used internally from Parse.
func (*Parser) ParallelExpr ¶
ParallelExpr grammar:
ParallelExpr = "parallel" Body "end" .
State 0
on "parallel"
shift and goto state 1
State 1
on "end"
shift and goto state 2
on "bench", "break", "def", "false", "fn", "for", "if", "import", "next", "nil", "parallel", "rats", "require", "return", "sandbox", "spawn", "true", "try", "use", "while", '!', '(', '-', ';', '[', '{', float_lit, ident, integer, raw_str_lit, str_lit, Statement, UseStmt, ImportStmt, RequireStmt, SandboxStmt, FuncDef, TestDef, BenchDef, IfStmt, WhileStmt, ForStmt, BreakStmt, NextStmt, ReturnStmt, AssignOrExpr, Expr, OrExpr, AndExpr, CompExpr, AddExpr, MulExpr, UnaryExpr, Postfix, Primary, TryExpr, SpawnExpr, ParallelExpr, FnExpr, ArrayLit, HashLit
call Body and goto state 3
State 2
Accept
State 3
on "end"
shift and goto state 2
ParallelExpr is used internally from Parse.
func (*Parser) Param ¶ added in v0.24.0
Param grammar:
Param = ident [ '=' Expr ] .
State 0
on ident
shift and goto state 1
State 1
Accept
on '='
shift and goto state 2
State 2
on "false", "fn", "nil", "parallel", "spawn", "true", "try", '!', '(', '-', '[', '{', float_lit, ident, integer, raw_str_lit, str_lit, OrExpr, AndExpr, CompExpr, AddExpr, MulExpr, UnaryExpr, Postfix, Primary, TryExpr, SpawnExpr, ParallelExpr, FnExpr, ArrayLit, HashLit
call Expr and goto state 3
State 3
Accept
Param is used internally from Parse.
func (*Parser) ParamList ¶
ParamList grammar:
ParamList = Param { ',' Param } .
State 0
on ident
call Param and goto state 1
State 1
Accept
on ','
shift and goto state 0
ParamList is used internally from Parse.
func (*Parser) Parse ¶
Parse parses 'src'. 'src' becomes "owned" by the parser and must not be mutated afterwards.
func (*Parser) Postfix ¶
Postfix grammar:
Postfix = Primary { Suffix } .
State 0
on "false", "fn", "nil", "parallel", "spawn", "true", "try", '(', '[', '{', float_lit, ident, integer, raw_str_lit, str_lit, TryExpr, SpawnExpr, ParallelExpr, FnExpr, ArrayLit, HashLit
call Primary and goto state 1
State 1
Accept
on '(', '.', '['
call Suffix and goto state 1
Postfix is used internally from Parse.
func (*Parser) Primary ¶
Primary grammar:
# Primary expressions
Primary = ident
| integer
| float_lit
| str_lit
| raw_str_lit
| "true"
| "false"
| "nil"
| ArrayLit
| HashLit
| TryExpr
| SpawnExpr
| ParallelExpr
| FnExpr
| '(' Expr ')' .
State 0
on "false", "nil", "true", float_lit, ident, integer, raw_str_lit, str_lit
shift and goto state 1
on '('
shift and goto state 2
on "try"
call TryExpr and goto state 1
on "spawn"
call SpawnExpr and goto state 1
on "parallel"
call ParallelExpr and goto state 1
on "fn"
call FnExpr and goto state 1
on '['
call ArrayLit and goto state 1
on '{'
call HashLit and goto state 1
State 1
Accept
State 2
on "false", "fn", "nil", "parallel", "spawn", "true", "try", '!', '(', '-', '[', '{', float_lit, ident, integer, raw_str_lit, str_lit, OrExpr, AndExpr, CompExpr, AddExpr, MulExpr, UnaryExpr, Postfix, Primary, TryExpr, SpawnExpr, ParallelExpr, FnExpr, ArrayLit, HashLit
call Expr and goto state 3
State 3
on ')'
shift and goto state 1
Primary is used internally from Parse.
func (*Parser) Program ¶
Program grammar:
# Rugo Language Grammar (LL(1))
# A minimal Ruby-inspired language that transpiles to Go.
# Entry point
# ';' is a statement separator injected by the preprocessor to disambiguate
# array literals on new lines from index suffix operations (e.g. expr\n[1,2,3]).
# Users should not write ';' directly — the preprocessor rejects it.
Program = { Statement | ';' } .
State 0
Accept
on ';'
shift and goto state 1
on "bench", "break", "def", "false", "fn", "for", "if", "import", "next", "nil", "parallel", "rats", "require", "return", "sandbox", "spawn", "true", "try", "use", "while", '!', '(', '-', '[', '{', float_lit, ident, integer, raw_str_lit, str_lit, UseStmt, ImportStmt, RequireStmt, SandboxStmt, FuncDef, TestDef, BenchDef, IfStmt, WhileStmt, ForStmt, BreakStmt, NextStmt, ReturnStmt, AssignOrExpr, Expr, OrExpr, AndExpr, CompExpr, AddExpr, MulExpr, UnaryExpr, Postfix, Primary, TryExpr, SpawnExpr, ParallelExpr, FnExpr, ArrayLit, HashLit
call Statement and goto state 1
State 1
Accept
on ';'
shift and goto state 1
on "bench", "break", "def", "false", "fn", "for", "if", "import", "next", "nil", "parallel", "rats", "require", "return", "sandbox", "spawn", "true", "try", "use", "while", '!', '(', '-', '[', '{', float_lit, ident, integer, raw_str_lit, str_lit, UseStmt, ImportStmt, RequireStmt, SandboxStmt, FuncDef, TestDef, BenchDef, IfStmt, WhileStmt, ForStmt, BreakStmt, NextStmt, ReturnStmt, AssignOrExpr, Expr, OrExpr, AndExpr, CompExpr, AddExpr, MulExpr, UnaryExpr, Postfix, Primary, TryExpr, SpawnExpr, ParallelExpr, FnExpr, ArrayLit, HashLit
call Statement and goto state 1
Program is used internally from Parse.
func (*Parser) RequireStmt ¶
RequireStmt grammar:
RequireStmt = "require" str_lit [ "as" ( str_lit | ident ) | "with" ident { ',' ident } ] .
State 0
on "require"
shift and goto state 1
State 1
on str_lit
shift and goto state 2
State 2
Accept
on "as"
shift and goto state 3
on "with"
shift and goto state 5
State 3
on ident, str_lit
shift and goto state 4
State 4
Accept
State 5
on ident
shift and goto state 6
State 6
Accept
on ','
shift and goto state 5
RequireStmt is used internally from Parse.
func (*Parser) ReturnStmt ¶
ReturnStmt grammar:
ReturnStmt = "return" [ Expr ] .
State 0
on "return"
shift and goto state 1
State 1
Accept
on "false", "fn", "nil", "parallel", "spawn", "true", "try", '!', '(', '-', '[', '{', float_lit, ident, integer, raw_str_lit, str_lit, OrExpr, AndExpr, CompExpr, AddExpr, MulExpr, UnaryExpr, Postfix, Primary, TryExpr, SpawnExpr, ParallelExpr, FnExpr, ArrayLit, HashLit
call Expr and goto state 2
State 2
Accept
ReturnStmt is used internally from Parse.
func (*Parser) SandboxList ¶ added in v0.18.0
SandboxList grammar:
SandboxList = '[' ( str_lit | integer ) { ',' ( str_lit | integer ) } ']' .
State 0
on '['
shift and goto state 1
State 1
on integer, str_lit
shift and goto state 2
State 2
on ','
shift and goto state 1
on ']'
shift and goto state 3
State 3
Accept
SandboxList is used internally from Parse.
func (*Parser) SandboxPerm ¶ added in v0.18.0
SandboxPerm grammar:
SandboxPerm = ident ':' ( str_lit | integer | SandboxList ) . State 0 on ident shift and goto state 1 State 1 on ':' shift and goto state 2 State 2 on integer, str_lit shift and goto state 3 on '[' call SandboxList and goto state 3 State 3 Accept
SandboxPerm is used internally from Parse.
func (*Parser) SandboxStmt ¶ added in v0.18.0
SandboxStmt grammar:
SandboxStmt = "sandbox" [ SandboxPerm { ',' SandboxPerm } ] .
State 0
on "sandbox"
shift and goto state 1
State 1
Accept
on ident
call SandboxPerm and goto state 2
State 2
Accept
on ','
shift and goto state 3
State 3
on ident
call SandboxPerm and goto state 2
SandboxStmt is used internally from Parse.
func (*Parser) SpawnExpr ¶
SpawnExpr grammar:
SpawnExpr = "spawn" Body "end" .
State 0
on "spawn"
shift and goto state 1
State 1
on "end"
shift and goto state 2
on "bench", "break", "def", "false", "fn", "for", "if", "import", "next", "nil", "parallel", "rats", "require", "return", "sandbox", "spawn", "true", "try", "use", "while", '!', '(', '-', ';', '[', '{', float_lit, ident, integer, raw_str_lit, str_lit, Statement, UseStmt, ImportStmt, RequireStmt, SandboxStmt, FuncDef, TestDef, BenchDef, IfStmt, WhileStmt, ForStmt, BreakStmt, NextStmt, ReturnStmt, AssignOrExpr, Expr, OrExpr, AndExpr, CompExpr, AddExpr, MulExpr, UnaryExpr, Postfix, Primary, TryExpr, SpawnExpr, ParallelExpr, FnExpr, ArrayLit, HashLit
call Body and goto state 3
State 2
Accept
State 3
on "end"
shift and goto state 2
SpawnExpr is used internally from Parse.
func (*Parser) Statement ¶
Statement grammar:
# Statements
Statement = UseStmt
| ImportStmt
| RequireStmt
| SandboxStmt
| FuncDef
| TestDef
| BenchDef
| IfStmt
| WhileStmt
| ForStmt
| BreakStmt
| NextStmt
| ReturnStmt
| AssignOrExpr .
State 0
on "use"
call UseStmt and goto state 1
on "import"
call ImportStmt and goto state 1
on "require"
call RequireStmt and goto state 1
on "sandbox"
call SandboxStmt and goto state 1
on "def"
call FuncDef and goto state 1
on "rats"
call TestDef and goto state 1
on "bench"
call BenchDef and goto state 1
on "if"
call IfStmt and goto state 1
on "while"
call WhileStmt and goto state 1
on "for"
call ForStmt and goto state 1
on "break"
call BreakStmt and goto state 1
on "next"
call NextStmt and goto state 1
on "return"
call ReturnStmt and goto state 1
on "false", "fn", "nil", "parallel", "spawn", "true", "try", '!', '(', '-', '[', '{', float_lit, ident, integer, raw_str_lit, str_lit, Expr, OrExpr, AndExpr, CompExpr, AddExpr, MulExpr, UnaryExpr, Postfix, Primary, TryExpr, SpawnExpr, ParallelExpr, FnExpr, ArrayLit, HashLit
call AssignOrExpr and goto state 1
State 1
Accept
Statement is used internally from Parse.
func (*Parser) Suffix ¶
Suffix grammar:
Suffix = '(' [ ArgList ] ')' | '[' Expr [ ',' Expr ] ']' | '.' ident .
State 0
on '('
shift and goto state 1
on '.'
shift and goto state 4
on '['
shift and goto state 5
State 1
on ')'
shift and goto state 2
on "false", "fn", "nil", "parallel", "spawn", "true", "try", '!', '(', '-', '[', '{', float_lit, ident, integer, raw_str_lit, str_lit, Expr, OrExpr, AndExpr, CompExpr, AddExpr, MulExpr, UnaryExpr, Postfix, Primary, TryExpr, SpawnExpr, ParallelExpr, FnExpr, ArrayLit, HashLit
call ArgList and goto state 3
State 2
Accept
State 3
on ')'
shift and goto state 2
State 4
on ident
shift and goto state 2
State 5
on "false", "fn", "nil", "parallel", "spawn", "true", "try", '!', '(', '-', '[', '{', float_lit, ident, integer, raw_str_lit, str_lit, OrExpr, AndExpr, CompExpr, AddExpr, MulExpr, UnaryExpr, Postfix, Primary, TryExpr, SpawnExpr, ParallelExpr, FnExpr, ArrayLit, HashLit
call Expr and goto state 6
State 6
on ']'
shift and goto state 2
on ','
shift and goto state 7
State 7
on "false", "fn", "nil", "parallel", "spawn", "true", "try", '!', '(', '-', '[', '{', float_lit, ident, integer, raw_str_lit, str_lit, OrExpr, AndExpr, CompExpr, AddExpr, MulExpr, UnaryExpr, Postfix, Primary, TryExpr, SpawnExpr, ParallelExpr, FnExpr, ArrayLit, HashLit
call Expr and goto state 8
State 8
on ']'
shift and goto state 2
Suffix is used internally from Parse.
func (*Parser) TestDef ¶
TestDef grammar:
TestDef = "rats" str_lit Body "end" .
State 0
on "rats"
shift and goto state 1
State 1
on str_lit
shift and goto state 2
State 2
on "end"
shift and goto state 3
on "bench", "break", "def", "false", "fn", "for", "if", "import", "next", "nil", "parallel", "rats", "require", "return", "sandbox", "spawn", "true", "try", "use", "while", '!', '(', '-', ';', '[', '{', float_lit, ident, integer, raw_str_lit, str_lit, Statement, UseStmt, ImportStmt, RequireStmt, SandboxStmt, FuncDef, TestDef, BenchDef, IfStmt, WhileStmt, ForStmt, BreakStmt, NextStmt, ReturnStmt, AssignOrExpr, Expr, OrExpr, AndExpr, CompExpr, AddExpr, MulExpr, UnaryExpr, Postfix, Primary, TryExpr, SpawnExpr, ParallelExpr, FnExpr, ArrayLit, HashLit
call Body and goto state 4
State 3
Accept
State 4
on "end"
shift and goto state 3
TestDef is used internally from Parse.
func (*Parser) TryExpr ¶
TryExpr grammar:
TryExpr = "try" Expr "or" ident Body "end" .
State 0
on "try"
shift and goto state 1
State 1
on "false", "fn", "nil", "parallel", "spawn", "true", "try", '!', '(', '-', '[', '{', float_lit, ident, integer, raw_str_lit, str_lit, OrExpr, AndExpr, CompExpr, AddExpr, MulExpr, UnaryExpr, Postfix, Primary, TryExpr, SpawnExpr, ParallelExpr, FnExpr, ArrayLit, HashLit
call Expr and goto state 2
State 2
on "or"
shift and goto state 3
State 3
on ident
shift and goto state 4
State 4
on "end"
shift and goto state 5
on "bench", "break", "def", "false", "fn", "for", "if", "import", "next", "nil", "parallel", "rats", "require", "return", "sandbox", "spawn", "true", "try", "use", "while", '!', '(', '-', ';', '[', '{', float_lit, ident, integer, raw_str_lit, str_lit, Statement, UseStmt, ImportStmt, RequireStmt, SandboxStmt, FuncDef, TestDef, BenchDef, IfStmt, WhileStmt, ForStmt, BreakStmt, NextStmt, ReturnStmt, AssignOrExpr, Expr, OrExpr, AndExpr, CompExpr, AddExpr, MulExpr, UnaryExpr, Postfix, Primary, TryExpr, SpawnExpr, ParallelExpr, FnExpr, ArrayLit, HashLit
call Body and goto state 6
State 5
Accept
State 6
on "end"
shift and goto state 5
TryExpr is used internally from Parse.
func (*Parser) UnaryExpr ¶
UnaryExpr grammar:
UnaryExpr = '!' Postfix | '-' Postfix | Postfix .
State 0
on '!', '-'
shift and goto state 1
on "false", "fn", "nil", "parallel", "spawn", "true", "try", '(', '[', '{', float_lit, ident, integer, raw_str_lit, str_lit, Primary, TryExpr, SpawnExpr, ParallelExpr, FnExpr, ArrayLit, HashLit
call Postfix and goto state 2
State 1
on "false", "fn", "nil", "parallel", "spawn", "true", "try", '(', '[', '{', float_lit, ident, integer, raw_str_lit, str_lit, Primary, TryExpr, SpawnExpr, ParallelExpr, FnExpr, ArrayLit, HashLit
call Postfix and goto state 2
State 2
Accept
UnaryExpr is used internally from Parse.
func (*Parser) UseStmt ¶
UseStmt grammar:
UseStmt = "use" str_lit . State 0 on "use" shift and goto state 1 State 1 on str_lit shift and goto state 2 State 2 Accept
UseStmt is used internally from Parse.
func (*Parser) WhileStmt ¶
WhileStmt grammar:
WhileStmt = "while" Expr Body "end" .
State 0
on "while"
shift and goto state 1
State 1
on "false", "fn", "nil", "parallel", "spawn", "true", "try", '!', '(', '-', '[', '{', float_lit, ident, integer, raw_str_lit, str_lit, OrExpr, AndExpr, CompExpr, AddExpr, MulExpr, UnaryExpr, Postfix, Primary, TryExpr, SpawnExpr, ParallelExpr, FnExpr, ArrayLit, HashLit
call Expr and goto state 2
State 2
on "end"
shift and goto state 3
on "bench", "break", "def", "false", "fn", "for", "if", "import", "next", "nil", "parallel", "rats", "require", "return", "sandbox", "spawn", "true", "try", "use", "while", '!', '(', '-', ';', '[', '{', float_lit, ident, integer, raw_str_lit, str_lit, Statement, UseStmt, ImportStmt, RequireStmt, SandboxStmt, FuncDef, TestDef, BenchDef, IfStmt, WhileStmt, ForStmt, BreakStmt, NextStmt, ReturnStmt, AssignOrExpr, Expr, OrExpr, AndExpr, CompExpr, AddExpr, MulExpr, UnaryExpr, Postfix, Primary, TryExpr, SpawnExpr, ParallelExpr, FnExpr, ArrayLit, HashLit
call Body and goto state 4
State 3
Accept
State 4
on "end"
shift and goto state 3
WhileStmt is used internally from Parse.