What is TinyPG and how does it work? I know its a "compiler-compiler" but how do I get started and create my own compiler in C#?
+1
A:
I've understood approximately how you use it, and here's a brief.
TinyPG is a complete compiler-compiler IDE, with a Windows GUI for RegExp, EBNF and C#/VB. The following outlines the procedure of developing your own "compiler" within TinyPG:
You define Terminals using Regular Expressions.
- You write these ReyExps within TinyPG, which basically extracts tokens from the input source code.
- RegExps are natively supported in .NET which means that even your generated "compiler" code uses .NET's RegExps.
You define Non-terminals and parser rules in Extended BNF meta-syntax.
- You write EBNF within TinyPG, to describe the language of your choice.
- Some free BNF Grammers that describe modern programming languages.
You define the compiler in Managed code.
- You write C#/VB code within TinyPG, to convert the tokens into an output of your choice.
- One C#/VB code block per BNF grammer rule only.
- TinyPG can compile and run your "tokenizer + parser + complier" using the commandline compiler.
TinyPG generates C# code for your new "compiler".
- Generates a parse-tree from inputted source code, using your RegEx along with your EBNF.
- Translates this parse-tree into an output, using your C#/VB code.
You develop the front-end of your compiler in C# or VB.NET.
- A basic front end would invoke the generated C# classes with an input file, and display the output.
To begin, you can open the "simple expression2.tpg" file within the provided Samples of TinyPG to see a demo of a calculator "compiler".
Jenko
2009-09-07 09:33:47