baslex

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2023 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TkNull = iota // Null token should never be seen
	TkEOF  = iota // EOF
	TkEOL  = iota // EOL

	TkErrInput    = iota // Input error -- first error
	TkErrInternal = iota // Internal error
	TkErrInvalid  = iota // Invalid, unexpected token found
	TkErrLarge    = iota // Large token -- last error

	TkQuestion     = iota // Question ?
	TkHash         = iota // Colon #
	TkColon        = iota // Colon :
	TkComma        = iota // Comma ,
	TkSemicolon    = iota // Semicolon ; (newline suppressor)
	TkParLeft      = iota // (
	TkParRight     = iota // )
	TkBracketLeft  = iota // [
	TkBracketRight = iota // ]
	TkCommentQ     = iota // Comment '
	TkString       = iota // String "
	TkNumber       = iota // Number [0-9]+
	TkNumberHex    = iota // Number &H[0-9]+
	TkFloat        = iota // .digits | digits. | digits.digits

	TkKeywordImp = iota // IMP
	TkKeywordEqv = iota // EQV
	TkKeywordXor = iota // XOR
	TkKeywordOr  = iota // OR
	TkKeywordAnd = iota // AND
	TkKeywordNot = iota // NOT

	TkEqual   = iota // Equal
	TkUnequal = iota // Unequal <>
	TkLT      = iota // <
	TkGT      = iota // >
	TkLE      = iota // <=
	TkGE      = iota // >=

	TkPlus       = iota // +
	TkMinus      = iota // -
	TkKeywordMod = iota // MOD
	TkBackSlash  = iota // \
	TkMult       = iota // *
	TkDiv        = iota // /
	TkPow        = iota // ^
	UnaryPlus    = iota // fictitious
	UnaryMinus   = iota // fictitious

	TkKeywordAbs         = iota // ABS
	TkKeywordAsc         = iota // ASC
	TkKeywordAtn         = iota // ATN
	TkKeywordBeep        = iota // BEEP
	TkKeywordChain       = iota // CHAIN
	TkKeywordChdir       = iota // CHDIR
	TkKeywordChr         = iota // CHR$
	TkKeywordClear       = iota // CLEAR
	TkKeywordClose       = iota // CLOSE
	TkKeywordCls         = iota // CLS
	TkKeywordColor       = iota // COLOR
	TkKeywordCommon      = iota // COMMON
	TkKeywordCont        = iota // CONT
	TkKeywordCos         = iota // COS
	TkKeywordCsrlin      = iota // CSRLIN
	TkKeywordData        = iota // DATA
	TkKeywordDate        = iota // DATE$
	TkKeywordDef         = iota // DEF
	TkKeywordDefdbl      = iota // DEFDBL
	TkKeywordDefint      = iota // DEFINT
	TkKeywordDefsng      = iota // DEFSNG
	TkKeywordDefstr      = iota // DEFSTR
	TkKeywordDim         = iota // DIM
	TkKeywordElse        = iota // ELSE
	TkKeywordEnd         = iota // END
	TkKeywordEnviron     = iota // ENVIRON
	TkKeywordEnvironFunc = iota // ENVIRON$
	TkKeywordEof         = iota // EOF
	TkKeywordErase       = iota // ERASE
	TkKeywordError       = iota // ERROR
	TkKeywordFiles       = iota // FILES
	TkKeywordFix         = iota // FIX
	TkKeywordFor         = iota // FOR
	TkKeywordGodecl      = iota // _GODECL
	TkKeywordGofunc      = iota // _GOFUNC
	TkKeywordGoimport    = iota // _GOIMPORT
	TkKeywordGoproc      = iota // _GOPROC
	TkKeywordGosub       = iota // GOSUB
	TkKeywordGoto        = iota // GOTO
	TkKeywordHex         = iota // HEX$
	TkKeywordIf          = iota // IF
	TkKeywordInkey       = iota // INKEY$
	TkKeywordInput       = iota // INPUT
	TkKeywordInputFunc   = iota // INPUT$
	TkKeywordInstr       = iota // INSTR
	TkKeywordInt         = iota // INT
	TkKeywordKey         = iota // KEY
	TkKeywordKill        = iota // KILL
	TkKeywordLeft        = iota // LEFT$
	TkKeywordLen         = iota // LEN
	TkKeywordLet         = iota // LET
	TkKeywordLine        = iota // LINE
	TkKeywordList        = iota // LIST
	TkKeywordLoad        = iota // LOAD
	TkKeywordLocate      = iota // LOCATE
	TkKeywordLof         = iota // LOF
	TkKeywordLog         = iota // LOG
	TkKeywordMid         = iota // MID$
	TkKeywordMkdir       = iota // MKDIR
	TkKeywordName        = iota // NAME
	TkKeywordNext        = iota // NEXT
	TkKeywordNew         = iota // NEW
	TkKeywordOct         = iota // OCT$
	TkKeywordOff         = iota // OFF
	TkKeywordOn          = iota // ON
	TkKeywordOpen        = iota // OPEN
	TkKeywordOption      = iota // OPTION
	TkKeywordPeek        = iota // PEEK
	TkKeywordPlay        = iota // PLAY
	TkKeywordPoke        = iota // POKE
	TkKeywordPos         = iota // POS
	TkKeywordPReset      = iota // PRESET
	TkKeywordPrint       = iota // PRINT
	TkKeywordPSet        = iota // PSET
	TkKeywordRandomize   = iota // RANDOMIZE
	TkKeywordRead        = iota // READ
	TkKeywordRem         = iota // REM
	TkKeywordReset       = iota // RESET
	TkKeywordRestore     = iota // RESTORE
	TkKeywordResume      = iota // RESUME
	TkKeywordReturn      = iota // RETURN
	TkKeywordRight       = iota // RIGHT$
	TkKeywordRmdir       = iota // RMDIR
	TkKeywordRnd         = iota // RND
	TkKeywordRun         = iota // RUN
	TkKeywordSave        = iota // SAVE
	TkKeywordScreen      = iota // SCREEN
	TkKeywordSgn         = iota // SGN
	TkKeywordSin         = iota // SIN
	TkKeywordSound       = iota // SOUND
	TkKeywordSpace       = iota // SPACE$
	TkKeywordSpc         = iota // SPC
	TkKeywordSqr         = iota // SQR
	TkKeywordStep        = iota // STEP
	TkKeywordStop        = iota // STOP
	TkKeywordStr         = iota // STR$
	TkKeywordString      = iota // STRING$
	TkKeywordSwap        = iota // SWAP
	TkKeywordSystem      = iota // SYSTEM
	TkKeywordTab         = iota // TAB
	TkKeywordTan         = iota // TAN
	TkKeywordThen        = iota // THEN
	TkKeywordTime        = iota // TIME$
	TkKeywordTimer       = iota // TIMER
	TkKeywordTo          = iota // TO
	TkKeywordUsing       = iota // USING
	TkKeywordVal         = iota // VAL
	TkKeywordView        = iota // VIEW
	TkKeywordWend        = iota // WEND
	TkKeywordWhile       = iota // WHILE
	TkKeywordWidth       = iota // WIDTH

	TkIdentifier = iota // Identifier (variable)
)

(A) const tokens

View Source
const (
	TokenIDFirst = TkNull
	TokenIDLast  = TkIdentifier
)

Token ID marks

View Source
const (
	DataOff         = iota
	DataBeforeValue = iota
	DataAfterValue  = iota
)

Variables

This section is empty.

Functions

func NewInput

func NewInput(label string, reader io.Reader) *bufio.Reader

func TokenString

func TokenString(label string, t Token, offset int) string

Types

type Lex

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

Lex is a full lexer object

func New

func New(input io.ByteScanner, debug bool) *Lex

New creates a Lex object

func NewStr

func NewStr(s string, debug bool) *Lex

NewStr creates a Lex object from string

func (*Lex) Column

func (l *Lex) Column() int

Column returns current column offset within line.

func (*Lex) HasToken

func (l *Lex) HasToken() bool

HasToken checks if there are more tokens

func (*Lex) Line

func (l *Lex) Line() int

Line returns current line count.

func (*Lex) Next

func (l *Lex) Next() Token

Next gets next token. Will return EOF token unless Lex.HasToken() is true. Check for EOF token with Token.IsEOF() method.

func (*Lex) Offset

func (l *Lex) Offset() int

Offset returns total read bytes.

func (*Lex) RawLine

func (l *Lex) RawLine() string

RawLine returns current raw line.

type Token

type Token struct {
	ID         int
	Value      string
	LineCount  int
	LineOffset int
}

Token is a lexical token

func (Token) IsEOF

func (t Token) IsEOF() bool

IsEOF checks for EOF token

func (Token) IsError

func (t Token) IsError() bool

IsError checks for error token

func (Token) Type

func (t Token) Type() string

Type gets the token type

Jump to

Keyboard shortcuts

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