|
|
|
|
|
by blenderob
309 days ago
|
|
> FYI: Parsing and compiling in the programming language sense are orthogonal problems. How so? In Ada, Fortran, C, C++, Java, Python, etc. parsing is one of the many phases of compiling. Far from being orthogonal problems, parsing is a sub-problem of compiling. |
|
When we parse a string, we go up from low-level human-readable strings to intermediate parse trees to a high-level AST.
A process of compilation goes down from some kind of a high-level internal representation through phases to something that is close to the target low-level language.
It can go down from an AST, or LLVM-s internal representation, or whatever.
Problems solved by both processes are different:
1. Parsing is about finding string patterns (using regexps or PEGs or whatever) and representing these using a more strict high-level structure. The structure is usually tree-like but is also often a graph.
2. Compiling takes something high-level (a tree, a graph, etc) and emits something different, usually simplified.
A good example is a typical lisp implementation where the parser is trivial but compilation phases represent numerous simplifying phases.