Skip to content

Commit 9f0d4b0

Browse files
authored
Update README.md
1 parent af379a6 commit 9f0d4b0

File tree

1 file changed

+18
-16
lines changed

1 file changed

+18
-16
lines changed

README.md

+18-16
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ PHP Parser written in Go
1515
[![Exago](https://api.exago.io:443/badge/cov/github.com/z7zmey/php-parser)](https://exago.io/project/github.com/z7zmey/php-parser)
1616
[![GoDoc](https://godoc.org/github.com/z7zmey/php-parser?status.svg)](https://godoc.org/github.com/z7zmey/php-parser)
1717

18+
This project uses [goyacc](https://godoc.org/golang.org/x/tools/cmd/goyacc) and [golex](https://github.com/cznic/golex) libraries to parse PHP sources into [AST](https://en.wikipedia.org/wiki/Abstract_syntax_tree). It can be used to write static analysis, refactoring, metrics, code style formatting tools.
19+
1820
#### Try it online: [demo](https://php-parser.com)
1921

2022
Features:
@@ -29,7 +31,7 @@ Features:
2931
Roadmap
3032
-------
3133

32-
- Saving comments and empty lines
34+
- Pretty printer
3335
- Control Flow Graph (CFG)
3436
- PhpDocComment parser
3537
- Stabilize api
@@ -45,7 +47,7 @@ CLI
4547
---
4648

4749
```
48-
php-parser [-php5] <path> ...
50+
php-parser [-php5 -noDump] <path> ...
4951
```
5052

5153
Dump AST to stdout.
@@ -100,8 +102,8 @@ Parsing syntax-invalid PHP files
100102

101103
If we try to parse `$a$b;` then the parser triggers error 'syntax error: unexpected T_VARIABLE'. Token `$b` is unexpected, but parser recovers parsing process and returns `$b;` statement to AST, because it is syntactically correct.
102104

103-
Pretty printer
104-
--------------
105+
Pretty printer [work in progress]
106+
---------------------------------
105107

106108
```Golang
107109
nodes := &stmt.StmtList{
@@ -123,14 +125,14 @@ nodes := &stmt.StmtList{
123125
},
124126
},
125127
Extends: &stmt.ClassExtends{
126-
ClassName: &name.Name{
127-
Parts: []node.Node{
128-
&name.NamePart{
129-
Value: "Baz"
130-
},
131-
},
132-
},
133-
},
128+
ClassName: &name.Name{
129+
Parts: []node.Node{
130+
&name.NamePart{
131+
Value: "Baz"
132+
},
133+
},
134+
},
135+
},
134136
Stmts: []node.Node{
135137
&stmt.ClassMethod{
136138
Modifiers: []node.Node{
@@ -164,9 +166,9 @@ It prints to stdout:
164166
namespace Foo;
165167
abstract class Bar extends Baz
166168
{
167-
public function greet()
168-
{
169-
echo 'Hello world';
170-
}
169+
public function greet()
170+
{
171+
echo 'Hello world';
172+
}
171173
}
172174
```

0 commit comments

Comments
 (0)