Creating a compiler for java language

Creating a compiler for java language

Page 1 of 1

3 Replies - 1083 Views - Last Post: 28 September 2010 - 07:20 AM Rate Topic: -----

#1 MorRomio  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 44
  • Joined: 28-September 10

Creating a compiler for java language

Posted 28 September 2010 - 04:02 AM

Hey guys

How are you?

I have been looking around for information/tutorials on how to create a compiler written in java, and that compiles java code, or even compiles some other code (preferably C#) if that would be easier. I've searched for similar topics on this site, and found one that began very good, but it stopped in the middle of everything (Also, the topic is from 2005).

I do some programming in java and C# (Visual studio), but I'm not an advanced programmer yet.

So basically, what I want to do is to start of by creating a simple compiler that can read keywords like "for, else, if, =, ==" and so on. Nothing fancy since I don't have any idea where to start. Once I grasp this, I can keep building on it myself.

Thanks in advance :)

Is This A Good Question/Topic? 0
  • +

Replies To: Creating a compiler for java language

#2 Luckless  Icon User is offline

  • </luck>
  • member icon

Reputation: 292
  • View blog
  • Posts: 1,146
  • Joined: 31-August 09

Re: Creating a compiler for java language

Posted 28 September 2010 - 06:39 AM

sounds like you are shooting for a development environment, not a compiler (though I could be wrong) also, java doesn't work like that. It is interpreted by
the Java Virtual Machine (JVM) for whatever specified platform you are using. It's really an interpreter, where the code is run one line at a time.

As far as recognizing keywords (to change the color of it) you could use a HashSet with the keywords, read a line from a text field, then increment through each element

//for loop...
//inside
if(myHashSet.contains(myString){
//change the color of the word to something else (like purple)
}



Was This Post Helpful? 0
  • +
  • -

#3 MorRomio  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 44
  • Joined: 28-September 10

Re: Creating a compiler for java language

Posted 28 September 2010 - 06:57 AM

Hi

Thanks for the reply.

I want to write a compiler that compiles the java programming language.
I just don't know where to start
Was This Post Helpful? 0
  • +
  • -

#4 guido-granobles  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 171
  • View blog
  • Posts: 617
  • Joined: 02-December 09

Re: Creating a compiler for java language

Posted 28 September 2010 - 07:20 AM

Take a look to the openJDK project. The code source is available.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1