refactor php7parser
This commit is contained in:
		
							parent
							
								
									b93d24f95f
								
							
						
					
					
						commit
						1a045403db
					
				
							
								
								
									
										4
									
								
								Makefile
									
									
									
									
									
								
							
							
						
						
									
										4
									
								
								Makefile
									
									
									
									
									
								
							| @ -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 $@ $< | ||||
|  | ||||
							
								
								
									
										4
									
								
								main.go
									
									
									
									
									
								
							
							
						
						
									
										4
									
								
								main.go
									
									
									
									
									
								
							| @ -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
											
										
									
								
							| @ -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 | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user