Documentation
¶
Overview ¶
Package token declares the type representing a lexical token of Lox code.
Index ¶
Constants ¶
View Source
const ( // PlaceholderIdent is the special identifier which can be used as a placeholder in declarations and assignments. PlaceholderIdent = "_" // CurrentInstanceIdent is the identifier used to refer the current instance of the class in a method. CurrentInstanceIdent = thisIdent // ConstructorIdent is the identifier used for the constructor method for classes. ConstructorIdent = "init" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type File ¶
type File struct {
// contains filtered or unexported fields
}
File is a simple representation of a file.
type Position ¶
type Position struct { File *File Line int // 1-based line number Column int // 0-based byte offset from the start of the line }
Position is a position in a file.
func (Position) Compare ¶
Compare returns
-1 if p's file comes before other's or p and other are in the same file and p comes before other, 0 if p and other are the same position in the same file, +1 if p's file comes after other's or p and other are in the same file and p comes after other.
type Range ¶
type Range interface { Start() Position // Start returns the position of the first character of the range. End() Position // End returns the position of the character immediately after the range. }
Range describes a range of characters in the source code.
type Token ¶
type Token struct { StartPos Position // Position of the first character of the token EndPos Position // Position of the character immediately after the token Type Type Lexeme string }
Token is a lexical token of Lox code.
type Type ¶
type Type int
Type is the type of a lexical token of Lox code.
const ( Illegal Type = iota EOF Print Var True False Nil If Else And Or While For Break Continue Fun Return Class This Super Static Get Set // Literals Ident String Number Comment // Symbols Semicolon Comma Dot Equal Plus Minus Asterisk Slash Percent Less LessEqual Greater GreaterEqual EqualEqual BangEqual Bang Question Colon LeftParen RightParen LeftBrace RightBrace )
The list of all token types.
func IdentType ¶
IdentType returns the type of the keyword with the given identifier, or Ident if the identifier is not a keyword.
Click to show internal directories.
Click to hide internal directories.