parser

package
v0.28.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 5, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RugoTOK_EOF      = Symbol(0)   // EOF
	RugoTOK_00260026 = Symbol(1)   // "&&"
	RugoTOK_002d003e = Symbol(2)   // "->"
	RugoTOK_003d003e = Symbol(3)   // "=>"
	RugoTOK_as       = Symbol(4)   // "as"
	RugoTOK_bench    = Symbol(5)   // "bench"
	RugoTOK_break    = Symbol(6)   // "break"
	RugoTOK_case     = Symbol(7)   // "case"
	RugoTOK_def      = Symbol(8)   // "def"
	RugoTOK_else     = Symbol(9)   // "else"
	RugoTOK_elsif    = Symbol(10)  // "elsif"
	RugoTOK_embed    = Symbol(11)  // "embed"
	RugoTOK_end      = Symbol(12)  // "end"
	RugoTOK_false    = Symbol(13)  // "false"
	RugoTOK_fn       = Symbol(14)  // "fn"
	RugoTOK_for      = Symbol(15)  // "for"
	RugoTOK_if       = Symbol(16)  // "if"
	RugoTOK_import   = Symbol(17)  // "import"
	RugoTOK_in       = Symbol(18)  // "in"
	RugoTOK_next     = Symbol(19)  // "next"
	RugoTOK_nil      = Symbol(20)  // "nil"
	RugoTOK_of       = Symbol(21)  // "of"
	RugoTOK_or       = Symbol(22)  // "or"
	RugoTOK_parallel = Symbol(23)  // "parallel"
	RugoTOK_rats     = Symbol(24)  // "rats"
	RugoTOK_require  = Symbol(25)  // "require"
	RugoTOK_return   = Symbol(26)  // "return"
	RugoTOK_sandbox  = Symbol(27)  // "sandbox"
	RugoTOK_spawn    = Symbol(28)  // "spawn"
	RugoTOK_true     = Symbol(29)  // "true"
	RugoTOK_try      = Symbol(30)  // "try"
	RugoTOK_use      = Symbol(31)  // "use"
	RugoTOK_while    = Symbol(32)  // "while"
	RugoTOK_with     = Symbol(33)  // "with"
	RugoTOK_007c007c = Symbol(34)  // "||"
	RugoTOK_0021     = Symbol(35)  // '!'
	RugoTOK_0025     = Symbol(36)  // '%'
	RugoTOK_0028     = Symbol(37)  // '('
	RugoTOK_0029     = Symbol(38)  // ')'
	RugoTOK_002a     = Symbol(39)  // '*'
	RugoTOK_002b     = Symbol(40)  // '+'
	RugoTOK_002c     = Symbol(41)  // ','
	RugoTOK_002d     = Symbol(42)  // '-'
	RugoTOK_002e     = Symbol(43)  // '.'
	RugoTOK_002f     = Symbol(44)  // '/'
	RugoTOK_003a     = Symbol(45)  // ':'
	RugoTOK_003b     = Symbol(46)  // ';'
	RugoTOK_003d     = Symbol(47)  // '='
	RugoTOK_005b     = Symbol(48)  // '['
	RugoTOK_005d     = Symbol(49)  // ']'
	RugoTOK_007b     = Symbol(50)  // '{'
	RugoTOK_007d     = Symbol(51)  // '}'
	Rugocomp_op      = Symbol(52)  // comp_op
	Rugofloat_lit    = Symbol(53)  // float_lit
	Rugoident        = Symbol(54)  // ident
	Rugointeger      = Symbol(55)  // integer
	Rugoraw_str_lit  = Symbol(56)  // raw_str_lit
	Rugostr_lit      = Symbol(57)  // str_lit
	Rugowhite_space  = Symbol(58)  // white_space
	RugoProgram      = Symbol(59)  // Program
	RugoStatement    = Symbol(60)  // Statement
	RugoUseStmt      = Symbol(61)  // UseStmt
	RugoImportStmt   = Symbol(62)  // ImportStmt
	RugoRequireStmt  = Symbol(63)  // RequireStmt
	RugoEmbedStmt    = Symbol(64)  // EmbedStmt
	RugoSandboxStmt  = Symbol(65)  // SandboxStmt
	RugoSandboxPerm  = Symbol(66)  // SandboxPerm
	RugoSandboxList  = Symbol(67)  // SandboxList
	RugoFuncDef      = Symbol(68)  // FuncDef
	RugoTestDef      = Symbol(69)  // TestDef
	RugoBenchDef     = Symbol(70)  // BenchDef
	RugoParamList    = Symbol(71)  // ParamList
	RugoParam        = Symbol(72)  // Param
	RugoBody         = Symbol(73)  // Body
	RugoIfStmt       = Symbol(74)  // IfStmt
	RugoCaseExpr     = Symbol(75)  // CaseExpr
	RugoExprList     = Symbol(76)  // ExprList
	RugoWhileStmt    = Symbol(77)  // WhileStmt
	RugoForStmt      = Symbol(78)  // ForStmt
	RugoBreakStmt    = Symbol(79)  // BreakStmt
	RugoNextStmt     = Symbol(80)  // NextStmt
	RugoReturnStmt   = Symbol(81)  // ReturnStmt
	RugoAssignOrExpr = Symbol(82)  // AssignOrExpr
	RugoExpr         = Symbol(83)  // Expr
	RugoOrExpr       = Symbol(84)  // OrExpr
	RugoAndExpr      = Symbol(85)  // AndExpr
	RugoCompExpr     = Symbol(86)  // CompExpr
	RugoAddExpr      = Symbol(87)  // AddExpr
	RugoMulExpr      = Symbol(88)  // MulExpr
	RugoUnaryExpr    = Symbol(89)  // UnaryExpr
	RugoPostfix      = Symbol(90)  // Postfix
	RugoSuffix       = Symbol(91)  // Suffix
	RugoArgList      = Symbol(92)  // ArgList
	RugoPrimary      = Symbol(93)  // Primary
	RugoTryExpr      = Symbol(94)  // TryExpr
	RugoSpawnExpr    = Symbol(95)  // SpawnExpr
	RugoParallelExpr = Symbol(96)  // ParallelExpr
	RugoFnExpr       = Symbol(97)  // FnExpr
	RugoArrayLit     = Symbol(98)  // ArrayLit
	RugoHashLit      = Symbol(99)  // HashLit
	RugoHashEntry    = Symbol(100) // HashEntry
)

Symbols

View Source
const RugoSymbolNames = "" /* 714-byte string literal not displayed */

Variables

View Source
var Source []byte

Source contains the parser source code for embedding into the AST cache.

View Source
var SymbolIndex = [...]uint16{} /* 102 elements not displayed */

Functions

This section is empty.

Types

type Parser

type Parser struct {
	// contains filtered or unexported fields
}

func (*Parser) AddExpr

func (p *Parser) AddExpr() (r []int32)

AddExpr grammar:

AddExpr     = MulExpr { ('+' | '-') MulExpr } .

State 0
	on  "case", "false", "fn", "nil", "parallel", "spawn", "true", "try", '!', '(', '-', '[', '{', float_lit, ident, integer, raw_str_lit, str_lit
		call MulExpr and goto state 1
State 1
	Accept
	on  '+', '-'
		shift and goto state 0

AddExpr is used internally from Parse.

func (*Parser) AndExpr

func (p *Parser) AndExpr() (r []int32)

AndExpr grammar:

AndExpr     = CompExpr { "&&" CompExpr } .

State 0
	on  "case", "false", "fn", "nil", "parallel", "spawn", "true", "try", '!', '(', '-', '[', '{', float_lit, ident, integer, raw_str_lit, str_lit
		call CompExpr and goto state 1
State 1
	Accept
	on  "&&"
		shift and goto state 0

AndExpr is used internally from Parse.

func (*Parser) ArgList

func (p *Parser) ArgList() (r []int32)

ArgList grammar:

ArgList     = Expr { ',' Expr } .

State 0
	on  "case", "false", "fn", "nil", "parallel", "spawn", "true", "try", '!', '(', '-', '[', '{', float_lit, ident, integer, raw_str_lit, str_lit
		call Expr and goto state 1
State 1
	Accept
	on  ','
		shift and goto state 0

ArgList is used internally from Parse.

func (*Parser) ArrayLit

func (p *Parser) ArrayLit() (r []int32)

ArrayLit grammar:

ArrayLit    = '[' [ Expr { ',' Expr } ] ']' .

State 0
	on  '['
		shift and goto state 1
State 1
	on  ']'
		shift and goto state 2
	on  "case", "false", "fn", "nil", "parallel", "spawn", "true", "try", '!', '(', '-', '[', '{', float_lit, ident, integer, raw_str_lit, str_lit
		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  "case", "false", "fn", "nil", "parallel", "spawn", "true", "try", '!', '(', '-', '[', '{', float_lit, ident, integer, raw_str_lit, str_lit
		call Expr and goto state 3

ArrayLit is used internally from Parse.

func (*Parser) AssignOrExpr

func (p *Parser) AssignOrExpr() (r []int32)

AssignOrExpr grammar:

AssignOrExpr = Expr [ '=' Expr ] .

State 0
	on  "case", "false", "fn", "nil", "parallel", "spawn", "true", "try", '!', '(', '-', '[', '{', float_lit, ident, integer, raw_str_lit, str_lit
		call Expr and goto state 1
State 1
	Accept
	on  '='
		shift and goto state 2
State 2
	on  "case", "false", "fn", "nil", "parallel", "spawn", "true", "try", '!', '(', '-', '[', '{', float_lit, ident, integer, raw_str_lit, str_lit
		call Expr and goto state 3
State 3
	Accept

AssignOrExpr is used internally from Parse.

func (*Parser) BenchDef

func (p *Parser) BenchDef() (r []int32)

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", "case", "def", "embed", "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
		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

func (p *Parser) Body() (r []int32)

Body grammar:

Body        = { Statement | ';' } .

State 0
	Accept
	on  ';'
		shift and goto state 1
	on  "bench", "break", "case", "def", "embed", "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
		call Statement and goto state 1
State 1
	Accept
	on  ';'
		shift and goto state 1
	on  "bench", "break", "case", "def", "embed", "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
		call Statement and goto state 1

Body is used internally from Parse.

func (*Parser) BreakStmt

func (p *Parser) BreakStmt() (r []int32)

BreakStmt grammar:

BreakStmt   = "break" .

State 0
	on  "break"
		shift and goto state 1
State 1
	Accept

BreakStmt is used internally from Parse.

func (*Parser) CaseExpr added in v0.27.0

func (p *Parser) CaseExpr() (r []int32)

CaseExpr grammar:

CaseExpr    = "case" Expr { "of" ExprList ( "->" Expr | Body ) } { "elsif" Expr ( "->" Expr | Body ) } [ "else" ( "->" Expr | Body ) ] "end" .

State 0
	on  "case"
		shift and goto state 1
State 1
	on  "case", "false", "fn", "nil", "parallel", "spawn", "true", "try", '!', '(', '-', '[', '{', float_lit, ident, integer, raw_str_lit, str_lit
		call Expr and goto state 2
State 2
	on  "of"
		shift and goto state 11
	on  "else"
		shift and goto state 3
	on  "end"
		shift and goto state 6
	on  "elsif"
		shift and goto state 7
State 3
	on  "->"
		shift and goto state 4
	on  "end"
		shift and goto state 6
	on  "bench", "break", "case", "def", "embed", "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
		call Body and goto state 5
State 4
	on  "case", "false", "fn", "nil", "parallel", "spawn", "true", "try", '!', '(', '-', '[', '{', float_lit, ident, integer, raw_str_lit, str_lit
		call Expr and goto state 5
State 5
	on  "end"
		shift and goto state 6
State 6
	Accept
State 7
	on  "case", "false", "fn", "nil", "parallel", "spawn", "true", "try", '!', '(', '-', '[', '{', float_lit, ident, integer, raw_str_lit, str_lit
		call Expr and goto state 8
State 8
	on  "else"
		shift and goto state 3
	on  "end"
		shift and goto state 6
	on  "elsif"
		shift and goto state 7
	on  "->"
		shift and goto state 9
	on  "bench", "break", "case", "def", "embed", "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
		call Body and goto state 10
State 9
	on  "case", "false", "fn", "nil", "parallel", "spawn", "true", "try", '!', '(', '-', '[', '{', float_lit, ident, integer, raw_str_lit, str_lit
		call Expr and goto state 10
State 10
	on  "else"
		shift and goto state 3
	on  "end"
		shift and goto state 6
	on  "elsif"
		shift and goto state 7
State 11
	on  "case", "false", "fn", "nil", "parallel", "spawn", "true", "try", '!', '(', '-', '[', '{', float_lit, ident, integer, raw_str_lit, str_lit
		call ExprList and goto state 12
State 12
	on  "of"
		shift and goto state 11
	on  "->"
		shift and goto state 1
	on  "else"
		shift and goto state 3
	on  "end"
		shift and goto state 6
	on  "elsif"
		shift and goto state 7
	on  "bench", "break", "case", "def", "embed", "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
		call Body and goto state 2

CaseExpr is used internally from Parse.

func (*Parser) CompExpr

func (p *Parser) CompExpr() (r []int32)

CompExpr grammar:

CompExpr    = AddExpr [ comp_op AddExpr ] .

State 0
	on  "case", "false", "fn", "nil", "parallel", "spawn", "true", "try", '!', '(', '-', '[', '{', float_lit, ident, integer, raw_str_lit, str_lit
		call AddExpr and goto state 1
State 1
	Accept
	on  comp_op
		shift and goto state 2
State 2
	on  "case", "false", "fn", "nil", "parallel", "spawn", "true", "try", '!', '(', '-', '[', '{', float_lit, ident, integer, raw_str_lit, str_lit
		call AddExpr and goto state 3
State 3
	Accept

CompExpr is used internally from Parse.

func (*Parser) EOF

func (p *Parser) EOF() bool

EOF reports whether the parser lookahead token is EOF.

func (*Parser) EmbedStmt added in v0.28.0

func (p *Parser) EmbedStmt() (r []int32)

EmbedStmt grammar:

EmbedStmt   = "embed" str_lit "as" ident .

State 0
	on  "embed"
		shift and goto state 1
State 1
	on  str_lit
		shift and goto state 2
State 2
	on  "as"
		shift and goto state 3
State 3
	on  ident
		shift and goto state 4
State 4
	Accept

EmbedStmt is used internally from Parse.

func (*Parser) Expr

func (p *Parser) Expr() (r []int32)

Expr grammar:

# Expressions (lowest to highest precedence)
Expr        = OrExpr .

State 0
	on  "case", "false", "fn", "nil", "parallel", "spawn", "true", "try", '!', '(', '-', '[', '{', float_lit, ident, integer, raw_str_lit, str_lit
		call OrExpr and goto state 1
State 1
	Accept

Expr is used internally from Parse.

func (*Parser) ExprList added in v0.27.0

func (p *Parser) ExprList() (r []int32)

ExprList grammar:

ExprList    = Expr { ',' Expr } .

State 0
	on  "case", "false", "fn", "nil", "parallel", "spawn", "true", "try", '!', '(', '-', '[', '{', float_lit, ident, integer, raw_str_lit, str_lit
		call Expr and goto state 1
State 1
	Accept
	on  ','
		shift and goto state 0

ExprList is used internally from Parse.

func (*Parser) FnExpr

func (p *Parser) FnExpr() (r []int32)

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
		call ParamList and goto state 6
State 3
	on  "end"
		shift and goto state 4
	on  "bench", "break", "case", "def", "embed", "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
		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

func (p *Parser) ForStmt() (r []int32)

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  "case", "false", "fn", "nil", "parallel", "spawn", "true", "try", '!', '(', '-', '[', '{', float_lit, ident, integer, raw_str_lit, str_lit
		call Expr and goto state 4
State 4
	on  "end"
		shift and goto state 5
	on  "bench", "break", "case", "def", "embed", "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
		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

func (p *Parser) FuncDef() (r []int32)

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
		call ParamList and goto state 7
State 4
	on  "end"
		shift and goto state 5
	on  "bench", "break", "case", "def", "embed", "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
		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

func (p *Parser) HashEntry() (r []int32)

HashEntry grammar:

HashEntry   = Expr "=>" Expr .

State 0
	on  "case", "false", "fn", "nil", "parallel", "spawn", "true", "try", '!', '(', '-', '[', '{', float_lit, ident, integer, raw_str_lit, str_lit
		call Expr and goto state 1
State 1
	on  "=>"
		shift and goto state 2
State 2
	on  "case", "false", "fn", "nil", "parallel", "spawn", "true", "try", '!', '(', '-', '[', '{', float_lit, ident, integer, raw_str_lit, str_lit
		call Expr and goto state 3
State 3
	Accept

HashEntry is used internally from Parse.

func (*Parser) HashLit

func (p *Parser) HashLit() (r []int32)

HashLit grammar:

HashLit     = '{' [ HashEntry { ',' HashEntry } ] '}' .

State 0
	on  '{'
		shift and goto state 1
State 1
	on  '}'
		shift and goto state 2
	on  "case", "false", "fn", "nil", "parallel", "spawn", "true", "try", '!', '(', '-', '[', '{', float_lit, ident, integer, raw_str_lit, str_lit
		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  "case", "false", "fn", "nil", "parallel", "spawn", "true", "try", '!', '(', '-', '[', '{', float_lit, ident, integer, raw_str_lit, str_lit
		call HashEntry and goto state 3

HashLit is used internally from Parse.

func (*Parser) IfStmt

func (p *Parser) IfStmt() (r []int32)

IfStmt grammar:

IfStmt      = "if" Expr Body { "elsif" Expr Body } [ "else" Body ] "end" .

State 0
	on  "if"
		shift and goto state 1
State 1
	on  "case", "false", "fn", "nil", "parallel", "spawn", "true", "try", '!', '(', '-', '[', '{', float_lit, ident, integer, raw_str_lit, str_lit
		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", "case", "def", "embed", "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
		call Body and goto state 6
State 3
	on  "end"
		shift and goto state 4
	on  "bench", "break", "case", "def", "embed", "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
		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

func (p *Parser) ImportStmt() (r []int32)

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

func (p *Parser) MulExpr() (r []int32)

MulExpr grammar:

MulExpr     = UnaryExpr { ('*' | '/' | '%') UnaryExpr } .

State 0
	on  "case", "false", "fn", "nil", "parallel", "spawn", "true", "try", '!', '(', '-', '[', '{', float_lit, ident, integer, raw_str_lit, str_lit
		call UnaryExpr and goto state 1
State 1
	Accept
	on  '%', '*', '/'
		shift and goto state 0

MulExpr is used internally from Parse.

func (*Parser) NextStmt

func (p *Parser) NextStmt() (r []int32)

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

func (p *Parser) OrExpr() (r []int32)

OrExpr grammar:

OrExpr      = AndExpr { "||" AndExpr } .

State 0
	on  "case", "false", "fn", "nil", "parallel", "spawn", "true", "try", '!', '(', '-', '[', '{', float_lit, ident, integer, raw_str_lit, str_lit
		call AndExpr and goto state 1
State 1
	Accept
	on  "||"
		shift and goto state 0

OrExpr is used internally from Parse.

func (*Parser) ParallelExpr

func (p *Parser) ParallelExpr() (r []int32)

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", "case", "def", "embed", "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
		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

func (p *Parser) Param() (r []int32)

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  "case", "false", "fn", "nil", "parallel", "spawn", "true", "try", '!', '(', '-', '[', '{', float_lit, ident, integer, raw_str_lit, str_lit
		call Expr and goto state 3
State 3
	Accept

Param is used internally from Parse.

func (*Parser) ParamList

func (p *Parser) ParamList() (r []int32)

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

func (p *Parser) Parse(name string, src []byte) (ast []int32, err error)

Parse parses 'src'. 'src' becomes "owned" by the parser and must not be mutated afterwards.

func (*Parser) Postfix

func (p *Parser) Postfix() (r []int32)

Postfix grammar:

Postfix     = Primary { Suffix } .

State 0
	on  "case", "false", "fn", "nil", "parallel", "spawn", "true", "try", '(', '[', '{', float_lit, ident, integer, raw_str_lit, str_lit
		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

func (p *Parser) Primary() (r []int32)

Primary grammar:

# Primary expressions
Primary     = ident
            | integer
            | float_lit
            | str_lit
            | raw_str_lit
            | "true"
            | "false"
            | "nil"
            | ArrayLit
            | HashLit
            | CaseExpr
            | 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  "case"
		call CaseExpr and goto state 1
	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  "case", "false", "fn", "nil", "parallel", "spawn", "true", "try", '!', '(', '-', '[', '{', float_lit, ident, integer, raw_str_lit, str_lit
		call Expr and goto state 3
State 3
	on  ')'
		shift and goto state 1

Primary is used internally from Parse.

func (*Parser) Program

func (p *Parser) Program() (r []int32)

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", "case", "def", "embed", "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
		call Statement and goto state 1
State 1
	Accept
	on  ';'
		shift and goto state 1
	on  "bench", "break", "case", "def", "embed", "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
		call Statement and goto state 1

Program is used internally from Parse.

func (*Parser) RequireStmt

func (p *Parser) RequireStmt() (r []int32)

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

func (p *Parser) ReturnStmt() (r []int32)

ReturnStmt grammar:

ReturnStmt  = "return" [ Expr ] .

State 0
	on  "return"
		shift and goto state 1
State 1
	Accept
	on  "case", "false", "fn", "nil", "parallel", "spawn", "true", "try", '!', '(', '-', '[', '{', float_lit, ident, integer, raw_str_lit, str_lit
		call Expr and goto state 2
State 2
	Accept

ReturnStmt is used internally from Parse.

func (*Parser) SandboxList added in v0.18.0

func (p *Parser) SandboxList() (r []int32)

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

func (p *Parser) SandboxPerm() (r []int32)

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

func (p *Parser) SandboxStmt() (r []int32)

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) Scan

func (p *Parser) Scan() (r scanner.Token)

Scan is used internally from Parse.

func (*Parser) SpawnExpr

func (p *Parser) SpawnExpr() (r []int32)

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", "case", "def", "embed", "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
		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

func (p *Parser) Statement() (r []int32)

Statement grammar:

# Statements
Statement   = UseStmt
            | ImportStmt
            | RequireStmt
            | EmbedStmt
            | 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  "embed"
		call EmbedStmt 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  "case", "false", "fn", "nil", "parallel", "spawn", "true", "try", '!', '(', '-', '[', '{', float_lit, ident, integer, raw_str_lit, str_lit
		call AssignOrExpr and goto state 1
State 1
	Accept

Statement is used internally from Parse.

func (*Parser) Suffix

func (p *Parser) Suffix() (r []int32)

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  "case", "false", "fn", "nil", "parallel", "spawn", "true", "try", '!', '(', '-', '[', '{', float_lit, ident, integer, raw_str_lit, str_lit
		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  "case", "false", "fn", "nil", "parallel", "spawn", "true", "try", '!', '(', '-', '[', '{', float_lit, ident, integer, raw_str_lit, str_lit
		call Expr and goto state 6
State 6
	on  ']'
		shift and goto state 2
	on  ','
		shift and goto state 7
State 7
	on  "case", "false", "fn", "nil", "parallel", "spawn", "true", "try", '!', '(', '-', '[', '{', float_lit, ident, integer, raw_str_lit, str_lit
		call Expr and goto state 8
State 8
	on  ']'
		shift and goto state 2

Suffix is used internally from Parse.

func (*Parser) TestDef

func (p *Parser) TestDef() (r []int32)

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", "case", "def", "embed", "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
		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) Token

func (p *Parser) Token(n int32) (r scanner.Token)

Token returns the n-th token in 'p'. Token panics if 'n' is out of range.

func (*Parser) TryExpr

func (p *Parser) TryExpr() (r []int32)

TryExpr grammar:

TryExpr      = "try" Expr "or" ident Body "end" .

State 0
	on  "try"
		shift and goto state 1
State 1
	on  "case", "false", "fn", "nil", "parallel", "spawn", "true", "try", '!', '(', '-', '[', '{', float_lit, ident, integer, raw_str_lit, str_lit
		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", "case", "def", "embed", "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
		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

func (p *Parser) UnaryExpr() (r []int32)

UnaryExpr grammar:

UnaryExpr   = '!' Postfix | '-' Postfix | Postfix .

State 0
	on  '!', '-'
		shift and goto state 1
	on  "case", "false", "fn", "nil", "parallel", "spawn", "true", "try", '(', '[', '{', float_lit, ident, integer, raw_str_lit, str_lit
		call Postfix and goto state 2
State 1
	on  "case", "false", "fn", "nil", "parallel", "spawn", "true", "try", '(', '[', '{', float_lit, ident, integer, raw_str_lit, str_lit
		call Postfix and goto state 2
State 2
	Accept

UnaryExpr is used internally from Parse.

func (*Parser) UseStmt

func (p *Parser) UseStmt() (r []int32)

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

func (p *Parser) WhileStmt() (r []int32)

WhileStmt grammar:

WhileStmt   = "while" Expr Body "end" .

State 0
	on  "while"
		shift and goto state 1
State 1
	on  "case", "false", "fn", "nil", "parallel", "spawn", "true", "try", '!', '(', '-', '[', '{', float_lit, ident, integer, raw_str_lit, str_lit
		call Expr and goto state 2
State 2
	on  "end"
		shift and goto state 3
	on  "bench", "break", "case", "def", "embed", "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
		call Body and goto state 4
State 3
	Accept
State 4
	on  "end"
		shift and goto state 3

WhileStmt is used internally from Parse.

type Symbol

type Symbol int32

func (Symbol) String

func (s Symbol) String() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL