Skip to content

Commit

Permalink
document parameter "filename" for the Parser methods
Browse files Browse the repository at this point in the history
  • Loading branch information
marco-m authored and alecthomas committed Jun 19, 2022
1 parent 9bf3906 commit 71ce420
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func MustBuild(grammar interface{}, options ...Option) *Parser {
// If "Lexer()" is not provided as an option, a default lexer based on text/scanner will be used. This scans typical Go-
// like tokens.
//
// See documentation for details
// See documentation for details.
func Build(grammar interface{}, options ...Option) (parser *Parser, err error) {
// Configure Parser struct with defaults + options.
p := &Parser{
Expand Down Expand Up @@ -122,6 +122,7 @@ func (p *Parser) Lexer() lexer.Definition {
}

// Lex uses the parser's lexer to tokenise input.
// Parameter filename is used as an opaque prefix in error messages.
func (p *Parser) Lex(filename string, r io.Reader) ([]lexer.Token, error) {
lex, err := p.lex.Lex(filename, r)
if err != nil {
Expand Down Expand Up @@ -174,7 +175,7 @@ func (p *Parser) parse(lex lexer.Lexer, v interface{}, options ...ParseOption) (
}

// Parse from r into grammar v which must be of the same type as the grammar passed to
// Build().
// Build(). Parameter filename is used as an opaque prefix in error messages.
//
// This may return an Error.
func (p *Parser) Parse(filename string, r io.Reader, v interface{}, options ...ParseOption) (err error) {
Expand All @@ -189,7 +190,7 @@ func (p *Parser) Parse(filename string, r io.Reader, v interface{}, options ...P
}

// ParseString from s into grammar v which must be of the same type as the grammar passed to
// Build().
// Build(). Parameter filename is used as an opaque prefix in error messages.
//
// This may return an Error.
func (p *Parser) ParseString(filename string, s string, v interface{}, options ...ParseOption) (err error) {
Expand All @@ -206,7 +207,7 @@ func (p *Parser) ParseString(filename string, s string, v interface{}, options .
}

// ParseBytes from b into grammar v which must be of the same type as the grammar passed to
// Build().
// Build(). Parameter filename is used as an opaque prefix in error messages.
//
// This may return an Error.
func (p *Parser) ParseBytes(filename string, b []byte, v interface{}, options ...ParseOption) (err error) {
Expand Down

0 comments on commit 71ce420

Please sign in to comment.