i'm a beginner in c# and i'm planning to make a compiler made in C#. i have already made some reserve words that were influenced by Fortran95 Programming Language. any tips or sources that can help me in making the compiler?
Hello
I will give you some hints and sources. This has nothing o do with C#, but with C and C++. The idea is to create a parser that will check the grammar too. A tool to do that is the Lex or Flex (lexical analyser), and for C++ compiler use Flex++
You write your code (regular expressions and c code), you use the flex.exe to generate the c code (huge file) and then compile it with c compiler to get the executeble. (if you want you can use flex++ with a c++ compiler)
When i used the flex tool, it was real fun. My bigest project was a calculator with +-*/. No () at all, but it knew how to calculate teh result correclty. With regex you see if there is any syntax error and output to the user a descriptive message and then with the c code 'do your stuff' to calculate the result. It was not a big deal but i learned a few things.
You can do that with C# but i dont know if it will be easier.
To get better help let us know what this compiler should do. Create an .exe file, assembler?
technically i'm still making the lexer now, the one that identifies the tokens per line, makes the token pattern per line, and symbol table.
i will also make use of an access database. where it contains the reserve words and corresponding token of the Programming Language.
the process is done by retrieving the reserve words from the database and comparing them to the words of a richtextbox in my form. if the richtextbox word is similar to the reserve word it will print the corresponding token to another form.
i had my latest program uploaded in mediafire.com:
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.