parser

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2022 License: BSD-3-Clause-Clear Imports: 15 Imported by: 0

Documentation

Overview

Code generated by goyacc -l -o ruby.go ruby.y. DO NOT EDIT.

compiled from https://github.com/whitequark/parser/blob/master/lib/parser/lexer/stack_state.rb

Index

Constants

View Source
const ADDASSIGN = 57350
View Source
const ALIAS = 57419
View Source
const AND = 57370
View Source
const ASSIGN = 57347
View Source
const ASTERISK = 57377
View Source
const BANG = 57382
View Source
const BEGIN = 57398
View Source
const BREAK = 57416
View Source
const CARET = 57372
View Source
const CASE = 57411
View Source
const CLASS = 57390
View Source
const COLON = 57356
View Source
const COMMA = 57437
View Source
const COMMENT = 57430
View Source
const CONSTANT = 57408
View Source
const CVAR = 57426
View Source
const DEF = 57392
View Source
const DIVASSIGN = 57352
View Source
const DO = 57420
View Source
const DOT = 57432
View Source
const DOT2 = 57357
View Source
const DOT3 = 57358
View Source
const DO_BLOCK = 57422
View Source
const DO_COND = 57421
View Source
const ELSE = 57402
View Source
const ELSIF = 57410
View Source
const END = 57393
View Source
const ENSURE = 57409
View Source
const EQ = 57362
View Source
const FALSE = 57389
View Source
const FLOAT = 57387
View Source
const FOR = 57415
View Source
const GT = 57366
View Source
const GTE = 57367
View Source
const GVAR = 57427
View Source
const HASHROCKET = 57459
View Source
const IDENT = 57429
View Source
const IF = 57394
View Source
const IF_MOD = 57395
View Source
const INT = 57386
View Source
const INTERPBEG = 57440
View Source
const INTERPEND = 57441
View Source
const IVAR = 57425
View Source
const LABEL = 57431
View Source
const LBRACE = 57433
View Source
const LBRACEBLOCK = 57434
View Source
const LBRACKET = 57453
View Source
const LBRACKETSTART = 57454
View Source
const LOGICALAND = 57360
View Source
const LOGICALOR = 57359
View Source
const LOWEST = 57346
View Source
const LPAREN = 57456
View Source
const LPARENSTART = 57457
View Source
const LSHIFT = 57373
View Source
const LSHIFTASSIGN = 57353
View Source
const LT = 57368
View Source
const LTE = 57369
View Source
const MATCH = 57364
View Source
const METHODIDENT = 57428
View Source
const MINUS = 57376
View Source
const MODASSIGN = 57348
View Source
const MODULE = 57391
View Source
const MODULO = 57379
View Source
const MULASSIGN = 57349
View Source
const (
	Main = "__main__"
)
View Source
const NEQ = 57363
View Source
const NEWLINE = 57436
View Source
const NEXT = 57417
View Source
const NIL = 57383
View Source
const NOTMATCH = 57365
View Source
const PIPE = 57371
View Source
const PLUS = 57375
View Source
const POW = 57381
View Source
const PRIVATE = 57423
View Source
const PROTECTED = 57424
View Source
const QMARK = 57355
View Source
const RAWSTRINGBEG = 57446
View Source
const RAWSTRINGEND = 57447
View Source
const RAWWORDSBEG = 57449
View Source
const RAWXSTRINGBEG = 57451
View Source
const RBRACE = 57435
View Source
const RBRACKET = 57455
View Source
const REGEXBEG = 57443
View Source
const REGEXEND = 57444
View Source
const REGEXPOPT = 57445
View Source
const RESCUE = 57399
View Source
const RESCUE_MOD = 57400
View Source
const RETURN = 57405
View Source
const RPAREN = 57458
View Source
const RSHIFT = 57374
View Source
const RSHIFTASSIGN = 57354
View Source
const SCOPE = 57460
View Source
const SELF = 57407
View Source
const SEMICOLON = 57452
View Source
const SLASH = 57378
View Source
const SPACESHIP = 57361
View Source
const STRING = 57385
View Source
const STRINGBEG = 57438
View Source
const STRINGBODY = 57442
View Source
const STRINGEND = 57439
View Source
const SUBASSIGN = 57351
View Source
const SUPER = 57418
View Source
const SYMBOL = 57384
View Source
const THEN = 57401
View Source
const TRUE = 57388
View Source
const UNARY_NUM = 57380
View Source
const UNLESS = 57396
View Source
const UNLESS_MOD = 57397
View Source
const UNTIL = 57413
View Source
const UNTIL_MOD = 57414
View Source
const WHEN = 57412
View Source
const WHILE = 57403
View Source
const WHILE_MOD = 57404
View Source
const WORDSBEG = 57448
View Source
const XSTRINGBEG = 57450
View Source
const YIELD = 57406

Variables

View Source
var BadLocal = new(local)
View Source
var Illegal int = 99999999

Functions

func DebugLevel

func DebugLevel() int

func GetType

func GetType(n Node, scope ScopeChain, class *Class) (t types.Type, err error)

func Indent

func Indent(strs ...string) string

func LogDebug

func LogDebug(verbosity int, format string, v ...interface{})

Types

type ArgsNode

type ArgsNode []Node

func (ArgsNode) Copy

func (n ArgsNode) Copy() Node

func (ArgsNode) FindByName

func (n ArgsNode) FindByName(name string) (Node, error)

func (ArgsNode) LineNo

func (n ArgsNode) LineNo() int

func (ArgsNode) SetType

func (n ArgsNode) SetType(t types.Type)

func (ArgsNode) String

func (n ArgsNode) String() string

func (ArgsNode) TargetType

func (n ArgsNode) TargetType(locals ScopeChain, class *Class) (types.Type, error)

func (ArgsNode) Type

func (n ArgsNode) Type() types.Type

Wrong but dummy for satisfying interface

type ArrayNode

type ArrayNode struct {
	Args ArgsNode
	// contains filtered or unexported fields
}

func (*ArrayNode) Copy

func (n *ArrayNode) Copy() Node

func (*ArrayNode) LineNo

func (n *ArrayNode) LineNo() int

func (*ArrayNode) SetType

func (n *ArrayNode) SetType(t types.Type)

func (*ArrayNode) String

func (n *ArrayNode) String() string

func (*ArrayNode) TargetType

func (n *ArrayNode) TargetType(locals ScopeChain, class *Class) (types.Type, error)

func (*ArrayNode) Type

func (n *ArrayNode) Type() types.Type

type AssignmentNode

type AssignmentNode struct {
	Left         []Node
	Right        []Node
	Reassignment bool
	OpAssignment bool
	SetterCall   bool
	// contains filtered or unexported fields
}

func (*AssignmentNode) Copy

func (n *AssignmentNode) Copy() Node

func (*AssignmentNode) LineNo

func (n *AssignmentNode) LineNo() int

func (*AssignmentNode) SetType

func (n *AssignmentNode) SetType(t types.Type)

func (*AssignmentNode) String

func (n *AssignmentNode) String() string

func (*AssignmentNode) TargetType

func (n *AssignmentNode) TargetType(scope ScopeChain, class *Class) (types.Type, error)

func (*AssignmentNode) Type

func (n *AssignmentNode) Type() types.Type

type Block

type Block struct {
	Body   *Body
	Scope  ScopeChain
	Method *Method
	*ParamList
}

func (*Block) Copy

func (b *Block) Copy() *Block

func (*Block) String

func (b *Block) String() string

func (*Block) Type

func (b *Block) Type() types.Type

type BlockParam

type BlockParam struct {
	Name       string
	ReturnType types.Type
	*ParamList
}

type Body

type Body struct {
	Statements      Statements
	ReturnType      types.Type
	ExplicitReturns []*ReturnNode
}

func (*Body) InferReturnType

func (b *Body) InferReturnType(scope ScopeChain, class *Class) error

func (*Body) String

func (n *Body) String() string

type BooleanNode

type BooleanNode struct {
	Val string
	// contains filtered or unexported fields
}

func (*BooleanNode) Copy

func (n *BooleanNode) Copy() Node

basic literals should never needed to be mutated by a client that's copied a subtree, so these methods are here to satisfy the interface only.

func (*BooleanNode) LineNo

func (n *BooleanNode) LineNo() int

func (*BooleanNode) SetType

func (n *BooleanNode) SetType(t types.Type)

func (*BooleanNode) String

func (n *BooleanNode) String() string

func (*BooleanNode) TargetType

func (n *BooleanNode) TargetType(locals ScopeChain, class *Class) (types.Type, error)

func (*BooleanNode) Type

func (n *BooleanNode) Type() types.Type

type BracketAccessNode

type BracketAccessNode struct {
	Composite Node
	Args      ArgsNode
	// contains filtered or unexported fields
}

func (*BracketAccessNode) Copy

func (n *BracketAccessNode) Copy() Node

func (*BracketAccessNode) LineNo

func (n *BracketAccessNode) LineNo() int

func (*BracketAccessNode) SetType

func (n *BracketAccessNode) SetType(t types.Type)

func (*BracketAccessNode) String

func (n *BracketAccessNode) String() string

func (*BracketAccessNode) TargetType

func (n *BracketAccessNode) TargetType(locals ScopeChain, class *Class) (types.Type, error)

func (*BracketAccessNode) Type

func (n *BracketAccessNode) Type() types.Type

type BracketAssignmentNode

type BracketAssignmentNode struct {
	Composite Node
	Args      ArgsNode
	// contains filtered or unexported fields
}

func (*BracketAssignmentNode) Copy

func (n *BracketAssignmentNode) Copy() Node

func (*BracketAssignmentNode) LineNo

func (n *BracketAssignmentNode) LineNo() int

func (*BracketAssignmentNode) SetType

func (n *BracketAssignmentNode) SetType(t types.Type)

func (*BracketAssignmentNode) String

func (n *BracketAssignmentNode) String() string

func (*BracketAssignmentNode) TargetType

func (n *BracketAssignmentNode) TargetType(locals ScopeChain, class *Class) (types.Type, error)

func (*BracketAssignmentNode) Type

func (n *BracketAssignmentNode) Type() types.Type

type CVarNode

type CVarNode struct {
	Val string
	// contains filtered or unexported fields
}

func (*CVarNode) Copy

func (n *CVarNode) Copy() Node

func (*CVarNode) LineNo

func (n *CVarNode) LineNo() int

func (*CVarNode) SetType

func (n *CVarNode) SetType(t types.Type)

func (*CVarNode) String

func (n *CVarNode) String() string

func (*CVarNode) TargetType

func (n *CVarNode) TargetType(locals ScopeChain, class *Class) (types.Type, error)

func (*CVarNode) Type

func (n *CVarNode) Type() types.Type

type CaseNode

type CaseNode struct {
	Value             Node
	Whens             []*WhenNode
	RequiresExpansion bool
	// contains filtered or unexported fields
}

func (*CaseNode) Copy

func (n *CaseNode) Copy() Node

func (*CaseNode) LineNo

func (n *CaseNode) LineNo() int

func (*CaseNode) SetType

func (n *CaseNode) SetType(t types.Type)

func (*CaseNode) String

func (n *CaseNode) String() string

func (*CaseNode) TargetType

func (n *CaseNode) TargetType(locals ScopeChain, class *Class) (types.Type, error)

func (*CaseNode) Type

func (n *CaseNode) Type() types.Type

type Class

type Class struct {
	Superclass string
	Statements Statements
	MethodSet  *MethodSet

	Body Body

	Constants []*Constant
	Module    *Module
	Private   bool
	// contains filtered or unexported fields
}

func (*Class) AddConstant

func (cls *Class) AddConstant(constant *Constant)

func (*Class) AddIVar

func (cls *Class) AddIVar(name string, ivar *IVar) error

func (*Class) AddIVars

func (cls *Class) AddIVars(args ArgsNode, readable, writeable bool)

func (*Class) AddStatement

func (cls *Class) AddStatement(stmt Node)

func (*Class) BuildType

func (cls *Class) BuildType(outerScope ScopeChain) *types.Class

func (*Class) ConstGet

func (cls *Class) ConstGet(name string) (Const, error)

func (*Class) Constant

func (cls *Class) Constant()

func (*Class) Copy

func (cls *Class) Copy() Node

func (*Class) GenerateMethod

func (cls *Class) GenerateMethod(m *Method, class *types.Class)

func (*Class) Get

func (cls *Class) Get(name string) (Local, bool)

ClassNode implements Scope with these methods

func (*Class) GetAncestorMethod

func (cls *Class) GetAncestorMethod(methodName string) (*Class, *Method, bool)

func (*Class) IVars

func (cls *Class) IVars(skip map[string]bool) []*IVar

func (*Class) LineNo

func (cls *Class) LineNo() int

func (*Class) Methods

func (cls *Class) Methods(skip map[string]bool) []*Method

func (*Class) Name

func (cls *Class) Name() string

func (*Class) Parent

func (cls *Class) Parent() *Class

func (*Class) QualifiedName

func (cls *Class) QualifiedName() string

func (*Class) Set

func (cls *Class) Set(string, Local)

func (*Class) SetType

func (cls *Class) SetType(t types.Type)

func (*Class) String

func (cls *Class) String() string

func (*Class) TakesConstants

func (cls *Class) TakesConstants() bool

func (*Class) TargetType

func (cls *Class) TargetType(scope ScopeChain, class *Class) (types.Type, error)

func (*Class) Type

func (cls *Class) Type() types.Type

type Comment

type Comment struct {
	Text   string
	LineNo int
}

type Condition

type Condition struct {
	Condition Node
	True      Statements
	False     Node
	// contains filtered or unexported fields
}

func (*Condition) Copy

func (n *Condition) Copy() Node

func (*Condition) LineNo

func (n *Condition) LineNo() int

func (*Condition) SetType

func (n *Condition) SetType(t types.Type)

func (*Condition) String

func (n *Condition) String() string

func (*Condition) TargetType

func (n *Condition) TargetType(locals ScopeChain, class *Class) (types.Type, error)

func (*Condition) Type

func (n *Condition) Type() types.Type

type Const

type Const interface {
	Constant()
	Name() string
	Type() types.Type
}

type Constant

type Constant struct {
	Val       Node
	Namespace Namespace
	// contains filtered or unexported fields
}

func (*Constant) Constant

func (constant *Constant) Constant()

func (*Constant) Name

func (constant *Constant) Name() string

func (*Constant) QualifiedName

func (constant *Constant) QualifiedName() string

func (*Constant) String

func (constant *Constant) String() string

func (*Constant) Type

func (constant *Constant) Type() types.Type

type ConstantNode

type ConstantNode struct {
	Val       string
	Namespace string
	// contains filtered or unexported fields
}

func (*ConstantNode) Copy

func (n *ConstantNode) Copy() Node

func (*ConstantNode) LineNo

func (n *ConstantNode) LineNo() int

func (*ConstantNode) SetType

func (n *ConstantNode) SetType(t types.Type)

func (*ConstantNode) String

func (n *ConstantNode) String() string

func (*ConstantNode) TargetType

func (n *ConstantNode) TargetType(locals ScopeChain, class *Class) (types.Type, error)

func (*ConstantNode) Type

func (n *ConstantNode) Type() types.Type

type ConstantScope

type ConstantScope interface {
	Scope
	AddConstant(*Constant)
	ConstGet(string) (Const, error)
}

type Float64Node

type Float64Node struct {
	Val string
	// contains filtered or unexported fields
}

func (*Float64Node) Copy

func (n *Float64Node) Copy() Node

func (*Float64Node) LineNo

func (n *Float64Node) LineNo() int

func (Float64Node) SetType

func (n Float64Node) SetType(t types.Type)

func (Float64Node) String

func (n Float64Node) String() string

func (Float64Node) TargetType

func (n Float64Node) TargetType(locals ScopeChain, class *Class) (types.Type, error)

func (Float64Node) Type

func (n Float64Node) Type() types.Type

type GVarNode

type GVarNode struct {
	Val string
	// contains filtered or unexported fields
}

func (*GVarNode) Copy

func (n *GVarNode) Copy() Node

func (*GVarNode) LineNo

func (n *GVarNode) LineNo() int

func (*GVarNode) SetType

func (n *GVarNode) SetType(t types.Type)

func (*GVarNode) String

func (n *GVarNode) String() string

func (*GVarNode) TargetType

func (n *GVarNode) TargetType(locals ScopeChain, class *Class) (types.Type, error)

func (*GVarNode) Type

func (n *GVarNode) Type() types.Type

type HashNode

type HashNode struct {
	Pairs []*KeyValuePair
	// contains filtered or unexported fields
}

func (*HashNode) Copy

func (n *HashNode) Copy() Node

func (*HashNode) LineNo

func (n *HashNode) LineNo() int

func (*HashNode) SetType

func (n *HashNode) SetType(t types.Type)

func (*HashNode) String

func (n *HashNode) String() string

func (*HashNode) TargetType

func (n *HashNode) TargetType(locals ScopeChain, class *Class) (types.Type, error)

func (*HashNode) Type

func (n *HashNode) Type() types.Type

type IVar

type IVar struct {
	Name string

	Readable, Writeable bool
	// contains filtered or unexported fields
}

func (*IVar) Type

func (ivar *IVar) Type() types.Type

type IVarNode

type IVarNode struct {
	Val   string
	Class *Class
	// contains filtered or unexported fields
}

func (*IVarNode) Copy

func (n *IVarNode) Copy() Node

func (*IVarNode) IVar

func (n *IVarNode) IVar() *IVar

func (*IVarNode) LineNo

func (n *IVarNode) LineNo() int

func (*IVarNode) NormalizedVal

func (n *IVarNode) NormalizedVal() string

func (*IVarNode) SetType

func (n *IVarNode) SetType(t types.Type)

func (*IVarNode) String

func (n *IVarNode) String() string

func (*IVarNode) TargetType

func (n *IVarNode) TargetType(locals ScopeChain, class *Class) (types.Type, error)

func (*IVarNode) Type

func (n *IVarNode) Type() types.Type

type IdentNode

type IdentNode struct {
	Val string

	MethodCall *MethodCall
	// contains filtered or unexported fields
}

func (*IdentNode) Copy

func (n *IdentNode) Copy() Node

func (*IdentNode) LineNo

func (n *IdentNode) LineNo() int

func (*IdentNode) SetType

func (n *IdentNode) SetType(t types.Type)

func (*IdentNode) String

func (n *IdentNode) String() string

func (*IdentNode) TargetType

func (n *IdentNode) TargetType(locals ScopeChain, class *Class) (types.Type, error)

func (*IdentNode) Type

func (n *IdentNode) Type() types.Type

type InfixExpressionNode

type InfixExpressionNode struct {
	Operator string
	Left     Node
	Right    Node
	// contains filtered or unexported fields
}

func (*InfixExpressionNode) Copy

func (n *InfixExpressionNode) Copy() Node

func (*InfixExpressionNode) HasMethod

func (n *InfixExpressionNode) HasMethod() bool

func (*InfixExpressionNode) LineNo

func (n *InfixExpressionNode) LineNo() int

func (*InfixExpressionNode) SetType

func (n *InfixExpressionNode) SetType(t types.Type)

func (*InfixExpressionNode) String

func (n *InfixExpressionNode) String() string

func (*InfixExpressionNode) TargetType

func (n *InfixExpressionNode) TargetType(locals ScopeChain, class *Class) (types.Type, error)

func (*InfixExpressionNode) Type

func (n *InfixExpressionNode) Type() types.Type

type IntNode

type IntNode struct {
	Val string
	// contains filtered or unexported fields
}

func (*IntNode) Copy

func (n *IntNode) Copy() Node

func (*IntNode) LineNo

func (n *IntNode) LineNo() int

func (*IntNode) SetType

func (n *IntNode) SetType(t types.Type)

func (*IntNode) String

func (n *IntNode) String() string

func (*IntNode) TargetType

func (n *IntNode) TargetType(locals ScopeChain, class *Class) (types.Type, error)

func (*IntNode) Type

func (n *IntNode) Type() types.Type

type KernelNode

type KernelNode struct{}

Placeholder in AST for Kernel method lookups

func (*KernelNode) Copy

func (n *KernelNode) Copy() Node

func (*KernelNode) LineNo

func (n *KernelNode) LineNo() int

func (*KernelNode) SetType

func (n *KernelNode) SetType(t types.Type)

func (*KernelNode) String

func (n *KernelNode) String() string

func (*KernelNode) TargetType

func (n *KernelNode) TargetType(locals ScopeChain, class *Class) (types.Type, error)

func (*KernelNode) Type

func (n *KernelNode) Type() types.Type

type KeyValuePair

type KeyValuePair struct {
	Key   Node
	Label string
	Value Node
	// contains filtered or unexported fields
}

func (KeyValuePair) Copy

func (n KeyValuePair) Copy() Node

func (*KeyValuePair) LineNo

func (n *KeyValuePair) LineNo() int

func (*KeyValuePair) SetType

func (n *KeyValuePair) SetType(t types.Type)

func (*KeyValuePair) String

func (n *KeyValuePair) String() string

func (*KeyValuePair) TargetType

func (n *KeyValuePair) TargetType(locals ScopeChain, class *Class) (types.Type, error)

func (*KeyValuePair) Type

func (n *KeyValuePair) Type() types.Type

type LexState

type LexState int
const (
	Clear LexState = iota
	InSymbol
	InGlobal
	InFloat
	InNumber
	InCVar
	InIVar
	InPunct
	InInterpString
	InInterp
	InRawString
	InRegex
	OpenBrace
	InEscapeSequence
)

func (LexState) String

func (i LexState) String() string

type Lexer

type Lexer struct {
	*bytes.Buffer
	Root *Root

	State *Stack[LexState]

	StringDelim *Stack[rune]
	// contains filtered or unexported fields
}

func NewLexer

func NewLexer(buf []byte) *Lexer

func (*Lexer) Advance

func (l *Lexer) Advance() (rune, rune, error)

func (*Lexer) AtExprStart

func (l *Lexer) AtExprStart() bool

func (*Lexer) Emit

func (l *Lexer) Emit(t int)

func (*Lexer) Error

func (l *Lexer) Error(e string)

func (*Lexer) Lex

func (l *Lexer) Lex(lval *yySymType) int

func (*Lexer) Peek

func (l *Lexer) Peek() (rune, error)

func (*Lexer) Read

func (l *Lexer) Read() (rune, error)

func (*Lexer) ResetBuffer

func (l *Lexer) ResetBuffer()

func (*Lexer) RewindBuffer

func (l *Lexer) RewindBuffer()

func (*Lexer) Tokenize

func (l *Lexer) Tokenize()

type Local

type Local interface {
	Type() types.Type
}

type Method

type Method struct {
	Receiver Node
	Name     string
	Body     *Body
	*ParamList
	Locals *SimpleScope
	Scope  ScopeChain
	Root   *Root
	Block  *BlockParam

	Private bool
	// contains filtered or unexported fields
}

func NewMethod

func NewMethod(name string, r *Root) *Method

func (*Method) AddParam

func (m *Method) AddParam(p *Param) error

func (*Method) Analyze

func (m *Method) Analyze(ms *MethodSet) error

func (*Method) AnalyzeArguments

func (method *Method) AnalyzeArguments(class *Class, c *MethodCall) error

func (*Method) Copy

func (n *Method) Copy() Node

func (*Method) GoName

func (m *Method) GoName() string

func (*Method) LineNo

func (n *Method) LineNo() int

func (*Method) ReturnType

func (m *Method) ReturnType() types.Type

func (*Method) SetType

func (n *Method) SetType(t types.Type)

func (*Method) String

func (n *Method) String() string

func (*Method) TargetType

func (n *Method) TargetType(locals ScopeChain, class *Class) (types.Type, error)

func (*Method) Type

func (n *Method) Type() types.Type

type MethodCall

type MethodCall struct {
	Receiver   Node
	Method     *Method
	MethodName string
	Args       ArgsNode
	Block      *Block
	RawBlock   string
	Getter     bool
	// contains filtered or unexported fields
}

func (*MethodCall) Copy

func (n *MethodCall) Copy() Node

func (*MethodCall) LineNo

func (n *MethodCall) LineNo() int

func (*MethodCall) PositionalArgs

func (c *MethodCall) PositionalArgs() ArgsNode

func (*MethodCall) ReceiverType

func (c *MethodCall) ReceiverType(scope ScopeChain, class *Class) types.Type

func (*MethodCall) RequiresTransform

func (n *MethodCall) RequiresTransform() bool

func (*MethodCall) SetBlock

func (c *MethodCall) SetBlock(blk *Block)

func (*MethodCall) SetType

func (n *MethodCall) SetType(t types.Type)

func (*MethodCall) String

func (n *MethodCall) String() string

func (*MethodCall) TargetType

func (c *MethodCall) TargetType(scope ScopeChain, class *Class) (types.Type, error)

func (*MethodCall) Type

func (n *MethodCall) Type() types.Type

type MethodSet

type MethodSet struct {
	Methods map[string]*Method
	Order   []string
	Calls   map[string][]*MethodCall
	Class   *Class
	Module  *Module
}

func NewMethodSet

func NewMethodSet() *MethodSet

func (*MethodSet) AddCall

func (ms *MethodSet) AddCall(c *MethodCall)

func (*MethodSet) AddMethod

func (ms *MethodSet) AddMethod(m *Method)

type Module

type Module struct {
	Statements Statements
	MethodSet  *MethodSet

	Parent    *Module
	Constants []*Constant
	Modules   []*Module
	Classes   []*Class
	// contains filtered or unexported fields
}

func (*Module) AddConstant

func (mod *Module) AddConstant(constant *Constant)

func (*Module) ConstGet

func (mod *Module) ConstGet(name string) (Const, error)

func (*Module) Constant

func (mod *Module) Constant()

func (*Module) Copy

func (mod *Module) Copy() Node

func (*Module) Get

func (mod *Module) Get(name string) (Local, bool)

func (*Module) LineNo

func (mod *Module) LineNo() int

func (*Module) Name

func (mod *Module) Name() string

func (*Module) QualifiedName

func (mod *Module) QualifiedName() string

func (*Module) Set

func (mod *Module) Set(string, Local)

func (*Module) SetType

func (mod *Module) SetType(t types.Type)

func (*Module) String

func (mod *Module) String() string

func (*Module) TakesConstants

func (mod *Module) TakesConstants() bool

func (*Module) TargetType

func (mod *Module) TargetType(scope ScopeChain, class *Class) (types.Type, error)

func (*Module) Type

func (mod *Module) Type() types.Type

type Namespace

type Namespace interface {
	QualifiedName() string
}

type NilNode

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

func (*NilNode) Copy

func (n *NilNode) Copy() Node

func (*NilNode) LineNo

func (n *NilNode) LineNo() int

func (*NilNode) SetType

func (n *NilNode) SetType(t types.Type)

func (*NilNode) String

func (n *NilNode) String() string

func (*NilNode) TargetType

func (n *NilNode) TargetType(locals ScopeChain, class *Class) (types.Type, error)

func (*NilNode) Type

func (n *NilNode) Type() types.Type

type Node

type Node interface {
	String() string
	TargetType(ScopeChain, *Class) (types.Type, error)
	Type() types.Type
	SetType(types.Type)
	LineNo() int
	Copy() Node
}

type NoopNode

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

func (*NoopNode) Copy

func (n *NoopNode) Copy() Node

func (*NoopNode) LineNo

func (n *NoopNode) LineNo() int

func (*NoopNode) SetType

func (n *NoopNode) SetType(t types.Type)

func (*NoopNode) String

func (n *NoopNode) String() string

func (*NoopNode) TargetType

func (n *NoopNode) TargetType(locals ScopeChain, class *Class) (types.Type, error)

func (*NoopNode) Type

func (n *NoopNode) Type() types.Type

type NotExpressionNode

type NotExpressionNode struct {
	Arg Node
	// contains filtered or unexported fields
}

func (*NotExpressionNode) Copy

func (n *NotExpressionNode) Copy() Node

func (*NotExpressionNode) LineNo

func (n *NotExpressionNode) LineNo() int

func (*NotExpressionNode) SetType

func (n *NotExpressionNode) SetType(t types.Type)

func (*NotExpressionNode) String

func (n *NotExpressionNode) String() string

func (*NotExpressionNode) TargetType

func (n *NotExpressionNode) TargetType(locals ScopeChain, class *Class) (types.Type, error)

func (*NotExpressionNode) Type

func (n *NotExpressionNode) Type() types.Type

type Param

type Param struct {
	Position int
	Name     string
	Kind     ParamKind

	Default  Node
	Required bool
	// contains filtered or unexported fields
}

func (*Param) Type

func (p *Param) Type() types.Type

type ParamKind

type ParamKind int
const (
	Positional ParamKind = iota
	Named
	Keyword
	ExplicitBlock
)

type ParamList

type ParamList struct {
	Params   []*Param
	ParamMap map[string]*Param
}

func NewParamList

func NewParamList() *ParamList

func (*ParamList) AddParam

func (list *ParamList) AddParam(p *Param) error

func (*ParamList) GetParam

func (list *ParamList) GetParam(i int) (*Param, error)

func (*ParamList) GetParamByName

func (list *ParamList) GetParamByName(s string) *Param

func (*ParamList) PositionalParams

func (list *ParamList) PositionalParams() []*Param

type ParseError

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

func NewParseError

func NewParseError(node Node, fmtString string, args ...interface{}) *ParseError

func (*ParseError) Error

func (p *ParseError) Error() string

func (*ParseError) Terminal

func (p *ParseError) Terminal() *ParseError

type RangeNode

type RangeNode struct {
	Lower, Upper Node
	Inclusive    bool
	// contains filtered or unexported fields
}

func (*RangeNode) Copy

func (n *RangeNode) Copy() Node

func (*RangeNode) LineNo

func (n *RangeNode) LineNo() int

func (*RangeNode) SetType

func (n *RangeNode) SetType(t types.Type)

func (*RangeNode) String

func (n *RangeNode) String() string

func (*RangeNode) TargetType

func (n *RangeNode) TargetType(locals ScopeChain, class *Class) (types.Type, error)

func (*RangeNode) Type

func (n *RangeNode) Type() types.Type

type ReturnNode

type ReturnNode struct {
	Val ArgsNode
	// contains filtered or unexported fields
}

func (*ReturnNode) Copy

func (n *ReturnNode) Copy() Node

func (*ReturnNode) LineNo

func (n *ReturnNode) LineNo() int

func (*ReturnNode) SetType

func (n *ReturnNode) SetType(t types.Type)

func (*ReturnNode) String

func (n *ReturnNode) String() string

func (*ReturnNode) TargetType

func (n *ReturnNode) TargetType(locals ScopeChain, class *Class) (types.Type, error)

func (*ReturnNode) Type

func (n *ReturnNode) Type() types.Type

type Root

type Root struct {
	State           *Stack[State]
	ScopeChain      ScopeChain
	Objects         []Node
	Statements      []Node
	Classes         []*Class
	MethodSetStack  *Stack[*MethodSet]
	Errors          []error
	ExplicitReturns []*ReturnNode
	StringStack     *Stack[*StringNode]
	Comments        map[int]Comment

	TopLevelModules []*Module
	// contains filtered or unexported fields
}

func NewRoot

func NewRoot() *Root

func ParseBytes

func ParseBytes(b []byte) (*Root, error)

func ParseFile

func ParseFile(filename string) (*Root, error)

func ParseString

func ParseString(s string) (*Root, error)

func (*Root) AddCall

func (r *Root) AddCall(c *MethodCall)

func (*Root) AddComment

func (r *Root) AddComment(c Comment)

func (*Root) AddError

func (r *Root) AddError(err error)

func (*Root) AddMethod

func (r *Root) AddMethod(m *Method)

func (*Root) AddReturn

func (r *Root) AddReturn(n *ReturnNode)

func (*Root) AddStatement

func (r *Root) AddStatement(n Node)

func (*Root) Analyze

func (r *Root) Analyze() error

func (*Root) AnalyzeMethodSet

func (r *Root) AnalyzeMethodSet(ms *MethodSet, rcvr types.Type) error

func (*Root) GetMethod

func (r *Root) GetMethod(name string) (*Method, bool)

func (*Root) ParseError

func (r *Root) ParseError() error

func (*Root) PopClass

func (r *Root) PopClass() *Class

func (*Root) PopModule

func (r *Root) PopModule() *Module

func (*Root) PushClass

func (r *Root) PushClass(name string, lineNo int)

func (*Root) PushModule

func (r *Root) PushModule(name string, lineNo int)

func (*Root) String

func (n *Root) String() string

type RubyLocal

type RubyLocal struct {
	Calls []*MethodCall
	// contains filtered or unexported fields
}

func (*RubyLocal) AddCall

func (rl *RubyLocal) AddCall(c *MethodCall)

func (*RubyLocal) SetType

func (rl *RubyLocal) SetType(t types.Type)

func (*RubyLocal) String

func (rl *RubyLocal) String() string

func (*RubyLocal) Type

func (rl *RubyLocal) Type() types.Type

type Scope

type Scope interface {
	Get(string) (Local, bool)
	Set(string, Local)
	Name() string
	TakesConstants() bool
}

type ScopeAccessNode

type ScopeAccessNode struct {
	Receiver Node
	Constant string
	// contains filtered or unexported fields
}

func (*ScopeAccessNode) Copy

func (n *ScopeAccessNode) Copy() Node

func (*ScopeAccessNode) LineNo

func (n *ScopeAccessNode) LineNo() int

func (*ScopeAccessNode) Lookup

func (n *ScopeAccessNode) Lookup(scope ScopeChain, outer, inner string) (Const, error)

func (*ScopeAccessNode) ReceiverName

func (n *ScopeAccessNode) ReceiverName() string

func (*ScopeAccessNode) SetType

func (n *ScopeAccessNode) SetType(t types.Type)

func (*ScopeAccessNode) String

func (n *ScopeAccessNode) String() string

func (*ScopeAccessNode) TargetType

func (n *ScopeAccessNode) TargetType(locals ScopeChain, class *Class) (types.Type, error)

func (*ScopeAccessNode) Type

func (n *ScopeAccessNode) Type() types.Type

func (*ScopeAccessNode) Walk

func (n *ScopeAccessNode) Walk(scope ScopeChain) (Const, error)

type ScopeChain

type ScopeChain []Scope

func NewScopeChain

func NewScopeChain() ScopeChain

func (ScopeChain) Current

func (chain ScopeChain) Current() Scope

func (ScopeChain) Extend

func (chain ScopeChain) Extend(scope Scope) ScopeChain

func (ScopeChain) Get

func (chain ScopeChain) Get(name string) (Local, bool)

func (ScopeChain) MustGet

func (chain ScopeChain) MustGet(name string) Local

func (ScopeChain) Name

func (chain ScopeChain) Name() string

func (ScopeChain) Prefix

func (chain ScopeChain) Prefix() string

func (ScopeChain) ResolveVar

func (chain ScopeChain) ResolveVar(s string) Local

func (ScopeChain) Set

func (chain ScopeChain) Set(name string, local Local)

type SelfNode

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

func (*SelfNode) Copy

func (n *SelfNode) Copy() Node

func (*SelfNode) LineNo

func (n *SelfNode) LineNo() int

func (*SelfNode) SetType

func (n *SelfNode) SetType(t types.Type)

func (*SelfNode) String

func (n *SelfNode) String() string

func (*SelfNode) TargetType

func (n *SelfNode) TargetType(locals ScopeChain, class *Class) (types.Type, error)

func (*SelfNode) Type

func (n *SelfNode) Type() types.Type

type SimpleScope

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

func NewScope

func NewScope(name string) *SimpleScope

func (*SimpleScope) Get

func (scope *SimpleScope) Get(name string) (Local, bool)

func (*SimpleScope) Name

func (scope *SimpleScope) Name() string

func (*SimpleScope) Set

func (scope *SimpleScope) Set(name string, local Local)

func (*SimpleScope) TakesConstants

func (scope *SimpleScope) TakesConstants() bool

type Stack

type Stack[T any] struct {
	// contains filtered or unexported fields
}

func (*Stack[T]) Peek

func (s *Stack[T]) Peek() T

func (*Stack[T]) Pop

func (s *Stack[T]) Pop() T

func (*Stack[T]) Push

func (s *Stack[T]) Push(t T)

func (*Stack[T]) Size

func (s *Stack[T]) Size() int

type StackState

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

func NewStackState

func NewStackState(name string) *StackState

func (*StackState) Clear

func (s *StackState) Clear() int

func (*StackState) IsActive

func (s *StackState) IsActive() bool

func (*StackState) IsEmpty

func (s *StackState) IsEmpty() bool

func (*StackState) Lexpop

func (s *StackState) Lexpop() bool

func (*StackState) Pop

func (s *StackState) Pop() bool

func (*StackState) Push

func (s *StackState) Push(bit bool) bool

type State

type State string
const (
	TopLevelStatement  State = "TopLevelStatement"
	InClassBody        State = "InClassBody"
	InModuleBody       State = "InModuleBody"
	InMethodDefinition State = "InMethodDefinition"
	InString           State = "InString"
)

type Statements

type Statements []Node

func (Statements) Copy

func (stmts Statements) Copy() Node

func (Statements) LineNo

func (stmts Statements) LineNo() int

func (Statements) SetType

func (stmts Statements) SetType(t types.Type)

func (Statements) String

func (stmts Statements) String() string

func (Statements) TargetType

func (stmts Statements) TargetType(scope ScopeChain, class *Class) (types.Type, error)

func (Statements) Type

func (stmts Statements) Type() types.Type

type StringKind

type StringKind int
const (
	DoubleQuote StringKind = iota
	SingleQuote
	Regexp
	Words
	RawWords
	Exec
	RawExec
)

type StringNode

type StringNode struct {
	BodySegments []string
	Interps      map[int][]Node

	Kind StringKind
	// contains filtered or unexported fields
}

func (*StringNode) Copy

func (n *StringNode) Copy() Node

func (*StringNode) FmtString

func (n *StringNode) FmtString(delim string) string

func (*StringNode) GoString

func (n *StringNode) GoString() string

func (*StringNode) LineNo

func (n *StringNode) LineNo() int

func (*StringNode) OrderedInterps

func (n *StringNode) OrderedInterps() []Node

func (*StringNode) SetType

func (n *StringNode) SetType(t types.Type)

func (*StringNode) String

func (n *StringNode) String() string

func (*StringNode) TargetType

func (n *StringNode) TargetType(scope ScopeChain, class *Class) (types.Type, error)

func (*StringNode) TranslateEscapes

func (n *StringNode) TranslateEscapes(segment string) (string, error)

func (*StringNode) Type

func (n *StringNode) Type() types.Type

type SuperNode

type SuperNode struct {
	Args   ArgsNode
	Method *Method
	Class  *Class
	// contains filtered or unexported fields
}

func (*SuperNode) Copy

func (n *SuperNode) Copy() Node

func (*SuperNode) Inline

func (n *SuperNode) Inline() Statements

func (*SuperNode) LineNo

func (n *SuperNode) LineNo() int

func (*SuperNode) SetType

func (n *SuperNode) SetType(t types.Type)

func (*SuperNode) String

func (n *SuperNode) String() string

func (*SuperNode) TargetType

func (n *SuperNode) TargetType(locals ScopeChain, class *Class) (types.Type, error)

func (*SuperNode) Type

func (n *SuperNode) Type() types.Type

type SymbolNode

type SymbolNode struct {
	Val string
	// contains filtered or unexported fields
}

func (*SymbolNode) Copy

func (n *SymbolNode) Copy() Node

func (*SymbolNode) LineNo

func (n *SymbolNode) LineNo() int

func (*SymbolNode) SetType

func (n *SymbolNode) SetType(t types.Type)

func (*SymbolNode) String

func (n *SymbolNode) String() string

func (*SymbolNode) TargetType

func (n *SymbolNode) TargetType(locals ScopeChain, class *Class) (types.Type, error)

func (*SymbolNode) Type

func (n *SymbolNode) Type() types.Type

type Token

type Token struct {
	Type     int
	Literal  string
	LineNo   int
	RawBlock string
}

func (Token) String

func (t Token) String() string

type WhenNode

type WhenNode struct {
	Conditions ArgsNode
	Statements Statements
	// contains filtered or unexported fields
}

func (*WhenNode) Copy

func (n *WhenNode) Copy() Node

func (*WhenNode) LineNo

func (n *WhenNode) LineNo() int

func (*WhenNode) SetType

func (n *WhenNode) SetType(t types.Type)

func (*WhenNode) String

func (n *WhenNode) String() string

func (*WhenNode) TargetType

func (n *WhenNode) TargetType(locals ScopeChain, class *Class) (types.Type, error)

func (*WhenNode) Type

func (n *WhenNode) Type() types.Type

type WhileNode

type WhileNode struct {
	Condition Node
	Body      Statements
	// contains filtered or unexported fields
}

func (*WhileNode) Copy

func (n *WhileNode) Copy() Node

func (*WhileNode) LineNo

func (n *WhileNode) LineNo() int

func (*WhileNode) SetType

func (n *WhileNode) SetType(t types.Type)

func (*WhileNode) String

func (n *WhileNode) String() string

func (*WhileNode) TargetType

func (n *WhileNode) TargetType(locals ScopeChain, class *Class) (types.Type, error)

func (*WhileNode) Type

func (n *WhileNode) Type() types.Type

Jump to

Keyboard shortcuts

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