Documentation ¶
Overview ¶
A scanner for the DOT grammar that has been derived from the standard golang scanner with extra added literals.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Error ¶
Within ErrorVector, an error is represented by an Error node. The position Pos, if valid, points to the beginning of the offending token, and the error condition is described by Msg.
type ErrorHandler ¶
An implementation of an ErrorHandler may be provided to the Scanner. If a syntax error is encountered and a handler was installed, Error is called with a position and an error message. The position points to the beginning of the offending token.
type Scanner ¶
type Scanner struct { // public state - ok to modify ErrorCount int // number of errors encountered // contains filtered or unexported fields }
A Scanner holds the scanner's internal state while processing a given text. It can be allocated as part of another data structure but must be initialized via Init before use. For a sample use, see the implementation of Tokenize.
func (*Scanner) Init ¶
Init prepares the scanner S to tokenize the text src. Calls to Scan will use the error handler err if they encounter a syntax error and err is not nil. Also, for each error encountered, the Scanner field ErrorCount is incremented by one. The filename parameter is used as filename in the token.Position returned by Scan for each token. The mode parameter determines how comments and illegal characters are handled.
func (*Scanner) Scan ¶
Scan scans the next token and returns the token position pos, the token tok, and the literal text lit corresponding to the token. The source end is indicated by token.EOF.
For more tolerant parsing, Scan will return a valid token if possible even if a syntax error was encountered. Thus, even if the resulting token sequence contains no illegal tokens, a client may not assume that no error occurred. Instead it must check the scanner's ErrorCount or the number of calls of the error handler, if there was one installed.