Jul 6, 2008

Creating a Compiler - The Nightmare of a Comp Science Students

Free Web Hosting, No Ads > CONTRIBUTE > Computers > Programming Languages > C/C++ Programming

free web hosting

Creating a Compiler - The Nightmare of a Comp Science Students

hansley
I got this assignment from my college:
To create a working Compiler or Interpreter
You need to design your own Language
And build the compiler using Java or preferably C.
This is one scary nightmare...dang....I wish I can just wake me up...
but I can't this is not a nightmare. T_T
Btw, does anyone here has any experience on creating compiler or interpreter using C?
I am designing a language which is the combination of C and PHP.
And I need help.

Reply

arp
Hi;

Any more parameters for this assignment? number of statements, functions etc..

it sounds hard, but just take a deep breath...

start with the actual syntax:

identifiers, functions, operators, separators, etc...
decide what legal and illegal syntax is

then write your pattern-matching code to look for these things

now that you can identify the parts of your language, all you need to do is translate it to C and compile and voila, u r done.

start with a simple arithmetic language, i.e. make sure the operators are infix (or postfix or prefix or whatever u like). make sure the operands are valid (i.e. numeric)

now expand it by adding variables. make sure variables are declared before being used.

i think u see where I am going now...

good luck!

- arp

Reply

eldeo
Hi!
I wrote C interpreter, Pascal interpreter, Icon interpreter,
C->Pascal translator and C->ICON translator
(everything in ANSI C)


You should read something about Flex/Bison (lex/YACC)
(use google to find it)

--
eldeo

Reply

switch
wow thats brave smile.gif im in year 9, hope i don't have to do anything llike that later on in life! i think ill just stick to 3d graphics, its somewhat easier laugh.gif

Reply

cse-icons
yeah....
first of all design the syntax... and get the patterns/ regular expressions to identify the tokens( identifier/variable, constructs, expressions etc).

you can then use lex to generate a program which reads the source and generates the tokens...

call this program from your program.. now that u have the tokens... process then in your program accordingly....

I have heard of yacc but never used it... just find out more abt it and c if that would help...
all the best...
rest assured that though it is difficult, it would be very satisfying once u c the result....

Reply



Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

(Maximum characters: 10,000)
You have characters left.
Confirm Code:

Recent Queries:-
  1. how create compilers - 73.48 hr back.
  2. how to create a compiler? - 79.50 hr back.
  3. video create compiler - 138.50 hr back.
  4. creating a compiler - 17.29 hr back.
  5. creating a compiler in c - 164.10 hr back.
  6. creating compiler - 170.71 hr back.
  7. lex yacc devcpp - 215.02 hr back.
Similar Topics

Keywords : creating, compiler, nightmare, comp, science, students

  1. Compiler
    (6)
  2. Resource Compiler
    Resource Compiler (0)
    Is there a good Resource Compiler for Win32 outhere which is freeware or opensource perhaps? im
    using the Visual C++ but it puts to much extra code in the rc file.. i always end up deleting those
    extra text... is there any?....
  3. Better Free C Compiler
    (4)
    I am trying to solve some strange problems - the problems are the sort where you have 2 different
    sets of code that do the exact same thing differently - but one solution works and the other
    produces strange results (very strange since the debugger shows they both do the same thing). Some
    problems of this nature remain and I think it has something to do with the compiler. I'm using
    gcc 3.3.4 right now, am working on installing 4.0.0 but I doubt it will help seeing how the only
    changes appear to be to C++ and java, not C. Is there a free compiler out there that bet....
  4. Can A Windows Compiler Compile For Linux?
    (6)
    A friend of me, is working on a mod for a tournament where I am a co admin off... The problem is...
    My friend uses Windows. Are there any Windows programs that can ccompile .so's to use on a linux
    server / box? Thanks for any reply's....
  5. Dev C++
    FREE C++ COMPILER (26)
    ok so i have dev C++, if any of you know what that is??? you can get it for a free download at
    www.downloads.com is it possible to write in c on it?....
  6. Free C++ Visual Compiler
    (18)
    Hello guys! So far, I only can complie files with the Borland compiler that work only in MS-DOS
    mode. As you guys know, MS-DOS is ancient....some people have never even heard about
    it!!!! Yeah, that's the truth...but anywayz, do you guys have a compiler that
    can do the same as Microsoft Visual C++ Compiler that is free? I am not looking for illegal stuff or
    anything. I am looking for a fully legimate program that can do almost exactly the same as Microsoft
    Visual C++. I really want to know, and don't worry., I am not posting this for fun. I....

    1. Looking for creating, compiler, nightmare, comp, science, students

Searching Video's for creating, compiler, nightmare, comp, science, students
advertisement



Creating a Compiler - The Nightmare of a Comp Science Students



 

 

 

 

ADD REPLY / Got an Opinion! Remove these ADs! RAPID SEARCH! Free Web Hosting [X]
Express your Opinions, Thoughts or Contribute more info. to help others.
Ask your Doubts & Queries to get answers, So that "Together We can help others!"
Register FREE for AD-FREE forum, Create your own topics, Ask Questions, track topics, setup subscriptions & notifications and Get a Free Website w/ Email and FTP.
500MB Space *No Ads*, CPanel, FTP, PHP, MySQL, EMails - 100% FREE