help in how to make a java compiler

java compiler

  • (2 Pages)
  • +
  • 1
  • 2

21 Replies - 22143 Views - Last Post: 05 December 2012 - 12:31 PM Rate Topic: -----

#1 grisswold  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 14
  • Joined: 28-August 05

help in how to make a java compiler

Posted 03 September 2005 - 06:04 AM

Does anyone know how to code in making a java compiler. Any simple java compiler code would do. Please I really2x nid this one.
Is This A Good Question/Topic? 1

Replies To: help in how to make a java compiler

#2 Amadeus  Icon User is offline

  • g+ + -o drink whiskey.cpp
  • member icon

Reputation: 248
  • View blog
  • Posts: 13,506
  • Joined: 12-July 02

Re: help in how to make a java compiler

Posted 03 September 2005 - 06:44 AM

Just to clarify, do you want to write a compiler using the java programming language, or do you want to write a compiler that compiles the java programming language? If the latter, what language do you want to use to write it?
Was This Post Helpful? 0
  • +
  • -

#3 grisswold  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 14
  • Joined: 28-August 05

Re: help in how to make a java compiler

Posted 03 September 2005 - 08:44 PM

I want to write a compiler that compiles the java programming language. Java programming and Visual Basic would do. But if possible I prefer Java.
Was This Post Helpful? 0
  • +
  • -

#4 snoj  Icon User is offline

  • Married Life
  • member icon

Reputation: 84
  • View blog
  • Posts: 3,564
  • Joined: 31-March 03

Re: help in how to make a java compiler

Posted 03 September 2005 - 08:56 PM

A Java compiler that compiles Java..interesting.


It'd be like if I wrote a php script that executed php code! Brilliant!
Was This Post Helpful? 1
  • +
  • -

#5 grisswold  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 14
  • Joined: 28-August 05

Re: help in how to make a java compiler

Posted 03 September 2005 - 10:08 PM

Yeah think thats about it. I really dont have any idea in making one. The first thing that came to my mind about it was to make it in assembly language. So I studied assembly in a month but get the concept in making the compiler. Right now Im desperate in finding help in making one.
Was This Post Helpful? 0
  • +
  • -

#6 Amadeus  Icon User is offline

  • g+ + -o drink whiskey.cpp
  • member icon

Reputation: 248
  • View blog
  • Posts: 13,506
  • Joined: 12-July 02

Re: help in how to make a java compiler

Posted 04 September 2005 - 10:32 AM

Well, I've written compilers before, so I'll ask a few of the questions that must be decided before you begin...

1. Does the compiler have to compile the full set of java language, libraries, objects, and controls? Or are you only going to be dealing with a few simple commands/structures?

2. Will you require all facets of a standalone compiler (parser - token list, linker, etc...), or are you simply interested in parsing the language? Do you need to end up with an executable?

3. Is this going to be a single pass or multi pass compiler?

4. You've identified the source language (Java). What is your target language? A better way to ask this is what do you want to compile your code into?

There are many other important issues to be identified, but those above are key to beginning.
Was This Post Helpful? 1
  • +
  • -

#7 Amadeus  Icon User is offline

  • g+ + -o drink whiskey.cpp
  • member icon

Reputation: 248
  • View blog
  • Posts: 13,506
  • Joined: 12-July 02

Re: help in how to make a java compiler

Posted 04 September 2005 - 10:34 AM

hotsnoj, on Sep 3 2005, 10:56 PM, said:

A Java compiler that compiles Java..interesting.


It'd be like if I wrote a php script that executed php code! Brilliant!

Actually, it would be more akin to you writing a php script that read php files, parsed the character strings, interpreted the command controls, etc....

Execution is only the final step.
Was This Post Helpful? 0
  • +
  • -

#8 grisswold  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 14
  • Joined: 28-August 05

Re: help in how to make a java compiler

Posted 04 September 2005 - 08:39 PM

What I had in mind was creating a program similar to Java Creator or Ultra Edit. A java editor that is able to create a java program and compiles the file and views the output if there be any errors or so then runs the program created in the editor. The compiled file may not be in executable but if you could add it then it would be a plus for my learning. For the mean time I would like it if the compiler would just deal with simple commands so I could understand the program and that I would have the idea in how to create one. I wanna learn how to make it first before I want the compiler to do complicated process.

I think it would be a standalone compiler. I really dont know what to answer in the third question. But based on what I have read I think it would be in a single pass since a compiler for a language generally has several different stages as it processes the input and most of these stages occur during a single pass or reading the source file.

Among the java edtiors that I have used usually compils the code into .class files. So I want it to compile similarly just as other java compilers would do.


Upon creation of the program could you make it less complicated. Even though that creating this program requires in depth complication, I really would like it made to be understandable by average level programmers. :)

This post has been edited by grisswold: 04 September 2005 - 08:40 PM

Was This Post Helpful? 0
  • +
  • -

#9 Amadeus  Icon User is offline

  • g+ + -o drink whiskey.cpp
  • member icon

Reputation: 248
  • View blog
  • Posts: 13,506
  • Joined: 12-July 02

Re: help in how to make a java compiler

Posted 05 September 2005 - 05:59 PM

Well, first things first...you will have to define the language parameters you will be targeting, so that you can build a token list for parsing purposes. This will allow the parser to recognize keywords and patterns upon which to base its next set of actions. For example, you may want to be able to recognize the following:
  • Simple variable declaration
  • Simple control statements (while, if, for)
  • simple assignment an comparative operators (=,==)
  • Simple actionable operators (+-*/)
Sound about right to start?

The best way to begin is to decide which keywords you want your parser to recognize...I'd suggest keeping it small to begin with, you can always increase the token list at a later date.

It's not a problem for 'average' programmers to build a compiler (it's a common college assignment), but you will need to recognize that it is a complex process, and requires a level of granularity not needed in many other types of applications.
Was This Post Helpful? 0
  • +
  • -

#10 grisswold  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 14
  • Joined: 28-August 05

Re: help in how to make a java compiler

Posted 08 September 2005 - 06:37 PM

Yo guys I'm back. Was on a recollection.

About the program, can u create a simple code for me. Please. I just need the most basic in compiling. The reason I cant create one is I dont know what methods or codes to create one. Thats why I need a starter program. So some how I can learn to make one on my own.
Was This Post Helpful? 0
  • +
  • -

#11 Amadeus  Icon User is offline

  • g+ + -o drink whiskey.cpp
  • member icon

Reputation: 248
  • View blog
  • Posts: 13,506
  • Joined: 12-July 02

Re: help in how to make a java compiler

Posted 08 September 2005 - 07:13 PM

Yes we can help you, but certain things have to be defined before beginning...see my post above your last one. Without at least minimal definition of the end goal, one could not even begin.
Was This Post Helpful? 0
  • +
  • -

#12 grisswold  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 14
  • Joined: 28-August 05

Re: help in how to make a java compiler

Posted 12 September 2005 - 12:36 AM

The program would be the most basic so guess it would deal with the (primitive data structures), its control statements(do, while, if, for, else, and else if), comparative operators(||, ==, !=, &&), assignment(=), and its operators (*,+,-,/), commandline still ends with a ";". I think I may be missing something. But I dont know what.
Was This Post Helpful? 0
  • +
  • -

#13 myway6789  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 14
  • Joined: 06-December 06

Re: help in how to make a java compiler

Posted 08 December 2006 - 10:51 PM

Hello Amadeus!
I'm going to make a java compiler too. Can you help me please! I'm finding a small java program that can compile a java source file into .class file. Have you got the same program like that and may you send me your program?
My email is : ***************

Thank you very much!
Was This Post Helpful? 0
  • +
  • -

#14 salindor  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 46
  • View blog
  • Posts: 301
  • Joined: 10-November 06

Re: help in how to make a java compiler

Posted 09 December 2006 - 09:28 AM

View Postgrisswold, on 4 Sep, 2005 - 08:39 PM, said:

What I had in mind was creating a program similar to Java Creator or Ultra Edit. A java editor that is able to create a java program and compiles the file and views the output if there be any errors or so then runs the program created in the editor. The compiled file may not be in executable but if you could add it then it would be a plus for my learning. For the mean time I would like it if the compiler would just deal with simple commands so I could understand the program and that I would have the idea in how to create one. I wanna learn how to make it first before I want the compiler to do complicated process.


you know there might be a simplier method to doing this. Rather than trying to compile the program yourself, use an extrenal compiler and capture the output. From the output you can find where all the errors are located.

For some reason I am thinking java reflection could help, but I didn't fully see anything that would allow you step through code. So, you would need to write well I guess it would be a compiler abiet a very simple one (based on the definition from above).

Write you own java class, with a single static method to call back into editor. Now scan the java file for every semicolon not in a for loop (at least for the first version); then every time you find a semicolon, go to the previous semicolon, and add the function call (this will break the program if the editor tells it is ok). There will probably be need todo some other magic to make sure the user is oblivious to all the extra function calls.

Then you can use reflection to figure out where the heck you are.
Was This Post Helpful? 0
  • +
  • -

#15 myway6789  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 14
  • Joined: 06-December 06

Re: help in how to make a java compiler

Posted 10 December 2006 - 11:55 PM

View Postsalindor, on 9 Dec, 2006 - 09:28 AM, said:

you know there might be a simplier method to doing this. Rather than trying to compile the program yourself, use an extrenal compiler and capture the output. From the output you can find where all the errors are located.


How to capture the output?
any suggestion will be great!
Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2