Why don't we store the syntax tree instead of the source code?
Posted
by
Calmarius
on Programmers
See other posts from Programmers
or by Calmarius
Published on 2011-11-10T22:04:43Z
Indexed on
2011/11/11
18:25 UTC
Read the original article
Hit count: 173
language-agnostic
We have a lot of programming languages. Every language is parsed and syntax checked before translated into code so an abstract syntax tree is built.
We have this abstract syntax tree, why don't we store this syntax tree instead of the source code (or next to the source code)?
By using an AST instead of the source code. Every programmer in a team can serialize this tree to any language, they want (with the appropriate context free grammar) and parse back to AST when they finished. So this would eliminate the debate about the coding style questions (where to put the { and }, where to put whitespace, indentation, etc.)
What are the pros and cons of this approach?
© Programmers or respective owner