Documentation ¶
Index ¶
- Constants
- type AnalysisReport
- type Converter
- func (c *Converter) Convert() (*ast.Program, error)
- func (c *Converter) Error() error
- func (c *Converter) Get() (*ast.Program, error)
- func (c *Converter) GetIntermediateProgram() *nast.Program
- func (c *Converter) GetVariableTranslations() map[string]string
- func (c *Converter) Load(prog *nast.Program, files FileSystem) ConverterIncludes
- func (c *Converter) LoadFile(mainfile string) ConverterIncludes
- func (c *Converter) LoadFileEx(mainfile string, files FileSystem) ConverterIncludes
- func (c *Converter) ProcessCodeExpansion() ConverterNodes
- func (c *Converter) ProcessFinalize() ConverterDone
- func (c *Converter) ProcessIncludes() ConverterExpansions
- func (c *Converter) ProcessLineNumbers() ConverterFinal
- func (c *Converter) ProcessNodes() ConverterLines
- func (c *Converter) RunConversion() ConverterDone
- func (c *Converter) SetChipType(chip string) ConverterEmpty
- func (c *Converter) SetDebug(b bool) ConverterEmpty
- type ConverterDone
- type ConverterEmpty
- type ConverterExpansions
- type ConverterFinal
- type ConverterIncludes
- type ConverterLines
- type ConverterNodes
- type DiskFileSystem
- type FileSystem
- type InsertedMacro
- type MemoryFileSystem
- type Parser
- func (p *Parser) Debug(b bool)
- func (p *Parser) Parse(prog string) (*nast.Program, error)
- func (p *Parser) ParseBlock(stop func() bool) *nast.Block
- func (p *Parser) ParseBreak() ast.Statement
- func (p *Parser) ParseContinue() ast.Statement
- func (p *Parser) ParseDefinition() *nast.Definition
- func (p *Parser) ParseElement() nast.Element
- func (p *Parser) ParseFuncCall() *nast.FuncCall
- func (p *Parser) ParseIf() ast.Statement
- func (p *Parser) ParseInclude() *nast.IncludeDirective
- func (p *Parser) ParseMacroDefinition() *nast.MacroDefinition
- func (p *Parser) ParseMultilineIf() nast.NestableElement
- func (p *Parser) ParseNestableElement() nast.NestableElement
- func (p *Parser) ParseNestableElementFuncCall() *nast.FuncCall
- func (p *Parser) ParseProgram() *nast.Program
- func (p *Parser) ParseSingleExpression() ast.Expression
- func (p *Parser) ParseStatement() ast.Statement
- func (p *Parser) ParseStatementLine() *nast.StatementLine
- func (p *Parser) ParseWhile() nast.NestableElement
- func (p *Parser) SetFilename(name string)
- type Printer
- type PublicParser
Constants ¶
const ( ErrExpectedStringConstant = "ErrExpectedStringConstant" ErrExpectedIdentifier = "ErrExpectedIdentifier" ErrExpectedExistingMacro = "ErrExpectedExistingMacro" ErrExpectedJumplabel = "ErrExpectedJumplabel" ErrExpectedMacroType = "ErrExpectedMacroType" )
Constant definitions for parser.Error.Code
const MaxExpandedMacros = 100
MaxExpandedMacros is the maximum number of macros to expand, before aborting due to a loop
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AnalysisReport ¶ added in v0.0.28
type AnalysisReport struct { FileDocstring string Definitions map[string]*nast.Definition Macros map[string]*nast.MacroDefinition Variables []string Labels []string Docstrings map[string]string }
AnalysisReport contains collected information about a nolol-programm
func Analyse ¶ added in v0.0.28
func Analyse(prog *nast.Program) (*AnalysisReport, error)
Analyse returns an AnalysisReport for the given program All includes in the input-program must have been already resolved (use the converter for this) The input-programm is mutated. Do NOT use it after analysis
func (AnalysisReport) GetMacroLocalVars ¶ added in v0.0.28
func (a AnalysisReport) GetMacroLocalVars(mac *nast.MacroDefinition) []string
GetMacroLocalVars returns the local variables for the given macro
func (AnalysisReport) GetVarsAtLine ¶ added in v0.0.28
func (a AnalysisReport) GetVarsAtLine(line int) []string
GetVarsAtLine returns all variables that are in scope at the given line
type Converter ¶
type Converter struct {
// contains filtered or unexported fields
}
Converter can convert a nolol-ast to a yolol-ast
func (*Converter) Convert ¶
Convert converts the nolol-program to a yolol-program This is a shortcut to calling the ProcessXY-Methods in order
func (*Converter) GetIntermediateProgram ¶ added in v0.0.32
GetIntermediateProgram returns the current intermediate nolol-ast. The state of it depends on what steps of the conversion have already been performed
func (*Converter) GetVariableTranslations ¶ added in v0.0.13
GetVariableTranslations returns a table that can be used to find the original names of the variables whos names where shortened during conversion
func (*Converter) Load ¶ added in v0.0.32
func (c *Converter) Load(prog *nast.Program, files FileSystem) ConverterIncludes
Load loades a nolol-ast to convert. Included files are retrieved using the given filesystem
func (*Converter) LoadFile ¶ added in v0.0.32
func (c *Converter) LoadFile(mainfile string) ConverterIncludes
LoadFile is a shortcut that loads a file to convert from the file-system mainfile is the path to the file on the disk. All included files are loaded relative to the mainfile.
func (*Converter) LoadFileEx ¶ added in v0.0.32
func (c *Converter) LoadFileEx(mainfile string, files FileSystem) ConverterIncludes
LoadFileEx acts like LoadFile, but allows the passing of a custom filesystem from which the source files are retrieved. This way, files that are not stored on disk can be converted
func (*Converter) ProcessCodeExpansion ¶ added in v0.0.32
func (c *Converter) ProcessCodeExpansion() ConverterNodes
ProcessCodeExpansion resolves all macro-definitions, macro-insertions and defines
func (*Converter) ProcessFinalize ¶ added in v0.0.32
func (c *Converter) ProcessFinalize() ConverterDone
ProcessFinalize takes the final steps in converting the program
func (*Converter) ProcessIncludes ¶ added in v0.0.32
func (c *Converter) ProcessIncludes() ConverterExpansions
ProcessIncludes resolves all Include-Directives in the given nolol-code
func (*Converter) ProcessLineNumbers ¶ added in v0.0.32
func (c *Converter) ProcessLineNumbers() ConverterFinal
ProcessLineNumbers handles gotos and line-labels
func (*Converter) ProcessNodes ¶ added in v0.0.32
func (c *Converter) ProcessNodes() ConverterLines
ProcessNodes converts most nolol ast-nodes to yolol ast.nodes
func (*Converter) RunConversion ¶ added in v0.0.32
func (c *Converter) RunConversion() ConverterDone
RunConversion jumps to the final phase of conversion
func (*Converter) SetChipType ¶ added in v0.1.5
func (c *Converter) SetChipType(chip string) ConverterEmpty
SetChipType sets the yolol chip-type for that the nolol-script should be compiled
func (*Converter) SetDebug ¶ added in v0.0.32
func (c *Converter) SetDebug(b bool) ConverterEmpty
SetDebug enables/disables debug logging
type ConverterDone ¶ added in v0.0.32
type ConverterDone interface { Get() (*ast.Program, error) GetVariableTranslations() map[string]string Error() error GetIntermediateProgram() *nast.Program }
ConverterDone is part of the Sequenced-Builder-Pattern of the Converter
type ConverterEmpty ¶ added in v0.0.32
type ConverterEmpty interface { Load(prog *nast.Program, files FileSystem) ConverterIncludes LoadFile(mainfile string) ConverterIncludes LoadFileEx(mainfile string, files FileSystem) ConverterIncludes SetDebug(b bool) ConverterEmpty SetChipType(chip string) ConverterEmpty }
ConverterEmpty is part of the Sequenced-Builder-Pattern of the Converter
type ConverterExpansions ¶ added in v0.0.32
type ConverterExpansions interface { ProcessCodeExpansion() ConverterNodes Error() error GetIntermediateProgram() *nast.Program }
ConverterExpansions is part of the Sequenced-Builder-Pattern of the Converter
type ConverterFinal ¶ added in v0.0.32
type ConverterFinal interface { ProcessFinalize() ConverterDone Error() error GetIntermediateProgram() *nast.Program }
ConverterFinal is part of the Sequenced-Builder-Pattern of the Converter
type ConverterIncludes ¶ added in v0.0.32
type ConverterIncludes interface { ProcessIncludes() ConverterExpansions Convert() (*ast.Program, error) RunConversion() ConverterDone Error() error GetIntermediateProgram() *nast.Program }
ConverterIncludes is part of the Sequenced-Builder-Pattern of the Converter
type ConverterLines ¶ added in v0.0.32
type ConverterLines interface { ProcessLineNumbers() ConverterFinal Error() error GetIntermediateProgram() *nast.Program }
ConverterLines is part of the Sequenced-Builder-Pattern of the Converter
type ConverterNodes ¶ added in v0.0.32
type ConverterNodes interface { ProcessNodes() ConverterLines Error() error GetIntermediateProgram() *nast.Program }
ConverterNodes is part of the Sequenced-Builder-Pattern of the Converter
type DiskFileSystem ¶ added in v0.0.10
type DiskFileSystem struct {
Dir string
}
DiskFileSystem retrieves files from a directory on the disk
type FileSystem ¶ added in v0.0.10
FileSystem defines an interface to get the content of files by name used so the converter can query for the content of files mentioned in include-directives
type InsertedMacro ¶ added in v0.0.32
type InsertedMacro struct { // Code to be inserted Code ast.Node // Type of the original macro MacroType string // The inseriton of the macro FuncCall *nast.FuncCall // The StatementLine the macro is inserted into (if any) ParentStatementLine *nast.StatementLine // Position inside ParentStatementLine ParentStatementLineIndex int }
InsertedMacro is a pseudo-ast node that is used during the insertion of a macro IT bundles information about an (already expanded) macro and it's insetion
func (*InsertedMacro) Accept ¶ added in v0.0.32
func (e *InsertedMacro) Accept(v ast.Visitor) error
Accept is used to implement Acceptor
func (*InsertedMacro) El ¶ added in v0.0.32
func (e *InsertedMacro) El()
El implements the type-marker method
func (*InsertedMacro) End ¶ added in v0.0.32
func (e *InsertedMacro) End() ast.Position
End is needed to implement ast.Node
func (*InsertedMacro) Expr ¶ added in v0.0.32
func (e *InsertedMacro) Expr()
Expr implements the type-marker method
func (*InsertedMacro) NestEl ¶ added in v0.0.32
func (e *InsertedMacro) NestEl()
NestEl implements the type-marker method
func (*InsertedMacro) Start ¶ added in v0.0.32
func (e *InsertedMacro) Start() ast.Position
Start is needed to implement ast.Node
func (*InsertedMacro) Stmt ¶ added in v0.0.32
func (e *InsertedMacro) Stmt()
Stmt implements the type-marker method
type MemoryFileSystem ¶ added in v0.0.10
MemoryFileSystem serves files from Memory
type Parser ¶
Parser parses a nolol-program
func (*Parser) ParseBlock ¶ added in v0.0.9
ParseBlock parse lines until stop() returns true
func (*Parser) ParseBreak ¶ added in v0.0.14
ParseBreak parses the break keyword
func (*Parser) ParseContinue ¶ added in v0.0.14
ParseContinue parses the continue keyword
func (*Parser) ParseDefinition ¶ added in v0.0.12
func (p *Parser) ParseDefinition() *nast.Definition
ParseDefinition parses a constant declaration
func (*Parser) ParseElement ¶ added in v0.0.10
ParseElement parses an element
func (*Parser) ParseFuncCall ¶ added in v0.0.6
ParseFuncCall parse a function call
func (*Parser) ParseIf ¶
ParseIf parses an if-node. Copied nearly 1to1 from yolol-parser, but requires ; instead of " " between statements
func (*Parser) ParseInclude ¶ added in v0.0.10
func (p *Parser) ParseInclude() *nast.IncludeDirective
ParseInclude parses an include directive
func (*Parser) ParseMacroDefinition ¶ added in v0.0.11
func (p *Parser) ParseMacroDefinition() *nast.MacroDefinition
ParseMacroDefinition parses the definition of a macro
func (*Parser) ParseMultilineIf ¶
func (p *Parser) ParseMultilineIf() nast.NestableElement
ParseMultilineIf parses a nolol-style multiline if
func (*Parser) ParseNestableElement ¶ added in v0.0.11
func (p *Parser) ParseNestableElement() nast.NestableElement
ParseNestableElement parses a NOLOL-Element which can appear inside a blocl
func (*Parser) ParseNestableElementFuncCall ¶ added in v0.0.32
ParseNestableElementFuncCall parses a funccall that is the only element on the line
func (*Parser) ParseProgram ¶
ParseProgram parses the program
func (*Parser) ParseSingleExpression ¶ added in v0.0.14
func (p *Parser) ParseSingleExpression() ast.Expression
ParseSingleExpression wraps the method of the yolol-parser and adds parsing of func-calls
func (*Parser) ParseStatement ¶ added in v0.0.14
ParseStatement wraps the method of the yolol-parser to add new statement-types
func (*Parser) ParseStatementLine ¶
func (p *Parser) ParseStatementLine() *nast.StatementLine
ParseStatementLine parses a statement line
func (*Parser) ParseWhile ¶
func (p *Parser) ParseWhile() nast.NestableElement
ParseWhile pasres a nolol while
func (*Parser) SetFilename ¶ added in v0.0.10
SetFilename sets the filename that is included in the position of every returned ast.node Necessary when parsing an included file to differenciate between positions in different files
type Printer ¶
type Printer struct { Indentation string // contains filtered or unexported fields }
Printer can generate the nolol-code corresponding to a nolol ast
type PublicParser ¶ added in v0.0.32
PublicParser is an interface that hides all overridable-methods from normal users