Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

tokenizer made in c#

Status
Not open for further replies.

javijerome

Programmer
Jun 26, 2010
25
0
0
PH
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++

(Have a search for BNF notation)

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:


if in case you want to see.
hope you can help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top