Documentation ¶
Overview ¶
Package compile compiles Suneido source code to byte code to be interpreted by the runtime package.
It uses a recursive descent parser that produces an AST that is then converted to byte code by codegen
Compiling constants (other than functions) produces values directly without going through an AST.
Expression parsing is shared with database queries.
Index ¶
- func Checked(th *Thread, src string) (Value, []string)
- func Constant(src string) Value
- func EvalString(th *Thread, s string) Value
- func NamedConstant(lib, name, src string, prevDef Value) Value
- func SetPos(result iSetPos, org, end int32)
- type Aspects
- type Expr
- type Labels
- type Parser
- type ParserBase
- func (p *ParserBase) Error(args ...any) string
- func (p *ParserBase) ErrorAt(pos int32, args ...any) string
- func (p *ParserBase) Match(token tok.Token)
- func (p *ParserBase) MatchIdent() string
- func (p *ParserBase) MatchIf(token tok.Token) bool
- func (p *ParserBase) MustMatch(token tok.Token)
- func (p *ParserBase) Next()
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EvalString ¶
func EvalString(th *Thread, s string) Value
EvalString executes string containing Suneido code i.e. string.Eval()
func NamedConstant ¶
func NamedConstant(lib, name, src string, prevDef Value) Value
NamedConstant compiles a Suneido constant with a name e.g. a library record
Types ¶
type Aspects ¶
Aspects allows tailoring the parser for different purposes. e.g. codegen, ast generation, queries, go gen
type Parser ¶
type Parser struct { ParserBase // contains filtered or unexported fields }
func QueryParser ¶
func (*Parser) Expression ¶
Expression parses a Suneido expression and builds an AST
func (*Parser) InitFuncInfo ¶
func (p *Parser) InitFuncInfo()
type ParserBase ¶
type ParserBase struct { Aspects Lxr *Lexer // Item is the current lexical token etc. Item // EndPos is the end of the previous token EndPos int32 // EqToIs treats Eq as Is for queries EqToIs bool // contains filtered or unexported fields }
func (*ParserBase) Error ¶
func (p *ParserBase) Error(args ...any) string
Error panics with "syntax Error at " + position It claims to return string so it can be called inside panic (so compiler knows we don't return)
func (*ParserBase) Match ¶
func (p *ParserBase) Match(token tok.Token)
func (*ParserBase) MatchIdent ¶
func (p *ParserBase) MatchIdent() string
func (*ParserBase) MustMatch ¶
func (p *ParserBase) MustMatch(token tok.Token)
func (*ParserBase) Next ¶
func (p *ParserBase) Next()
Next skips whitespace and comments to advance to the next token. It sets p.Item (Text, Pos, Token), p.EndPos, and p.newline.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package ast defines the node types used by the compiler to build syntax trees
|
Package ast defines the node types used by the compiler to build syntax trees |
Package check processes an ast.Function and finds used but (possibly) not initialized, and initialized but (possibly) not used.
|
Package check processes an ast.Function and finds used but (possibly) not initialized, and initialized but (possibly) not used. |
Package lexer implements the lexical scanner for the Suneido language
|
Package lexer implements the lexical scanner for the Suneido language |
Package tokens defines the lexical tokens
|
Package tokens defines the lexical tokens |