Skip to content
This repository has been archived by the owner on Oct 16, 2022. It is now read-only.

Commit

Permalink
fixing line numbers and filenames in error messages. issue #24
Browse files Browse the repository at this point in the history
  • Loading branch information
stephens2424 committed Nov 25, 2015
1 parent 935c78a commit 055c8ff
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions parser/parser.go
Expand Up @@ -3,6 +3,7 @@ package parser
import (
"bytes"
"fmt"
"path"

"github.com/stephens2424/php/ast"
"github.com/stephens2424/php/lexer"
Expand Down Expand Up @@ -84,7 +85,7 @@ func (p ParseError) String() string {

// Parse consumes the input string to produce an AST that represents it.
func (p *Parser) Parse(filepath, input string) (file *ast.File, err error) {
file = &ast.File{Namespace: p.FileSet.GlobalNamespace}
file = &ast.File{Namespace: p.FileSet.GlobalNamespace, Name: path.Base(filepath)}
p.file = file
p.scope = p.FileSet.Scope
p.namespace = p.FileSet.GlobalNamespace
Expand Down Expand Up @@ -222,7 +223,7 @@ func errorf(p *Parser, str string, args ...interface{}) ParseError {
e := ParseError{error: fmt.Errorf(str, args...)}
if p != nil {
e.File = p.file
e.Line = 0
e.Line = p.current.Begin.Line
}
return e
}
Expand Down

0 comments on commit 055c8ff

Please sign in to comment.