This site requires JavaScript, please enable it in your browser!
Greenfoot back

Report as inappropriate.

bourne
bourne presents ...

2014/4/28

Interpreter

Write some code and run it.

Implemented so far:
* All ops expected in Java with precedence, except for: unary +, and ternary
* Types: int, char, double, boolean, String, array
* Cast to int and char
* while, do-while, normal for loops, and switches
* if, else if, else
* return
* break and continue (with tags)
* Syntax checking messages (a little weak)
* Global variables, methods

Nest if's and loops with/out '{}' as much as you like.

Strings currently have default value of "" instead of null.

Built-in methods:
* void print(String) // Prints the given String to the display console.
* double rand() // Returns a random double in range [0,1).

The program looks for a method called main with no params, to run.
Use the terminate button if your code execution is taking a long time or is in an infinite loop.

You can use ctrl+t to insert 4 spaces like a tab.

Lots to do...

For reusable GUI Components, visit:
http://www.greenfoot.org/scenarios/7578

5127 views / 23 in the last 7 days

8 votes | 0 in the last 7 days

Tags: with-source code gui program bourne

open in greenfoot

There is no HTML 5 translation of this scenario available.
View legacy version (requires Java plugin)

This scenarios uses Java features that are not available for use after conversion to HTML 5. Please try the legacy version, which requires the Java plugin to be installed.

A new version of this scenario was uploaded on Thu May 08 23:44:41 UTC 2014 Added String methods: * int length() * boolean isEmpty() * char charAt(int) * String substring(int) * String substring(int, int) * boolean equals(String)
A new version of this scenario was uploaded on Fri May 09 01:10:46 UTC 2014 Added a majority of String methods. Below is the complete list of supported String methods. Will be working next on compiling together a language spec that will be accessible from the scenario. char charAt(int) int compareTo(String) int compareToIgnoreCase(String) boolean contains(String) boolean endsWith(String) boolean equals(String) boolean equalsIgnoreCase(String) int indexOf(char) int indexOf(char, int) int indexOf(String) int indexOf(String, int) boolean isEmpty() int lastIndexOf(char) int lastIndexOf(char, int) int lastIndexOf(String) int lastIndexOf(String, int) int length() String replace(char, char) String replace(String, String) boolean startsWith(String) boolean startsWith(String, int) String substring(int) String substring(int, int) char[] toCharArray() String toLowerCase() String toUpperCase() String trim()
Game/maniacGame/maniac

2014/5/9

Next you should create your own programming language ;)
KartoffelbrotKartoffelbrot

2014/5/10

epic...
A new version of this scenario was uploaded on Mon Jun 09 05:44:12 UTC 2014 Added syntax coloring and switches. Switches work with ints and chars, but only literals since no constants support yet. Breaks with/out labels also work in switches. And of course case and default. Keywords as variable names no longer allowed, and other bug fixes. Syntax coloring made possible by new general coloring feature added to TextBox. With extension on TextBox's included ColorCoder class.
A new version of this scenario was uploaded on Mon Jun 09 05:57:45 UTC 2014 Added syntax coloring and switches. Switches work with ints and chars, but only literals since no constants support yet. Breaks with/out labels also work in switches. And of course case and default. Keywords as variable names no longer allowed, and other bug fixes. Syntax coloring made possible by new general coloring feature added to TextBox. With extension on TextBox's included ColorCoder class. Couple more bug fixes
lordhersheylordhershey

2014/6/9

That is really nice.
A new version of this scenario was uploaded on Mon Jun 09 17:12:38 UTC 2014 Bug fixes and made printout consoles to autoscroll down
A new version of this scenario was uploaded on Mon Jun 09 18:15:14 UTC 2014 Few more fixes and clean up of some code
UpupzealotUpupzealot

2014/6/14

I have to say: this is what geek does, and I am only a programmer.

See all comments

Want to leave a comment? You must first log in.

Who likes this?

Nosson1459 Upupzealot Kartoffelbrot Kytuzian Game/maniac darkmist255 lordhershey JetLennit