Documentation
¶
Overview ¶
Package lex implements lexical analysis for the assembler.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsRegisterShift ¶
IsRegisterShift reports whether the token is one of the ARM register shift operators.
Types ¶
type Input ¶
type Input struct { Stack // contains filtered or unexported fields }
Input is the main input: a stack of readers and some macro definitions. It also handles #include processing (by pushing onto the input stack) and parses and instantiates macro definitions.
func (*Input) Push ¶
func (in *Input) Push(r TokenReader)
type Macro ¶
type Macro struct {
// contains filtered or unexported fields
}
A Macro represents the definition of a #defined macro.
type ScanToken ¶
type ScanToken rune
A ScanToken represents an input item. It is a simple wrapping of rune, as returned by text/scanner.Scanner, plus a couple of extra values.
type Slice ¶
type Slice struct {
// contains filtered or unexported fields
}
A Slice reads from a slice of Tokens.
type Stack ¶
type Stack struct {
// contains filtered or unexported fields
}
A Stack is a stack of TokenReaders. As the top TokenReader hits EOF, it resumes reading the next one down.
func (*Stack) Push ¶
func (s *Stack) Push(tr TokenReader)
Push adds tr to the top (end) of the input stack. (Popping happens automatically.)
type Token ¶
type Token struct { ScanToken // contains filtered or unexported fields }
A Token is a scan token plus its string value. A macro is stored as a sequence of Tokens with spaces stripped.
type TokenReader ¶
type TokenReader interface { Next() ScanToken Text() string File() string Base() *src.PosBase SetBase(*src.PosBase) Line() int Col() int Close() }
A TokenReader is like a reader, but returns lex tokens of type Token. It also can tell you what the text of the most recently returned token is, and where it was found. The underlying scanner elides all spaces except newline, so the input looks like a stream of Tokens; original spacing is lost but we don't need it.
func NewLexer ¶
func NewLexer(name string) TokenReader
NewLexer returns a lexer for the named file and the given link context.