compil

package
v1.0.8 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2023 License: GPL-3.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EOF1 rune = 0x0
	EOF2 rune = 0x1a // End of file = EOF1 or EOF2

	EOL1 rune = 0x0d
	EOL2 rune = 0x0a // End of line = EOL1, or EOL2, or EOL1 followed by EOL2
)
View Source
const (
	StringObj = iota // Points out an Object containing a terminal string of the parsed text,...
	UserObj          // ... the result of a hard function,...
	TermObj          // ... a tree of Object, result of a soft function,...
	NulObj           // ... or an empty Object, when an syntax error has occurred.
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Anyptr

type Anyptr interface{}

type Compilation

type Compilation interface {
	Error(pos, line, col int, msg string)
	Compile(co *Compiler, lockIfError bool) bool
	LockIfError(lock bool)
	Lock()
	StopCompil()
}

func NewCompilation

func NewCompilation(c Compilationer) Compilation

type Compilationer

type Compilationer interface {

	// Text reading method: ch is the next character read. When reading after the end of text, ch must return EOF1 or EOF2.
	Read() (ch rune, cLen int)

	// Returns the current position in the input stream of chars (origin can have any value).
	Pos() int

	// Moves the current position in the input stream of chars to pos (origin must be the same than for Pos). pos may extend until the position which follows the end of the text.
	SetPos(pos int)

	// Execution of hard functions: fNum is the index of the hard function, parsNb is the number of input parameters; pars is the list of input parameters; objPos is an Object whose position in text will be the position of res; res is the result of the hard function.
	Execution(fNum, parsNb int, pars ObjectsList) (objPos *Object, res Anyptr, ok bool)

	// Lexical and syntactic errors notification: pos position, line line number and col column number of the error; msg is the error message. pos, line and col are numbered from 1.
	Error(pos, line, col int, msg string)

	// Maps an index text to a more lengthy one. Used to make explicit or to translate error messages.
	Map(index string) string
}

type Compiler

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

type Directorier

type Directorier interface {
	ReadInt() int32 // Reads next integer in the binary file built by module BabelBabel
}

type Directory

type Directory interface {
	ReadCompiler() *Compiler
}

func NewDirectory

func NewDirectory(d Directorier) Directory

type Object

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

func Parameter

func Parameter(l ObjectsList, num int) *Object

Extracts an Object of an ObjectsList: 'l', the list; 'num', the index in the list (1 first). num must be strictly positive and not greater than the number of Objects in l.

func (*Object) Column

func (o *Object) Column() int

Column number, numbered from 1, in the parsed text, of a stringObj or userObj Object.

func (*Object) ErrorIn

func (o *Object) ErrorIn() bool

Tests whether o has the type nulObj, or the type userObj with error, or the type termObj with error or with a descendant in error.

func (*Object) Line

func (o *Object) Line() int

Line number, numbered from 1, in the parsed text, of a stringObj or userObj Object.

func (*Object) ObjFunc

func (o *Object) ObjFunc() int

Gives the number of the hard or soft function which created the userObj or termObj Object.

func (*Object) ObjNum

func (o *Object) ObjNum() int

Gives the number of an userObj or termObj Object.

func (*Object) ObjString

func (o *Object) ObjString() string

Returns, in value, the string contained in a stringObj Object or, else, the value parameter is not changed.

func (*Object) ObjStringLen

func (o *Object) ObjStringLen() int

Gives the length of the string contained in a stringObj Object.

func (*Object) ObjTermSon

func (o *Object) ObjTermSon(sonNum int) *Object

Gives a subtree of a termObj Object: sonNum is the index of the subtree (1 first). sonNum must be strictly positive and not greater than the number of subtrees of o.

func (*Object) ObjTermSonsNb

func (o *Object) ObjTermSonsNb() int

Gives the number of subtrees of a termObj Object.

func (*Object) ObjType

func (o *Object) ObjType() (t int8)

Gives the type of content of an Object: stringObj, userObj, termObj or nulObj.

func (*Object) ObjUser

func (o *Object) ObjUser() Anyptr

Gives the data contained in an userObj Object.

func (*Object) Position

func (o *Object) Position() int

Position, numbered from 1, in the parsed text, of a stringObj or userObj Object.

type ObjectsList

type ObjectsList []*Object // A list of Object, hard function parameters

Jump to

Keyboard shortcuts

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