Documentation ¶
Index ¶
- type Char
- type Token
- func (t *Token) DebugString() string
- func (t *Token) From() (line, column int)
- func (t *Token) IsLiteral(lit string) bool
- func (t *Token) IsOneOfLiterals(lits ...string) bool
- func (t *Token) IsOneOfTypes(tys ...TokenType) bool
- func (t *Token) IsType(ty TokenType) bool
- func (t *Token) Range() (fromLine, fromColumn, toLine, toColumn int)
- func (t *Token) RangeColumns() (from, to int)
- func (t *Token) RangeLines() (from, to int)
- func (t *Token) To() (line, column int)
- func (t Token) WithLiteral(lit string) *Token
- func (t Token) WithRange(fromLine, fromColumn, toLine, toColumn int) *Token
- func (t Token) WithRangeChars(from, to Char) *Token
- func (t Token) WithType(tp TokenType) *Token
- type TokenType
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Char ¶
Represents a character in the source code, with its position.
type Token ¶
type Token struct { Type TokenType Literal string FromLine int FromColumn int ToLine int ToColumn int }
Represents a token in the source code.
tokens.NewToken(EOF, "").WithRangeChars(from, to)
func (*Token) DebugString ¶
Pretty string representation of the token.
func (*Token) IsOneOfLiterals ¶
Returns true if the token is one of the given literals.
func (*Token) IsOneOfTypes ¶ added in v0.2.0
Returns true if the token is of the given type.
func (*Token) RangeColumns ¶ added in v0.2.0
Returns the range of the token ignoring the lines. Starting at 1.
func (*Token) RangeLines ¶ added in v0.2.0
Returns the range of the starting and final lines. Starting at 1.
func (Token) WithLiteral ¶ added in v0.2.0
Creates a new token with the given literal. You can use this method as a chain.
func (Token) WithRange ¶ added in v0.2.0
Creates a new token with the given range. You can use this method as a chain.
func (Token) WithRangeChars ¶ added in v0.2.0
Creates a new token with the given char range. You can use this method as a chain.
Click to show internal directories.
Click to hide internal directories.