nolol

package
v0.0.21 Latest Latest
Warning

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

Go to latest
Published: Sep 15, 2020 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Converter

type Converter struct {

	// UseSpaces disables the default spaceless-mode
	UseSpaces bool
	// contains filtered or unexported fields
}

Converter can convert a nolol-ast to a yolol-ast

func NewConverter

func NewConverter() *Converter

NewConverter creates a new converter

func (*Converter) Convert

func (c *Converter) Convert(prog *nast.Program, files FileSystem) (*ast.Program, error)

Convert converts a nolol-program to a yolol-program files is an object to access files that are referenced in prog's include directives

func (*Converter) ConvertFile added in v0.0.10

func (c *Converter) ConvertFile(mainfile string) (*ast.Program, error)

ConvertFile is a shortcut that loads a file from the file-system, parses it and directly convertes it. mainfile is the path to the file on the disk. All included are loaded relative to the mainfile.

func (*Converter) ConvertFileEx added in v0.0.10

func (c *Converter) ConvertFileEx(mainfile string, files FileSystem) (*ast.Program, error)

ConvertFileEx acts like ConvertFile, 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) Debug added in v0.0.7

func (c *Converter) Debug(b bool)

Debug enables/disables debug logging

func (*Converter) GetVariableTranslations added in v0.0.13

func (c *Converter) GetVariableTranslations() map[string]string

GetVariableTranslations returns a table that can be used to find the original names of the variables whos names where shortened during conversion

type DiskFileSystem added in v0.0.10

type DiskFileSystem struct {
	Dir string
}

DiskFileSystem retrieves files from a directory on the disk

func (DiskFileSystem) Get added in v0.0.10

func (f DiskFileSystem) Get(name string) (string, error)

Get implements FileSystem

type FileSystem added in v0.0.10

type FileSystem interface {
	Get(name string) (string, error)
}

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 MemoryFileSystem added in v0.0.10

type MemoryFileSystem map[string]string

MemoryFileSystem serves files from Memory

func (MemoryFileSystem) Get added in v0.0.10

func (f MemoryFileSystem) Get(name string) (string, error)

Get implements FileSystem

type Parser

type Parser struct {
	*parser.Parser
}

Parser parses a nolol-program

func NewParser

func NewParser() *Parser

NewParser creates and returns a nolol parser

func (*Parser) Debug added in v0.0.7

func (p *Parser) Debug(b bool)

Debug enables/disables debug logging

func (*Parser) Parse

func (p *Parser) Parse(prog string) (*nast.Program, error)

Parse is the entry point for parsing

func (*Parser) ParseBlock added in v0.0.9

func (p *Parser) ParseBlock(stop func() bool) *nast.Block

ParseBlock parse lines until stop() returns true

func (*Parser) ParseBreak added in v0.0.14

func (p *Parser) ParseBreak() ast.Statement

ParseBreak parses the break keyword

func (*Parser) ParseContinue added in v0.0.14

func (p *Parser) ParseContinue() ast.Statement

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

func (p *Parser) ParseElement() nast.Element

ParseElement parses an element

func (*Parser) ParseFuncCall added in v0.0.6

func (p *Parser) ParseFuncCall() *nast.FuncCall

ParseFuncCall parse a function call

func (*Parser) ParseGoto

func (p *Parser) ParseGoto() ast.Statement

ParseGoto allows labeled-gotos and forbids line-based gotos

func (*Parser) ParseIf

func (p *Parser) ParseIf() ast.Statement

ParseIf overrides and disables the old yolol-style inline ifs

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) ParseMacroInsertion added in v0.0.11

func (p *Parser) ParseMacroInsertion() *nast.MacroInsetion

ParseMacroInsertion parses a macro insertion

func (*Parser) ParseMultilineIf

func (p *Parser) ParseMultilineIf() nast.Element

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

func (p *Parser) ParseProgram() *nast.Program

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

func (p *Parser) ParseStatement() ast.Statement

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) ParseWaitDirective added in v0.0.13

func (p *Parser) ParseWaitDirective() *nast.WaitDirective

ParseWaitDirective parses a NOLOL wait-statement

func (*Parser) ParseWhile

func (p *Parser) ParseWhile() nast.Element

ParseWhile pasres a nolol while

func (*Parser) SetFilename added in v0.0.10

func (p *Parser) SetFilename(name string)

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

func NewPrinter

func NewPrinter() *Printer

NewPrinter creates a new Printer

func (*Printer) Print

func (np *Printer) Print(prog ast.Node) (string, error)

Print returns the nolol-code for the given ast

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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