microsoft / microsoft/tolerant-php-parser
Add a utility and/or library to dump a compact representation of a node?
Nobody has claimed this yet.
- Dominant language
- PHP
- Stars
- 894
- Forks
- 85
- Avg merge
- 2d 13h
- Merged PRs (30d)
- 3
Description
E.g. to tools or bin
This will help people who are developing libraries using this parser, as well as trying to debug the behavior on a given file/snippet.
I didn't see any similar issues mentioned elsewhere in the issues, readme, or tools directory.
Currently, I'm using this snippet: https://gist.github.com/TysonAndre/3c0619efc9695ef9f2465f4a55e6e6ee
Previously, I was using var_export(), which was several times longer.
» php dump.php "const X = 2*3+1;"
Node\SourceFileNode
statementList: Node\Statement\ConstDeclaration
constKeyword: Token: ConstKeyword(111): "const"
constElements: Node\DelimitedList\ConstElementList
children: Node\ConstElement
name: Token: Name(2): " X"
equalsToken: Token: EqualsToken(238): " ="
assignment: Node\Expression\BinaryExpression
leftOperand: Node\Expression\BinaryExpression
leftOperand: Node\NumericLiteral
children: Token: IntegerLiteralToken(416): " 2"
operator: Token: AsteriskToken(212): "*"
rightOperand: Node\NumericLiteral
children: Token: IntegerLiteralToken(416): "3"
operator: Token: PlusToken(213): "+"
rightOperand: Node\NumericLiteral
children: Token: IntegerLiteralToken(416): "1"
semicolon: Token: SemicolonToken(237): ";"
endOfFileToken: Token: EndOfFileToken(1): ""
EDIT: I've moved that snippet to https://github.com/phan/phan/blob/master/internal/dump_fallback_ast.php
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with internal/dump_fallback_ast.php and compare it with the issue's sample output. Check the tools and bin directories for an appropriate entry point. Done means providing a compact node representation for a PHP file or snippet, suitable for parser-library development and debugging.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- devtools
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100