mirror of
https://github.com/go-sylixos/elvish.git
synced 2024-12-14 02:57:52 +08:00
parse: Unexport (*Parser).{Done,Errors}.
This commit is contained in:
parent
8bc3af27b7
commit
c88da9745e
|
@ -22,8 +22,8 @@ import (
|
|||
func Parse(srcname, src string) (*Chunk, error) {
|
||||
ps := NewParser(srcname, src)
|
||||
n := ParseChunk(ps)
|
||||
ps.Done()
|
||||
return n, ps.Errors()
|
||||
ps.done()
|
||||
return n, ps.assembleError()
|
||||
}
|
||||
|
||||
// Errors.
|
||||
|
|
|
@ -27,17 +27,16 @@ func NewParser(srcname, src string) *Parser {
|
|||
return &Parser{srcname, src, 0, 0, []map[rune]int{{}}, Error{}}
|
||||
}
|
||||
|
||||
// Done tells the parser that parsing has completed.
|
||||
func (ps *Parser) Done() {
|
||||
// Tells the parser that parsing is done.
|
||||
func (ps *Parser) done() {
|
||||
if ps.pos != len(ps.src) {
|
||||
r, _ := utf8.DecodeRuneInString(ps.src[ps.pos:])
|
||||
ps.error(fmt.Errorf("unexpected rune %q", r))
|
||||
}
|
||||
}
|
||||
|
||||
// Errors gets the parsing errors after calling one of the parse* functions. If
|
||||
// the return value is not nil, it is always of type Error.
|
||||
func (ps *Parser) Errors() error {
|
||||
// Assembles all parsing errors as one, or returns nil if there were no errors.
|
||||
func (ps *Parser) assembleError() error {
|
||||
if len(ps.errors.Entries) > 0 {
|
||||
return &ps.errors
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user