Documentation ¶
Index ¶
- Constants
- func CompileTypeSpec(source string) (*data.Type, error)
- func Run(name string, s *symbols.SymbolTable, t *tokenizer.Tokenizer) error
- func RunString(name string, s *symbols.SymbolTable, programText string) error
- func TestAssert(s *symbols.SymbolTable, args []interface{}) (interface{}, error)
- func TestEqual(s *symbols.SymbolTable, args []interface{}) (interface{}, error)
- func TestFail(s *symbols.SymbolTable, args []interface{}) (interface{}, error)
- func TestFalse(s *symbols.SymbolTable, args []interface{}) (interface{}, error)
- func TestIsType(s *symbols.SymbolTable, args []interface{}) (interface{}, error)
- func TestNil(s *symbols.SymbolTable, args []interface{}) (interface{}, error)
- func TestNotEqual(s *symbols.SymbolTable, args []interface{}) (interface{}, error)
- func TestNotNil(s *symbols.SymbolTable, args []interface{}) (interface{}, error)
- func TestTrue(s *symbols.SymbolTable, args []interface{}) (interface{}, error)
- type Compiler
- func (c *Compiler) AddBuiltins(pkgname string) bool
- func (c *Compiler) AddPackageToSymbols(s *symbols.SymbolTable) *Compiler
- func (c *Compiler) AddStandard(s *symbols.SymbolTable) bool
- func (c *Compiler) Assert() error
- func (c *Compiler) AutoImport(all bool, s *symbols.SymbolTable) error
- func (c *Compiler) Clone(withLock bool) *Compiler
- func (c *Compiler) Compile(name string, t *tokenizer.Tokenizer) (*bytecode.ByteCode, error)
- func (c *Compiler) CompileString(name string, source string) (*bytecode.ByteCode, error)
- func (c *Compiler) ExitEnabled(b bool) *Compiler
- func (c *Compiler) Expression() (*bytecode.ByteCode, error)
- func (c *Compiler) ExtensionsEnabled(b bool) *Compiler
- func (c *Compiler) Fail() error
- func (c *Compiler) File() error
- func (c *Compiler) Get(name string) (interface{}, bool)
- func (c *Compiler) GetPackageType(packageName, typeName string) (*data.Type, bool)
- func (c *Compiler) MainSeen() bool
- func (c *Compiler) NormalizedIdentifiers() bool
- func (c *Compiler) ParseFunctionDeclaration() (*data.FunctionDeclaration, error)
- func (c *Compiler) SetInteractive(b bool) *Compiler
- func (c *Compiler) SetNormalizedIdentifiers(flag bool) *Compiler
- func (c *Compiler) SetRoot(s *symbols.SymbolTable) *Compiler
- func (c *Compiler) SetTestMode(b bool) *Compiler
- func (c *Compiler) Symbols() *symbols.SymbolTable
- func (c *Compiler) TestMode() bool
- func (c *Compiler) TestPass() error
- func (c *Compiler) WithNormalization(f bool) *Compiler
- func (c *Compiler) WithSymbols(s *symbols.SymbolTable) *Compiler
- func (c *Compiler) WithTokens(t *tokenizer.Tokenizer) *Compiler
Constants ¶
const ( AssertDirective = "assert" AuthentiatedDirective = "authenticated" DebugDirective = "debug" EntryPointDirective = "entrypoint" ErrorDirective = "error" FileDirective = "file" FailDirective = "fail" GlobalDirective = "global" HandlerDirective = "handler" JSONDirective = "json" LineDirective = "line" LocalizationDirective = "localization" LogDirective = "log" PassDirective = "pass" ResponseDirective = "response" StatusDirective = "status" TemplateDirective = "template" TestDirective = "test" TextDirective = "text" TypeDirective = "type" URLDirective = "url" WaitDirective = "wait" )
Variables ¶
This section is empty.
Functions ¶
func CompileTypeSpec ¶
Given a string expression of a type specification, compile it asn return the type it represents, and an optional error if it was incorrectly formed. This cannot reference user types as they are not visible to this function.
If the string starts with the keyword `type` followed by a type name, then the resulting value is a type definition of the given name.
func Run ¶
Given a token stream, compile and execute it immediately. Note that language extensions are always enabled for this kind of execution mode.
func RunString ¶
func RunString(name string, s *symbols.SymbolTable, programText string) error
Given a string, compile and execute it immediately.
func TestAssert ¶
func TestAssert(s *symbols.SymbolTable, args []interface{}) (interface{}, error)
TestAssert implements the T.assert() function.
func TestEqual ¶
func TestEqual(s *symbols.SymbolTable, args []interface{}) (interface{}, error)
TestEqual implements the T.Equal() function.
func TestFail ¶
func TestFail(s *symbols.SymbolTable, args []interface{}) (interface{}, error)
TestFail implements the T.fail() function which generates a fatal error.
func TestFalse ¶
func TestFalse(s *symbols.SymbolTable, args []interface{}) (interface{}, error)
TestFalse implements the T.False() function.
func TestIsType ¶
func TestIsType(s *symbols.SymbolTable, args []interface{}) (interface{}, error)
TestIsType implements the T.type() function.
func TestNil ¶
func TestNil(s *symbols.SymbolTable, args []interface{}) (interface{}, error)
TestNil implements the T.Nil() function.
func TestNotEqual ¶
func TestNotEqual(s *symbols.SymbolTable, args []interface{}) (interface{}, error)
TestNotEqual implements the T.NotEqual() function.
func TestNotNil ¶
func TestNotNil(s *symbols.SymbolTable, args []interface{}) (interface{}, error)
TestNotNil implements the T.NotNil() function.
func TestTrue ¶
func TestTrue(s *symbols.SymbolTable, args []interface{}) (interface{}, error)
TestTrue implements the T.True() function.
Types ¶
type Compiler ¶
type Compiler struct {
// contains filtered or unexported fields
}
Compiler is a structure defining what we know about the compilation.
func (*Compiler) AddBuiltins ¶
AddBuiltins adds the builtins for the named package (or prebuilt builtins if the package name is empty).
func (*Compiler) AddPackageToSymbols ¶
func (c *Compiler) AddPackageToSymbols(s *symbols.SymbolTable) *Compiler
AddPackageToSymbols adds all the defined packages for this compilation to the given symbol table. This function supports attribute chaining for a compiler instance.
func (*Compiler) AddStandard ¶
func (c *Compiler) AddStandard(s *symbols.SymbolTable) bool
AddStandard adds the package-independent standard functions (like len() or make()) to the given symbol table.
func (*Compiler) AutoImport ¶
func (c *Compiler) AutoImport(all bool, s *symbols.SymbolTable) error
AutoImport arranges for the import of built-in packages. The parameter indicates if all available packages (including those found in the ego path) are imported, versus just essential packages like "util".
func (*Compiler) Clone ¶
Clone makes a new copy of the current compiler. The withLock flag indicates if the clone should respect symbol table locking. This function supports attribute chaining for a compiler instance.
func (*Compiler) Compile ¶
Compile starts a compilation unit, and returns a bytecode of the compiled material.
func (*Compiler) CompileString ¶
CompileString turns a string into a compilation unit. This is a helper function around the Compile() operation that removes the need for the caller to provide a tokenizer.
func (*Compiler) ExitEnabled ¶
If set to true, the compiler allows the "exit" statement. This function supports attribute chaining for a compiler instance.
func (*Compiler) Expression ¶
Expression is the public entrypoint to compile an expression which returns a bytecode segment as it's result. This lets code compile an expression, but save the generated code to emit later.
The function grammar considers a conditional to be the top of the parse tree, so we start evaluating there.
From the golang doc, operator precedence is:
Precedence Operator 5 * / % << >> & &^ 4 + - | ^ 3 == != < <= > >= 2 && 1 ||
func (*Compiler) ExtensionsEnabled ¶
If set to true, the compiler allows the PRINT, TRY/CATCH, etc. statements. This function supports attribute chaining for a compiler instance.
func (*Compiler) GetPackageType ¶
For a given package and type name, get the underlying type.
func (*Compiler) MainSeen ¶
MainSeen indicates if a "package main" has been seen in this compilation.
func (*Compiler) NormalizedIdentifiers ¶
NormalizedIdentifiers returns true if this instance of the compiler is folding all identifiers to a common (lower) case.
func (*Compiler) ParseFunctionDeclaration ¶
func (c *Compiler) ParseFunctionDeclaration() (*data.FunctionDeclaration, error)
ParseFunctionDeclaration compiles a function declaration, which specifies the parameter and return type of a function.
func (*Compiler) SetInteractive ¶
SetInteractive indicates if the compilation is happening in interactive (i.e. REPL) mode. This function supports attribute chaining for a compiler instance.
func (*Compiler) SetNormalizedIdentifiers ¶
SetNormalizedIdentifiers sets the flag indicating if this compiler instance is folding all identifiers to a common case. This function supports attribute chaining for a compiler instance.
func (*Compiler) SetRoot ¶
func (c *Compiler) SetRoot(s *symbols.SymbolTable) *Compiler
Override the default root symbol table for this compilation. This determines where package names are stored/found, for example. This is overridden by the web service handlers as they have per-call instances of root. This function supports attribute chaining for a compiler instance.
func (*Compiler) SetTestMode ¶
SetTestMode is used to set the test mode indicator for the compiler. This is set to true only when running in Ego "test" mode. This function supports attribute chaining for a compiler instance.
func (*Compiler) Symbols ¶
func (c *Compiler) Symbols() *symbols.SymbolTable
Symbols returns the symbol table map from compilation.
func (*Compiler) TestMode ¶
TesetMode returns whether the compiler is being used under control of the Ego "test" command, which has slightly different rules for block constructs.
func (*Compiler) WithNormalization ¶
WithNormalization sets the normalization flag. This function supports attribute chaining for a compiler instance.
func (*Compiler) WithSymbols ¶
func (c *Compiler) WithSymbols(s *symbols.SymbolTable) *Compiler
Set the given symbol table as the default symbol table for compilation. This mostly affects how builtins are processed. This function supports attribute chaining for a compiler instance.
Source Files ¶
- assignment.go
- block.go
- call.go
- compiler.go
- constant.go
- defer.go
- directives.go
- errors.go
- exit.go
- expr_atom.go
- expr_condiitional.go
- expr_function.go
- expr_operators.go
- expr_reference.go
- expr_unary.go
- expression.go
- for.go
- function.go
- go.go
- if.go
- initializer.go
- lvalue.go
- package.go
- panic.go
- print.go
- return.go
- run.go
- statement.go
- switch.go
- testing.go
- try.go
- type.go
- typeCompiler.go
- url.go
- var.go