473,789 Members | 2,388 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Designing a language interpreter & compiler for a simple language

59 New Member
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 1970
pbmods
5,821 Recognized Expert Expert
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 Recognized Expert MVP
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
2690
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 opinions expressed herein are my personal ones, coming from several years of experience with Lisp. I did plenty of AI programming back in the day, which is what would now be called "search" instead.
72
5446
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 (dreamweaver and the like), they are all at the lowest level of programming (something like assembly as oposed to C++ etc.). These tools create "brain-dead" developers that constantly have to plough through tons of tags to do the simplest thing. ...
2
1513
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 C/C++. More specifically, does it mean the Java compiler is written in C/C++? But the Java API is written in Java itself. This is the confusing part.
3
9735
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 variables) routines and expressions (routines can have recursion ) where can I find help and source code on that project...?
134
8046
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 increasingly been using scripting languages (especially Python and Bourne shell) which offer the same speed and yet are far more simple and safe to use. I can no longer understand why anyone would willingly use C to program anything but the lowest...
669
26234
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 paper written on this subject. On the Expressive Power of Programming Languages, by Matthias Felleisen, 1990. http://www.ccs.neu.edu/home/cobbe/pl-seminar-jr/notes/2003-sep-26/expressive-slides.pdf
1
2087
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 written using other languages. Extensions of Python could be done via special interpreter extensions. From Python sources, the special modules would look like other modules, with the Python API (the key feature from
8
2193
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 which weresically used by the computers. I want to know about the basic compiler software.
4
2110
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 raw C will give me more experience. I wrote a simple lexer ( changes leksems into the streams of tokens). The Lisp dialect I have to implement is not defined in any formal way, but I have a description of how it should behave (say its a >>writen...
0
9506
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10193
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10136
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9979
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7525
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupr who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6761
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5415
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5548
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2906
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.