Documentation ¶
Index ¶
- func DescribeToken(token *Token) string
- func DescribeTokenKind(kind TokenKind) string
- func GetTokenOpOpcode(opKind TokenKind) arch.Opcode
- func IsTokenDirective(kind TokenKind) bool
- func IsTokenIdentifier(kind TokenKind) bool
- func IsTokenImm(kind TokenKind) bool
- func IsTokenOp(kind TokenKind) bool
- type Token
- type TokenKind
- type TokenStream
- type Tokenizer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DescribeToken ¶
DescribeToken returns a human-readable token description, including contextual information if applicable like register number.
func DescribeTokenKind ¶
DescribeTokenKind returns a human-readable TokenKind
func GetTokenOpOpcode ¶
GetTokenOpOpcode returns the arch.Opcode for the given TokenKind
func IsTokenDirective ¶
IsTokenDirective returns whether the token is in the Directive category
func IsTokenIdentifier ¶
IsTokenIdentifier returns whether the token is in the Identifier category
func IsTokenImm ¶
IsTokenImm returns whether the token is in the Imm category
Types ¶
type TokenKind ¶
type TokenKind int
const ( ADD TokenKind ADDI SUB SUBI AND OR XOR LSL LSR CMP CMPI LDREG LDWORD LDHWRD LDBYTE STREG STWORD STHWRD STBYTE ADR MOV MOVZ MOVK B BREG BLR B_EQ B_NEQ B_LT B_LE B_GT B_GE BL PUSH POP SYSCALL HALT NOOP REGISTER IDENTIFIER BASE_8_IMM BASE_10_IMM BASE_16_IMM LABEL_DECLARATION SECTION FILL_STATEMENT STRING_STATEMENT ADDRESS_OF STRING LABEL COMMA LBRACKET RBRACKET COMMENT LINE_END )
type TokenStream ¶
type TokenStream struct {
// contains filtered or unexported fields
}
TokenStream describes a stream of lexer Tokens
func NewTokenStream ¶
func NewTokenStream(tokens []*Token) *TokenStream
NewTokenStream returns a TokenStream encapsulating tokens.
tokens should not be modified while TokenStream is in use.
func (*TokenStream) HasNext ¶
func (ts *TokenStream) HasNext() bool
HasNext returns whether the stream has more tokens
func (*TokenStream) Jump ¶
func (ts *TokenStream) Jump(pos int)
Jump goes to an arbitrary position within the TokenStream
func (*TokenStream) Peek ¶
func (ts *TokenStream) Peek() *Token
Peek returns the next Token without removing it
func (*TokenStream) Pop ¶
func (ts *TokenStream) Pop() *Token
Pop removes and returns the next Token, advancing the stream
func (*TokenStream) Pos ¶
func (ts *TokenStream) Pos() int
Pos returns the current position in the TokenStream
func (*TokenStream) Remaining ¶
func (ts *TokenStream) Remaining() int
Remaining returns how many tokens remain in the stream