token

package
v0.0.0-...-20f0194 Latest Latest
Warning

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

Go to latest
Published: Dec 30, 2019 License: CC-BY-3.0, MIT Imports: 3 Imported by: 0

Documentation

Overview

5 december 2019

4 december 2019

Index

Constants

View Source
const (
	LowestPrec   = gotoken.LowestPrec
	UnaryPrec    = gotoken.UnaryPrec
	HightestPrec = gotoken.HighestPrec
)

Variables

This section is empty.

Functions

This section is empty.

Types

type File

type File = gotoken.File

type FileSet

type FileSet = gotoken.FileSet

func NewFileSet

func NewFileSet() *FileSet

type Pos

type Pos = gotoken.Pos
const NoPos Pos = gotoken.NoPos

type Position

type Position = gotoken.Position

type Token

type Token int

Token is the set of lexical tokens in the assembler.

const (
	// Special tokens.
	// These are not literals, operators, or keywords.
	ILLEGAL Token = iota
	EOF
	COMMENT

	// Literal tokens.
	IDENT
	INT
	CHAR
	STRING

	// Operators and delimiters.
	ADD // +
	SUB // -
	MUL // *
	DIV // /

	BAND // &
	BOR  // |
	BXOR // ^
	SHL  // <<
	SHR  // >>
	CMPL // ~

	EQ // ==
	NE // !=
	LT // <
	LE // <=
	GT // >
	GE // >=

	LAND // &&
	LOR  // ||
	NOT  // !

	COMMA // ,
	SEMI  // ;
	COLON // :

	AT   // @ (denotes local labels)
	NEXT // :+ (reference to next nameless label in scope)
	PREV // :- (reference to previous nameless label in scope)

	POUND // #

	LPAREN // (
	RPAREN // )

	// Keywords and entire classes of keywords for 68000-specific tokens.
	OPCODE    // all opcodes
	DATAREG   // d0 .. d7
	ADDRREG   // a0 .. a7, sp
	DATAREG_W // d0.w .. d7.w
	ADDRREG_W // a0.w .. a7.w, sp.w
	DATAREG_L // d0.l .. d7.l
	ADDRREG_L // a0.l .. a7.l, sp.l

	PC    // pc
	USP   // usp
	CCR   // ccr
	SR    // sr
	DOT_W // .w (absolute addressing suffix)
	DOT_L // .l (absolute addressing suffix)

	DOT // . (the current position; equivalent to $ or * in other assemblers)
	MOD // .mod

)

Predefined tokens.

func Lookup

func Lookup(str string) Token

Lookup returns the token type for the identifier or keyword stored in str. If str does not store a keyword, IDENT is returned.

func (Token) IsKeyword

func (t Token) IsKeyword() bool

IsKeyword returns whether t is a keyword.

func (Token) IsLiteral

func (t Token) IsLiteral() bool

IsLiteral returns whether t is a literal.

func (Token) IsOperator

func (t Token) IsOperator() bool

IsOperator returns whether t is an operator. MOD is not considered an operator for the purposes of this test.

func (Token) Precedence

func (t Token) Precedence() int

Precedence returns the binary-operator precedence for t. The precedence of MOD is the same as that of MUL. Precedence rules are the same as in Go. If t is neither MOD nor a binary operator, LowestPrec is returned.

func (Token) String

func (t Token) String() string

String returns the string for t.

Jump to

Keyboard shortcuts

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