Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
z7zmey committed Apr 6, 2018
1 parent 335bedc commit 624dc4f
Showing 1 changed file with 48 additions and 1 deletion.
49 changes: 48 additions & 1 deletion README.md
Expand Up @@ -64,6 +64,53 @@ It does not change AST but collects resolved names into `map[node.Node]string`
- For `Class`, `Interface`, `Trait`, `Function`, `ConstList` nodes collects name with current namespace.
- For `Name`, `Relative`, `FullyQualified` nodes resolves `use` aliases and collects a fully qualified name.

## Pretty printer

```Golang
nodes := &stmt.StmtList{
Stmts: []node.Node{
&stmt.Namespace{
NamespaceName: &name.Name{Parts: []node.Node{&name.NamePart{Value: "Foo"}}},
},
&stmt.Class{
Modifiers: []node.Node{&node.Identifier{Value: "abstract"}},
ClassName: &name.Name{Parts: []node.Node{&name.NamePart{Value: "Bar"}}},
Extends: &name.Name{Parts: []node.Node{&name.NamePart{Value: "Baz"}}},
Stmts: []node.Node{
&stmt.ClassMethod{
Modifiers: []node.Node{&node.Identifier{Value: "public"}},
MethodName: &node.Identifier{Value: "greet"},
Stmts: []node.Node{
&stmt.Echo{
Exprs: []node.Node{
&scalar.String{Value: "'Hello world'"},
},
},
},
},
},
},
},
}

file := os.Stdout
p := printer.NewPrinter(file, " ")
p.PrintFile(nodes)
```

Output:
```PHP
<?php
namespace Foo;
abstract class Bar extends Baz
{
public function greet()
{
echo 'Hello world';
}
}
```

## Roadmap
- [X] Lexer
- [x] PHP 7 syntax analyzer
Expand All @@ -75,9 +122,9 @@ It does not change AST but collects resolved names into `map[node.Node]string`
- [x] PHP 5 syntax analyzer
- [x] Tests
- [x] Namespace resolver
- [x] Pretty printer
- [ ] PhpDocComment parser
- [ ] Error handling
- [ ] Stabilize api
- [ ] Documentation
- [ ] Pretty printer
- [ ] Code flow graph

0 comments on commit 624dc4f

Please sign in to comment.