refactor php7parser

This commit is contained in:
z7zmey 2018-01-25 17:42:15 +02:00
parent b93d24f95f
commit 1a045403db
4 changed files with 495 additions and 495 deletions

View File

@ -1,6 +1,6 @@
PHPFILE=example.php
all: ./parser/php7.go ./scanner/scanner.go
all: ./php7parser/parser.go ./scanner/scanner.go
rm -f y.output
gofmt -l -s -w *.go
go build
@ -14,5 +14,5 @@ test: all
./scanner/scanner.go: ./scanner/scanner.l
golex -o $@ $<
./parser/php7.go: ./parser/php7.y
./php7parser/parser.go: ./php7parser/parser.y
goyacc -o $@ $<

View File

@ -8,7 +8,7 @@ import (
"path/filepath"
"github.com/yookoala/realpath"
"github.com/z7zmey/php-parser/parser"
php7parser "github.com/z7zmey/php-parser/php7parser"
)
func main() {
@ -23,7 +23,7 @@ func main() {
fmt.Printf("==> %s\n", path)
src, _ := os.Open(string(path))
nodes, comments, positions := parser.ParsePhp7(src, path)
nodes, comments, positions := php7parser.Parse(src, path)
visitor := Dumper{
Indent: " | ",

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +1,5 @@
%{
package parser
package php7parser
import (
"io"
@ -50,7 +50,7 @@ func newLexer(src io.Reader, fName string) *lexer {
return &lexer{scanner.Lexer{lx, []int{0}, "", nil}}
}
func ParsePhp7(src io.Reader, fName string) (node.Node, comment.Comments, position.Positions) {
func Parse(src io.Reader, fName string) (node.Node, comment.Comments, position.Positions) {
yyDebug = 0
yyErrorVerbose = true
rootnode = stmt.NewStmtList([]node.Node{}) //reset