Re: Lexer, Parser, AST, what now?
Sun, 15 Mar 2009 19:55:18 -0700 (PDT)

          From comp.compilers

Related articles
Lexer, Parser, AST, what now? (lican) (2009-03-10)
Re: Lexer, Parser, AST, what now? (2009-03-15)
Re: Lexer, Parser, AST, what now? (lican) (2009-03-17)
Re: Lexer, Parser, AST, what now? (Aaron Gray) (2009-03-18)
| List of all articles for this month |

Newsgroups: comp.compilers
Date: Sun, 15 Mar 2009 19:55:18 -0700 (PDT)
Organization: Compilers Central
References: 09-03-047
Keywords: analysis
Posted-Date: 17 Mar 2009 06:43:25 EDT

On 10 Mar, 16:24, lican <> wrote:
> Hi!
> Recently I wrote a fast lexer and RDP by hand in C++, generated a nice
> AST... Then wrote some tree walkers that generated my IR (something
> similar to bytecode in Lua). Then I wrote a control flow graph in C#
> (will be ported to C++ soon) with DAG inside basic blocks. I have a
> general idea how to combine AST walking and CFG creation, but what to
> do after that? It looks hacky and the code is not optimized. I would
> need at least basic CSE and constant propagation.

It is probably a good idea to look at SSA (Static Single Assignment)
too :-

> I also dug through LLVM, PHP and Lua source codes. They're generally
> to big and complex to follow what's happening inside. Also found the
> Dao language (nice one), but also, code to complex. Can anyone guide
> me to next steps needed for this thing to work?

You could try these LLVM tutorials :-

> P.S. Language features: dynamic typing, classes, you can say it's a
> PHP - Lua fusion with nicer syntax (in my opinion). I also wrote a
> simple VM, with 256 registers (similar to Lua's), but can't run
> anything without the code. Please help!

Writing your own code generator is not really a good idea if not only
for sanities sake. LLVM makes your code run on lots of platforms and
efficiently too.

Good luck,


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.