Welcome Guest ( Log In | Register )

Outline · [ Standard ] · Linear+

C# Writing a parser

views
     
chibiheroes
post Apr 7 2021, 04:55 PM

Getting Started
**
Junior Member
61 posts

Joined: Nov 2009


No mate, you don't use binary tree, you use lexer. This lexer basically parses your source code into a list of tokens, which is fed into a parser that turns that list into a tree of nodes, aka Abstract Syntax Tree. First and foremost though, you need to KNOW why you making a new language, so you ask questions like:

1 .What execution paradigm do we want to use? Will it be imperative or functional? Or maybe based on state machines or business rules? C vs Lisp
2. Do we want static typing or dynamic typing? Java vs Python
3. What sort of programs this language will be best at? Will it be used for small scripts or large systems? Haskell vs C++
4. What matters most to us: performance? Readability? C vs Python
5. Do we want it to be similar to an existing programming language? Will it be aimed at C developers or easy to learn for who is coming from Python?
6. Do we want it to work on a specific platform (JVM, CLR)?
7. What sort of metaprogramming capabilities do we want to support, if any? Macros? Templates? Reflection?

I'm too lazy to type so just google and check it out tongue.gif tongue.gif tongue.gif
chibiheroes
post Apr 8 2021, 11:35 AM

Getting Started
**
Junior Member
61 posts

Joined: Nov 2009


My memory is hazy since I haven't done compiler programming since 1999 but I think there are better parser generator than Bison/Flex like ANTLR, just do a google for compiler-compiler.

 

Change to:
| Lo-Fi Version
0.0124sec    0.48    6 queries    GZIP Disabled
Time is now: 29th March 2024 - 06:42 PM