type Dispenser … // NewDispenser returns a Dispenser, ready to use for parsing the given input. func NewDispenser(filename string, input io.Reader) Dispenser { … } // NewDispenserTokens returns a Dispenser filled with the given tokens. func NewDispenserTokens(filename string, tokens []Token) Dispenser { … } // Next loads the next token. Returns true if a token // was loaded; false otherwise. If false, all tokens // have been consumed. func (d *Dispenser) Next() bool { … } // NextArg loads the next token if it is on the same // line. Returns true if a token was loaded; false // otherwise. If false, all tokens on the line have // been consumed. It handles imported tokens correctly. func (d *Dispenser) NextArg() bool { … } // NextLine loads the next token only if it is not on the same // line as the current token, and returns true if a token was // loaded; false otherwise. If false, there is not another token // or it is on the same line. It handles imported tokens correctly. func (d *Dispenser) NextLine() bool { … } // NextBlock can be used as the condition of a for loop // to load the next token as long as it opens a block or // is already in a block. It returns true if a token was // loaded, or false when the block's closing curly brace // was loaded and thus the block ended. Nested blocks are // not supported. func (d *Dispenser) NextBlock() bool { … } // Val gets the text of the current token. If there is no token // loaded, it returns empty string. func (d *Dispenser) Val() string { … } // Line gets the line number of the current token. If there is no token // loaded, it returns 0. func (d *Dispenser) Line() int { … } // File gets the filename of the current token. If there is no token loaded, // it returns the filename originally given when parsing started. func (d *Dispenser) File() string { … } // Args is a convenience function that loads the next arguments // (tokens on the same line) into an arbitrary number of strings // pointed to in targets. If there are fewer tokens available // than string pointers, the remaining strings will not be changed // and false will be returned. If there were enough tokens available // to fill the arguments, then true will be returned. func (d *Dispenser) Args(targets ...*string) bool { … } // RemainingArgs loads any more arguments (tokens on the same line) // into a slice and returns them. Open curly brace tokens also indicate // the end of arguments, and the curly brace is not included in // the return value nor is it loaded. func (d *Dispenser) RemainingArgs() []string { … } // ArgErr returns an argument error, meaning that another // argument was expected but not found. In other words, // a line break or open curly brace was encountered instead of // an argument. func (d *Dispenser) ArgErr() error { … } // SyntaxErr creates a generic syntax error which explains what was // found and what was expected. func (d *Dispenser) SyntaxErr(expected string) error { … } // EOFErr returns an error indicating that the dispenser reached // the end of the input when searching for the next token. func (d *Dispenser) EOFErr() error { … } // Err generates a custom parse-time error with a message of msg. func (d *Dispenser) Err(msg string) error { … } // Errf is like Err, but for formatted error messages func (d *Dispenser) Errf(format string, args ...interface{ … } // numLineBreaks counts how many line breaks are in the token // value given by the token index tknIdx. It returns 0 if the // token does not exist or there are no line breaks. func (d *Dispenser) numLineBreaks(tknIdx int) int { … } // isNewLine determines whether the current token is on a different // line (higher line number) than the previous token. It handles imported // tokens correctly. If there isn't a previous token, it returns true. func (d *Dispenser) isNewLine() bool { … }