text

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2020 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LParen = 0 + iota
	RParen
	LBrace
	RBrace
	LBracket
	RBracket
	Comma
	Semicolon
	SymbolHash
	SymbolAt
	SymbolDollar
	EOL
	EOF
	UnaryOperator
	BinaryOperator
	SymbolArrow
	Identifier
	Number
	SingleQuotedString
	DoubleQuotedString
	KeywordIF
	KeywordELSE
	KeywordFOR
	KeywordUNTIL
	DirDeposit
	DirNumberFormat
	KeywordEnum
	KeywordOpcode
	DirError
	KeywordInclude
	GenericSeparator
	TokenCommand
)

TokenType values

Variables

View Source
var TokenTypeMap = map[string]TokenType{
	"(": LParen, ")": RParen, "[": LBracket, "]": RBracket, "{": LBrace, "}": RBrace,
	",": Comma, ";": Semicolon, "if": KeywordIF, "else": KeywordELSE, ".db": DirDeposit, ".dw": DirDeposit,
	".dd": DirDeposit, ".opcode": KeywordOpcode, ".enum": KeywordEnum, ".number": DirNumberFormat, ".error": DirError,
	"->": SymbolArrow, "$": SymbolDollar, "#": SymbolHash, "@": SymbolAt, ".include": KeywordInclude, "for": KeywordFOR, "until": KeywordUNTIL,
}

TokenTypeMap contains separators and keyword tokens

Functions

This section is empty.

Types

type SourceLine

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

SourceLine keep original strings with whitespaces, line number and source name

func NewSourceLine

func NewSourceLine(words []string, lineNumber uint, sourceName string) *SourceLine

NewSourceLine create a new source line

func (*SourceLine) AllStrings

func (line *SourceLine) AllStrings() []string

AllStrings return a slice with all strings in the line

func (*SourceLine) LineNumber

func (line *SourceLine) LineNumber() uint

LineNumber return the line number

func (*SourceLine) Print

func (line *SourceLine) Print(ui ui.UI)

Print print the line

func (*SourceLine) RuneIndex

func (line *SourceLine) RuneIndex(ui ui.UI, indexOfWord uint) uint

RuneIndex calculate the index of the first rune of the indexOfWord argument

func (*SourceLine) SourceName

func (line *SourceLine) SourceName() string

SourceName return the source in which this line is found

func (*SourceLine) StringAt

func (line *SourceLine) StringAt(i uint) string

StringAt return the string at i index

type Token

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

Token of parsing, extends lexing.Token adding a TokenType to the token

func NewInternalToken

func NewInternalToken(value string) Token

NewInternalToken create new token with internal identifier Testing only

func NewSpecialToken

func NewSpecialToken(derived Token, value string, tType TokenType) Token

NewSpecialToken create a special token that have the same position of another one

func NewToken

func NewToken(value string, tType TokenType, lineIndex uint, line *SourceLine) Token

NewToken create a new Token

func (Token) EnumType

func (t Token) EnumType() TokenType

EnumType return the type assigned by parser

func (Token) Position

func (t Token) Position() (line uint, pos uint, file string)

Position return the position of this token in the source (as collection of sources)

func (Token) Value

func (t Token) Value() string

Value return the value assigned by parser

func (Token) WithType

func (t Token) WithType(tType TokenType) Token

WithType return a copy of the token with specified type

func (Token) WithValue

func (t Token) WithValue(value string) Token

WithValue return a copy of the token with specified value

type TokenType

type TokenType int

TokenType is the token type of the token

func (TokenType) String

func (tt TokenType) String() string

String method of TokenType

Jump to

Keyboard shortcuts

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