lexer

package
v0.0.0-...-54e147c Latest Latest
Warning

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

Go to latest
Published: Jan 1, 2016 License: MIT Imports: 4 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Lexer

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

func MakeLexer

func MakeLexer(f io.ByteReader, fname string) Lexer

func (*Lexer) NextToken

func (l *Lexer) NextToken() Token

type Position

type Position struct {
	Filename string
	Line     int
	Column   int
}

func (Position) Move

func (p Position) Move(cols int) Position

type Token

type Token struct {
	Position   Position
	Type       TokenType
	SourceCode string
	Payload    interface{}
}

func (Token) IsAssignOp

func (t Token) IsAssignOp() bool

func (Token) IsComment

func (t Token) IsComment() bool

func (Token) IsDelim

func (t Token) IsDelim() bool

func (Token) IsKeyword

func (t Token) IsKeyword() bool

func (Token) IsLiteral

func (t Token) IsLiteral() bool

func (Token) IsOp

func (t Token) IsOp() bool

type TokenType

type TokenType int
const (
	EndOfFile TokenType = iota

	LineComment
	BlockComment

	Identifier

	BreakKeyword
	CaseKeyword
	ChanKeyword
	ConstKeyword
	ContinueKeyword
	DefaultKeyword
	DeferKeyword
	ElseKeyword
	FallthroughKeyword
	ForKeyword
	FuncKeyword
	GoKeyword
	GotoKeyword
	IfKeyword
	ImportKeyword
	InterfaceKeyword
	MapKeyword
	PackageKeyword
	RangeKeyword
	ReturnKeyword
	SelectKeyword
	StructKeyword
	SwitchKeyword
	TypeKeyword
	VarKeyword

	AddOp // +
	SubOp // -
	MulOp // *
	DivOp // /
	ModOp // %

	BitAndOp   // &
	BitOrrOp   // |
	BitXorOp   // ^
	ShlOp      // <<
	ShrOp      // >>
	BitClearOp // &^

	DefineOp         // :=
	AssignOp         // =
	AddAssignOp      // +=
	SubAssignOp      // -=
	MulAssignOp      // *=
	DivAssignOp      // /=
	ModAssignOp      // %=
	BitAndAssignOp   // &=
	BitOrrAssignOp   // |=
	BitXorAssignOp   // ^=
	ShlAssignOp      // <<=
	ShrAssignOp      // >>=
	BitClearAssignOp // &^=

	LogicNotOp // !
	LogicAndOp // &&
	LogicOrrOp // ||
	LtOp       // <
	GtOp       // >
	EqOp       // ==
	NeqOp      // !=
	LteOp      // <=
	GteOp      // >=

	ChanOpOp    // <-
	IncrementOp // ++
	DecrementOp // --

	EllipsisOp // ...

	EndOfLine
	ElidedSemicolon
	Semicolon

	LParen
	LBracket
	LBrace
	RParen
	RBracket
	RBrace

	Comma
	Dot
	Colon

	DecimalIntegerLiteral
	OctalIntegerLiteral
	HexIntegerLiteral
	BinaryIntegerLiteral

	FloatLiteral

	ImaginaryLiteral

	RuneLiteral

	InterpretedStringLiteral
	RawStringLiteral
)

Reference: https://golang.org/ref/spec#Lexical_elements

func (TokenType) String

func (tt TokenType) String() string

Jump to

Keyboard shortcuts

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