mirror of
https://github.com/yhirose/cpp-peglib.git
synced 2025-01-22 21:35:29 +00:00
Improved AST printer.
This commit is contained in:
parent
561defea8b
commit
19c3644490
6
peglib.h
6
peglib.h
@ -1852,11 +1852,11 @@ struct AstPrint
|
|||||||
|
|
||||||
void print(const Ast& ast) {
|
void print(const Ast& ast) {
|
||||||
level_ += 1;
|
level_ += 1;
|
||||||
for (auto i = 0; i < level_; i++) { std::cout << " "; }
|
for (auto i = 0; i < level_; i++) { std::cout << " "; }
|
||||||
if (ast.is_token) {
|
if (ast.is_token) {
|
||||||
std::cout << ast.name << ": '" << ast.token << "'" << std::endl;
|
std::cout << "- " << ast.name << ": '" << ast.token << "'" << std::endl;
|
||||||
} else {
|
} else {
|
||||||
std::cout << ast.name << std::endl;
|
std::cout << "+ " << ast.name << std::endl;
|
||||||
}
|
}
|
||||||
for (auto node : ast.nodes) { print(*node); }
|
for (auto node : ast.nodes) { print(*node); }
|
||||||
level_ -= 1;
|
level_ -= 1;
|
||||||
|
Loading…
Reference in New Issue
Block a user