compiler

package
v0.0.0-...-a184b3a Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2018 License: BSD-3-Clause Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Int

func Int(value int64) *big.Int

func WriteString

func WriteString(output io.Writer, data string)

Types

type Base

type Base interface {
	Push(c *Compiler, name string)
	Pull(c *Compiler, name string)
	Drop(c *Compiler)
	Free(c *Compiler)

	//Attach/Detach from a list.
	Attach(c *Compiler)
	Detach(c *Compiler)
}

type Cache

type Cache struct {
	bytes.Buffer
}

type Compiler

type Compiler struct {
	Syntax

	CurrentFunction *Function

	Language Language

	GlobalScope Scope
	Scope       []Scope

	Header io.Writer
	Output io.Writer

	StdErr []io.Writer

	DisableOutput bool

	Scanners []*scanner.Scanner

	CurrentLines []string
	LastLine     string

	LineOffset int
	NextToken  string
	DoneToken  bool

	Errors bool
	// contains filtered or unexported fields
}

func (*Compiler) Add

func (c *Compiler) Add()

func (*Compiler) AddInput

func (c *Compiler) AddInput(input io.Reader)

func (*Compiler) Back

func (c *Compiler) Back()

func (*Compiler) BigData

func (c *Compiler) BigData(name string, data ...*big.Int)

func (*Compiler) BigInt

func (c *Compiler) BigInt(value *big.Int)

func (*Compiler) Call

func (c *Compiler) Call(f *Function)

func (*Compiler) CallRaw

func (c *Compiler) CallRaw(data string)

func (*Compiler) Cast

func (c *Compiler) Cast(a, b Type) bool

func (*Compiler) Channel

func (c *Compiler) Channel() string

func (*Compiler) Code

func (c *Compiler) Code(data string)

func (*Compiler) CollectAll

func (c *Compiler) CollectAll()

func (*Compiler) Compile

func (c *Compiler) Compile()

func (*Compiler) CompileCache

func (c *Compiler) CompileCache(cache Cache, name string, line int)

func (*Compiler) Copy

func (c *Compiler) Copy()

func (*Compiler) CopyList

func (c *Compiler) CopyList()

func (*Compiler) CopyPipe

func (c *Compiler) CopyPipe()

func (*Compiler) Data

func (c *Compiler) Data(name string, data []byte)

func (*Compiler) DeleteFlag

func (c *Compiler) DeleteFlag(flag Flag)

func (*Compiler) Div

func (c *Compiler) Div()

func (*Compiler) Done

func (c *Compiler) Done()

func (*Compiler) Drop

func (c *Compiler) Drop()

func (*Compiler) DropList

func (c *Compiler) DropList()

func (*Compiler) DropPipe

func (c *Compiler) DropPipe()

func (*Compiler) DropType

func (c *Compiler) DropType(t Type)

func (*Compiler) Error

func (c *Compiler) Error() string

func (*Compiler) Exit

func (c *Compiler) Exit()

func (*Compiler) Expected

func (c *Compiler) Expected(tokens ...string)

func (*Compiler) Expecting

func (c *Compiler) Expecting(token string)

func (*Compiler) ExpectingType

func (c *Compiler) ExpectingType(t Type)

func (*Compiler) Expression

func (c *Compiler) Expression() Type

func (*Compiler) Flip

func (c *Compiler) Flip()

func (*Compiler) Fork

func (c *Compiler) Fork()

func (*Compiler) Free

func (c *Compiler) Free()

func (*Compiler) FreeList

func (c *Compiler) FreeList()

func (*Compiler) FreePipe

func (c *Compiler) FreePipe()

func (*Compiler) FreeType

func (c *Compiler) FreeType(t Type)

func (*Compiler) GainScope

func (c *Compiler) GainScope()

func (*Compiler) Get

func (c *Compiler) Get()

func (*Compiler) GetFlag

func (c *Compiler) GetFlag(flag Flag) (Flag, int)

func (*Compiler) GetFunction

func (c *Compiler) GetFunction(name string) *Function

func (*Compiler) GetOperator

func (c *Compiler) GetOperator(symbol string) Operator

func (*Compiler) GetScope

func (c *Compiler) GetScope() Scope

func (*Compiler) GetType

func (c *Compiler) GetType(name string) *Type

func (*Compiler) GetVariable

func (c *Compiler) GetVariable(name string) Variable

func (*Compiler) Global

func (c *Compiler) Global() string

func (*Compiler) GlobalFlagExists

func (c *Compiler) GlobalFlagExists(f Flag) bool

func (*Compiler) Heap

func (c *Compiler) Heap()

func (*Compiler) HeapList

func (c *Compiler) HeapList()

func (*Compiler) HeapPipe

func (c *Compiler) HeapPipe()

func (*Compiler) If

func (c *Compiler) If()

func (*Compiler) Info

func (c *Compiler) Info()

func (*Compiler) Int

func (c *Compiler) Int(value int64)

func (*Compiler) Less

func (c *Compiler) Less()
func (c *Compiler) Link(data string)

func (*Compiler) List

func (c *Compiler) List()

func (*Compiler) Load

func (c *Compiler) Load()

func (*Compiler) LoadCache

func (c *Compiler) LoadCache(cache Cache, name string, line int)

func (*Compiler) Loop

func (c *Compiler) Loop()

func (*Compiler) LoseScope

func (c *Compiler) LoseScope()

func (*Compiler) Main

func (c *Compiler) Main()

func (*Compiler) Make

func (c *Compiler) Make()

func (*Compiler) Mod

func (c *Compiler) Mod()

func (*Compiler) More

func (c *Compiler) More()

func (*Compiler) Move

func (c *Compiler) Move()

func (*Compiler) Mul

func (c *Compiler) Mul()

func (*Compiler) Name

func (c *Compiler) Name(data string)

func (*Compiler) NameList

func (c *Compiler) NameList(data string)

func (*Compiler) NamePipe

func (c *Compiler) NamePipe(data string)

func (*Compiler) Native

func (c *Compiler) Native(target, data string)

func (*Compiler) NewCache

func (c *Compiler) NewCache(open, close string) Cache

func (*Compiler) No

func (c *Compiler) No()

func (*Compiler) Open

func (c *Compiler) Open()

func (*Compiler) Or

func (c *Compiler) Or()

func (*Compiler) Peek

func (c *Compiler) Peek() string

func (*Compiler) Pipe

func (c *Compiler) Pipe()

func (*Compiler) Pop

func (c *Compiler) Pop()

func (*Compiler) Pow

func (c *Compiler) Pow()

func (*Compiler) Pull

func (c *Compiler) Pull(data string)

func (*Compiler) PullList

func (c *Compiler) PullList(data string)

func (*Compiler) PullPipe

func (c *Compiler) PullPipe(data string)

func (*Compiler) PullType

func (c *Compiler) PullType(t Type, data string)

func (*Compiler) Push

func (c *Compiler) Push(data string)

func (*Compiler) PushList

func (c *Compiler) PushList(data string)

func (*Compiler) PushPipe

func (c *Compiler) PushPipe(data string)

func (*Compiler) PushType

func (c *Compiler) PushType(t Type, data string)

func (*Compiler) Put

func (c *Compiler) Put()

func (*Compiler) RaiseError

func (c *Compiler) RaiseError(message Translatable)

func (*Compiler) Read

func (c *Compiler) Read()

func (*Compiler) Redo

func (c *Compiler) Redo()

func (*Compiler) Same

func (c *Compiler) Same()

func (*Compiler) Scan

func (c *Compiler) Scan() string

func (*Compiler) ScanEmbeddedStatement

func (c *Compiler) ScanEmbeddedStatement(t Type)

func (*Compiler) ScanExpression

func (c *Compiler) ScanExpression() Type

func (*Compiler) ScanIf

func (c *Compiler) ScanIf(test string) bool

func (*Compiler) ScanStatement

func (c *Compiler) ScanStatement()

func (*Compiler) Seek

func (c *Compiler) Seek()

func (*Compiler) Send

func (c *Compiler) Send()

func (*Compiler) Set

func (c *Compiler) Set()

func (*Compiler) SetFlag

func (c *Compiler) SetFlag(f Flag)

func (*Compiler) SetGlobal

func (c *Compiler) SetGlobal(name string, t Type)

func (*Compiler) SetGlobalFlag

func (c *Compiler) SetGlobalFlag(f Flag)

func (*Compiler) SetSyntax

func (c *Compiler) SetSyntax(s Syntax)

func (*Compiler) SetVariable

func (c *Compiler) SetVariable(name string, t Type)

func (*Compiler) Shunt

func (c *Compiler) Shunt(t Type, precedence int) Type

func (*Compiler) Size

func (c *Compiler) Size()

func (*Compiler) Stop

func (c *Compiler) Stop()

func (*Compiler) Sub

func (c *Compiler) Sub()

func (*Compiler) Swap

func (c *Compiler) Swap()

func (*Compiler) SwapList

func (c *Compiler) SwapList()

func (*Compiler) SwapOutput

func (c *Compiler) SwapOutput()

func (*Compiler) SwapPipe

func (c *Compiler) SwapPipe()

func (*Compiler) Token

func (c *Compiler) Token() string

func (*Compiler) UndefinedError

func (c *Compiler) UndefinedError(token string)

func (*Compiler) Unexpected

func (c *Compiler) Unexpected(token string)

func (*Compiler) Unimplemented

func (c *Compiler) Unimplemented()

func (*Compiler) UpdateFlag

func (c *Compiler) UpdateFlag(flag Flag)

func (*Compiler) UpdateVariable

func (c *Compiler) UpdateVariable(name string, t Type)

func (*Compiler) Used

func (c *Compiler) Used()

func (*Compiler) Wrap

func (c *Compiler) Wrap(data string)

type Data

type Data interface {
	Equals(Data) bool
	Name(Language) string
}

type DefaultBase

type DefaultBase byte
const (
	NULL DefaultBase = iota
	INT
	LIST
	PIPE
)

func (DefaultBase) Attach

func (d DefaultBase) Attach(c *Compiler)

func (DefaultBase) Detach

func (d DefaultBase) Detach(c *Compiler)

func (DefaultBase) Drop

func (d DefaultBase) Drop(c *Compiler)

func (DefaultBase) Free

func (d DefaultBase) Free(c *Compiler)

func (DefaultBase) Pull

func (d DefaultBase) Pull(c *Compiler, name string)

func (DefaultBase) Push

func (d DefaultBase) Push(c *Compiler, name string)

type Expression

type Expression struct {
	Name   Translatable
	OnScan func(*Compiler) Type

	Detect func(*Compiler) *Type
}

type Flag

type Flag struct {
	Name  Translatable
	Value int
	Data  string
	Bool  bool

	Defined bool

	OnLost func(*Compiler)
}

type Function

type Function struct {
	Name Translatable

	Arguments []Type
	Tokens    []string

	Returns []Type

	Flags []Flag

	Inline  func(*Compiler)
	Compile func(*Compiler)

	Variadic bool

	Data interface{}
	// contains filtered or unexported fields
}

type Language

type Language int
const (
	English Language = iota

	Afrikaans
	Albanian
	Amharic
	Arabic
	Armenian
	Azerbaijani
	Basque
	Belarusian
	Bengali
	Bosnian
	Bulgarian
	Burmese
	Catalan
	Cebuano
	Chichewa
	Chinese
	Corsican
	Croatian
	Czech
	Danish
	Dutch
	Esperanto
	Estonian
	Filipino
	Finnish
	French
	Frisian
	Galician
	Georgian
	German
	Greek
	Gujarati
	HaitianCreole
	Hausa
	Hawaiian
	Hebrew
	Hindi
	Hmong
	Hungarian
	Icelandic
	Igbo
	Indonesian
	Irish
	Italian
	Japanese
	Javanese
	Kannada
	Kazakh
	Khmer
	Korean
	Kurdish
	Kyrgyz
	Lao
	Latin
	Latvian
	Lithuanian
	Luxembourgish
	Macedonian
	Malagasy
	Malay
	Malayalam
	Maltese
	Maori
	Marathi
	Mongolian
	Nepali
	Norwegian
	Pashto
	Persian
	Polish
	Portuguese
	Punjabi
	Romanian
	Russian
	Samoan
	ScotsGaelic
	Serbian
	Sesotho
	Shona
	Sindhi
	Sinhala
	Slovak
	Slovenian
	Somali
	Spanish
	Sundanese
	Swahili
	Swedish
	Tajik
	Tamil
	Telugu
	Thai
	Turkish
	Ukrainian
	Urdu
	Uzbek
	Vietnamese
	Welsh
	Xhosa
	Yiddish
	Yoruba
	Zulu

	Klingon

	All
)

type Operator

type Operator struct {
	Symbol     string
	Precedence int
}

type Scope

type Scope struct {
	Variables map[string]Variable
	Flags     map[string]Flag
}

func NewScope

func NewScope() Scope

type Shunt

type Shunt map[string]func(*Compiler, Type) Type

type Statement

type Statement struct {
	Name Translatable

	OnScan func(*Compiler)
	Detect func(*Compiler) bool
}

type Syntax

type Syntax struct {
	Name string

	Statements  []Statement
	Expressions []Expression
	Types       []Type
	Functions   []*Function

	Operators []Operator

	Aliases map[string]string
}

func NewSyntax

func NewSyntax(name string) Syntax

func (*Syntax) RegisterAlias

func (s *Syntax) RegisterAlias(from string, to string)

func (*Syntax) RegisterExpression

func (s *Syntax) RegisterExpression(expression Expression)

func (*Syntax) RegisterFunction

func (s *Syntax) RegisterFunction(f *Function)

func (*Syntax) RegisterOperator

func (s *Syntax) RegisterOperator(symbol string, p int)

func (*Syntax) RegisterStatement

func (s *Syntax) RegisterStatement(statement Statement)

func (*Syntax) RegisterType

func (s *Syntax) RegisterType(t Type)

type Translatable

type Translatable [All + 1]string

func NoTranslation

func NoTranslation(name string) Translatable

type Type

type Type struct {
	Data

	Name Translatable
	Base Base

	Immutable bool
	Fake      bool
	Constant  bool

	Cast  func(c *Compiler, a Type, b Type) bool
	Shunt func(c *Compiler, symbol string, a Type, b Type) *Type

	Casts []func(c *Compiler, t Type) bool

	Shunts map[string]func(*Compiler, Type) Type

	Collect func(*Compiler)

	EmbeddedStatement func(*Compiler, Type)
}

func (Type) Equals

func (t Type) Equals(b Type) bool

func (Type) String

func (t Type) String() string

func (Type) With

func (t Type) With(d Data) Type

type Variable

type Variable struct {
	Type
	Defined, Protected, Modified, Embedded bool

	Index int
	List  string

	DefinedAtLineNumber int
	DefinedAtLine       string
}

Jump to

Keyboard shortcuts

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