#33 comment package has renamed to meta and parser now saves whitespaces
This commit is contained in:
@@ -3,6 +3,8 @@ package php7
|
||||
import (
|
||||
"io"
|
||||
|
||||
"github.com/z7zmey/php-parser/meta"
|
||||
|
||||
"github.com/z7zmey/php-parser/errors"
|
||||
"github.com/z7zmey/php-parser/node"
|
||||
"github.com/z7zmey/php-parser/parser"
|
||||
@@ -21,7 +23,6 @@ type Parser struct {
|
||||
positionBuilder *parser.PositionBuilder
|
||||
errors []*errors.Error
|
||||
rootNode node.Node
|
||||
comments parser.Comments
|
||||
}
|
||||
|
||||
// NewParser creates and returns new Parser
|
||||
@@ -35,7 +36,6 @@ func NewParser(src io.Reader, path string) *Parser {
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,12 +50,15 @@ func (l *Parser) Error(msg string) {
|
||||
l.errors = append(l.errors, errors.NewError(msg, l.currentToken))
|
||||
}
|
||||
|
||||
func (l *Parser) WithMeta() {
|
||||
l.Lexer.WithMeta = true
|
||||
}
|
||||
|
||||
// Parse the php7 Parser entrypoint
|
||||
func (l *Parser) Parse() int {
|
||||
// init
|
||||
l.errors = nil
|
||||
l.rootNode = nil
|
||||
l.comments = parser.Comments{}
|
||||
l.positionBuilder = &parser.PositionBuilder{}
|
||||
|
||||
// parse
|
||||
@@ -78,11 +81,6 @@ func (l *Parser) GetErrors() []*errors.Error {
|
||||
return l.errors
|
||||
}
|
||||
|
||||
// GetComments returns comments list
|
||||
func (l *Parser) GetComments() parser.Comments {
|
||||
return l.comments
|
||||
}
|
||||
|
||||
// helpers
|
||||
|
||||
func lastNode(nn []node.Node) node.Node {
|
||||
@@ -100,6 +98,14 @@ func isDollar(r rune) bool {
|
||||
return r == '$'
|
||||
}
|
||||
|
||||
func addMeta(n node.Node, mm []meta.Meta, tn meta.TokenName) {
|
||||
for _, m := range mm {
|
||||
m.SetTokenName(tn)
|
||||
}
|
||||
|
||||
n.AddMeta(mm)
|
||||
}
|
||||
|
||||
func (p *Parser) returnTokenToPool(yyDollar []yySymType, yyVAL *yySymType) {
|
||||
for i := 1; i < len(yyDollar); i++ {
|
||||
if yyDollar[i].token != nil {
|
||||
|
||||
1511
php7/php7.go
1511
php7/php7.go
File diff suppressed because it is too large
Load Diff
1019
php7/php7.y
1019
php7/php7.y
File diff suppressed because it is too large
Load Diff
11150
php7/php7_test.go
11150
php7/php7_test.go
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user