473,386 Members | 1,823 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Designing a language interpreter & compiler for a simple language

Hey guys.
I'm currently taking a course where everyone in the class will code a compiler for a simple C-like language. I'm doing mine in C# and have some general questions for efficiency and the actual architecture.
I've coded a lexer which reads code and categorizes everything into groups.
I'm using a hash table to store all of the lexems, where the key to the table is the order of appearance of a lexem in the code and the value is the type of the lexem which is simply a struct of different predefined tokens (string, integer, sub operator and etc)
In the lexer i'm using a switch while reading the file and determining what i read. Would it be possible to achieve the same with regular expressions?

Also, i'm not quiet sure about this, but this is what i plan on doing with the parser. Since my lexer returns a hash table collection of the entire coded. I can then do all of my error checking here. I will get the value of the first key of the table and then get the second one and performs syntax checks?

I've also read a bit about parse-tree but don't seem to understand what they'd be used for in my case. Is the parse tree going to be used during the actual compilation of a code? I'm not really going to be compiling it, but rather converting it to a compilable C++ code.

If you guys think of something that might improve the architecture of the whole process, please let me know!
Thanks in advance.
Aug 26 '07 #1
2 1946
pbmods
5,821 Expert 4TB
Heya, gasfusion.

I'm going to go ahead and move this thread to the .NET forum, where our resident Experts will be better able to help you out.
Aug 26 '07 #2
JosAH
11,448 Expert 8TB
There's a little article series on compilers in the Java Articles section; maybe you
can read it for some ideas of your own.

kind regards,

Jos
Aug 29 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

34
by: nobody | last post by:
This article is posted at the request of C.W. Yang who asked me to detail my opinion of Lisp, and for the benefit of people like him, who may find themselves intrigued by this language. The...
72
by: Mel | last post by:
Are we going backwards ? (please excuse my spelling...) In my opinion an absolute YES ! Take a look at what we are doing ! we create TAGS, things like <H1> etc. and although there are tools...
2
by: Matt | last post by:
For example, we want to produce a new language called NewLang. When we implement the compiler of NewLang, we should use languages other than NewLang. Correct? But I heard Java is implemented in...
3
by: eyalkz | last post by:
Hi Everybody, I need to write a simple interpreter (in C) for a very Simple language... the language (was invented for the project) has only variable or numbers (there are also built-in...
134
by: evolnet.regular | last post by:
I've been utilising C for lots of small and a few medium-sized personal projects over the course of the past decade, and I've realised lately just how little progress it's made since then. I've...
669
by: Xah Lee | last post by:
in March, i posted a essay “What is Expressiveness in a Computer Language”, archived at: http://xahlee.org/perl-python/what_is_expresiveness.html I was informed then that there is a academic...
1
by: Petr Prikryl | last post by:
Do you think that the following could became PEP (pre PEP). Please, read it, comment it, reformulate it,... Abstract Introduction of the mechanism for language extensions via modules...
8
by: pransri2006 | last post by:
Hi guys! I think all of u know about the designing of compilers. Can any body tell me about the designing of the compilers. And also tell me the difference between the compilers and Interpreter...
4
by: Thomas | last post by:
Hello, I am a CS student and I want to write simple lisp interpreter. The code should be entierly in C. I don't want to use any compiler generators like Bison or Yak, since wrinting this in...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.