Lossless Parser
#2923
Replies: 1 comment
-
How would you go about it ? |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Problem
The current parser generates an Abstract Syntax Tree (AST) and ignores trivial elements such as comments and whitespaces, which adversely affects the formatter's ability to retain the original code formatting during analysis and manipulation. To solve this problem, one could develop a lossless parser that creates a Concrete Syntax Tree (CST) instead. A CST retains all the formatting details, allowing for precise code analysis and manipulation while preserving the original formatting and comments, thereby significantly improving the formatter's functionality and the overall developer experience.
Happy Case
In an ideal scenario, the implementation of a lossless parser would seamlessly integrate with the existing development environment or toolchain. Upon feeding a piece of code into this parser, it would generate a Concrete Syntax Tree (CST) that retains all trivial elements like comments, whitespaces, and formatting nuances. Developers can then carry out code analysis, refactoring, or formatting operations without losing any of these details. The lossless parser would ensure that the original code formatting is preserved, or if desired, systematically reformatted according to specified formatting guidelines.
Alternatives Considered
No response
Additional Context
No response
Would you like to submit a PR for this Issue?
No
Support Needs
No response
Beta Was this translation helpful? Give feedback.
All reactions