issue #8: update Parser constructor
This commit is contained in:
parent
71f940fcf2
commit
0cf164c11c
@ -1,12 +1,8 @@
|
|||||||
package php5
|
package php5
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bufio"
|
|
||||||
goToken "go/token"
|
|
||||||
"io"
|
"io"
|
||||||
|
|
||||||
"github.com/cznic/golex/lex"
|
|
||||||
|
|
||||||
"github.com/z7zmey/php-parser/comment"
|
"github.com/z7zmey/php-parser/comment"
|
||||||
"github.com/z7zmey/php-parser/errors"
|
"github.com/z7zmey/php-parser/errors"
|
||||||
"github.com/z7zmey/php-parser/node"
|
"github.com/z7zmey/php-parser/node"
|
||||||
@ -21,7 +17,7 @@ func (lval *yySymType) Token(t token.Token) {
|
|||||||
|
|
||||||
// Parser structure
|
// Parser structure
|
||||||
type Parser struct {
|
type Parser struct {
|
||||||
scanner.Lexer
|
*scanner.Lexer
|
||||||
lastToken *token.Token
|
lastToken *token.Token
|
||||||
positionBuilder *position.Builder
|
positionBuilder *position.Builder
|
||||||
errors []*errors.Error
|
errors []*errors.Error
|
||||||
@ -32,21 +28,10 @@ type Parser struct {
|
|||||||
|
|
||||||
// NewParser creates and returns new Parser
|
// NewParser creates and returns new Parser
|
||||||
func NewParser(src io.Reader, fName string) *Parser {
|
func NewParser(src io.Reader, fName string) *Parser {
|
||||||
file := goToken.NewFileSet().AddFile(fName, -1, 1<<31-1)
|
lexer := scanner.NewLexer(src, fName)
|
||||||
lx, err := lex.New(file, bufio.NewReader(src), lex.RuneClass(scanner.Rune2Class))
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
scanner := scanner.Lexer{
|
|
||||||
Lexer: lx,
|
|
||||||
StateStack: []int{0},
|
|
||||||
PhpDocComment: "",
|
|
||||||
Comments: nil,
|
|
||||||
}
|
|
||||||
|
|
||||||
return &Parser{
|
return &Parser{
|
||||||
scanner,
|
lexer,
|
||||||
nil,
|
nil,
|
||||||
nil,
|
nil,
|
||||||
nil,
|
nil,
|
||||||
|
@ -1,12 +1,8 @@
|
|||||||
package php7
|
package php7
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bufio"
|
|
||||||
goToken "go/token"
|
|
||||||
"io"
|
"io"
|
||||||
|
|
||||||
"github.com/cznic/golex/lex"
|
|
||||||
|
|
||||||
"github.com/z7zmey/php-parser/comment"
|
"github.com/z7zmey/php-parser/comment"
|
||||||
"github.com/z7zmey/php-parser/errors"
|
"github.com/z7zmey/php-parser/errors"
|
||||||
"github.com/z7zmey/php-parser/node"
|
"github.com/z7zmey/php-parser/node"
|
||||||
@ -21,7 +17,7 @@ func (lval *yySymType) Token(t token.Token) {
|
|||||||
|
|
||||||
// Parser structure
|
// Parser structure
|
||||||
type Parser struct {
|
type Parser struct {
|
||||||
scanner.Lexer
|
*scanner.Lexer
|
||||||
lastToken *token.Token
|
lastToken *token.Token
|
||||||
positionBuilder *position.Builder
|
positionBuilder *position.Builder
|
||||||
errors []*errors.Error
|
errors []*errors.Error
|
||||||
@ -32,21 +28,10 @@ type Parser struct {
|
|||||||
|
|
||||||
// NewParser creates and returns new Parser
|
// NewParser creates and returns new Parser
|
||||||
func NewParser(src io.Reader, fName string) *Parser {
|
func NewParser(src io.Reader, fName string) *Parser {
|
||||||
file := goToken.NewFileSet().AddFile(fName, -1, 1<<31-1)
|
lexer := scanner.NewLexer(src, fName)
|
||||||
lx, err := lex.New(file, bufio.NewReader(src), lex.RuneClass(scanner.Rune2Class))
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
scanner := scanner.Lexer{
|
|
||||||
Lexer: lx,
|
|
||||||
StateStack: []int{0},
|
|
||||||
PhpDocComment: "",
|
|
||||||
Comments: nil,
|
|
||||||
}
|
|
||||||
|
|
||||||
return &Parser{
|
return &Parser{
|
||||||
scanner,
|
lexer,
|
||||||
nil,
|
nil,
|
||||||
nil,
|
nil,
|
||||||
nil,
|
nil,
|
||||||
|
Loading…
Reference in New Issue
Block a user