Documentation ¶
Overview ¶
Package lexer provides a lexical analyser for the language. The lexer passes the tokens to a channel from which a client can read.
l := lexer.Lex(filename, reader) for token := range l.Tokens { // do something with the token if token.Type == lexer.EOF { break // we are done } }
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Lexer ¶
type Lexer struct { Tokens chan Token // channel of tokens // contains filtered or unexported fields }
Lexer represents the lexical analyser.
type Token ¶
type Token struct { Pos scanner.Position // position in the input string Text string // text of this token Type Type // tpye of this token }
Token represents a token.
type Type ¶
type Type int
Type categorizes a token.
const ( EOF Type = iota // end of file Error // error, value is the text of the lexeme Ident // alphanumeric identifier // Literals False // false Number // integer number True // true // Keywords Else // else For // for If // if Print // print Var // var // Types Bool // bool Int // int // Assignment operator Assign // = // Arithmetic operators Multiply // * Divide // / Plus // + Minus // - // Relationship operators Less // < LessOrEqual // <= Greater // >= GreaterOrEqual // > Equal // == NotEqual // != // Logical operators Not // ! And // && Or // || // Delimiters LeftParen // ( RightParen // ) LeftBrace // { RightBrace // } )
Click to show internal directories.
Click to hide internal directories.