Documentation ¶
Overview ¶
Package gleanerrors contains types used to report errors from parsers generated by glean.
Although default error messages are provided, these will likely be unsatisfactory in practice. A program using a glean parser can likely produce better messages based on the context in which the parser is used.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Ambiguous ¶
type Ambiguous struct { // The range in which the ambiguity occurs. Range // Two of the rules that could be applied in valid parses. Possibly identical. // // These rules will have the same target symbol, and will apply to the // subsequence of tokens inside the parser input; this subsequence may // be larger than indicated in Range. Rule1, Rule2 Rule }
There were multiple matches of a symbol to a range of input tokens.
Only two matches are reported. It is possible for Rule1 and Rule2 to be identical, if a single rule can be applied in multiple ways.
type Location ¶
type Location struct { // The index of the token within the slice given to the parser. Index int // The token itself. Token interface{} }
Location identifies a single token in the input passed to a parse function.
func MakeLocation ¶
MakeLocation returns the Location for a specific token.
In edge cases, n might be -1 or len(tokens); if so, a nil token is used.
type Range ¶
type Range struct {
First, Last Location
}
Range indicates the position of an error that may span multiple tokens.
If the range is empty, Last.Index will be First.Index - 1; if this means Last.Index is -1, then Last.Token will be nil.
type Unexpected ¶
type Unexpected struct { // The token found in the input. Location }
A token did not match any rule expected at its position in the input.
This is also returned when the parser input ends prematurely, without forming a valid match for the target symbol. In this case, Location.Index will be the length of the input, and Location.Token will be nil.
Currently, the list of symbols valid at this point in the input is not returned. This may or may not be added in future.