Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork1
leogtzr/monkeylangj
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
This is a Java implementation of Thorsten Ball's Monkey Programming Language from his great bookWriting An Interpreter in Go.
- Tokenizer
- Lexer
- Parser
- AST
- Builtin Functions
- if/else
- Arrays & Maps
- Function Literals
- Closures
- REPL ([Read Eval Print Loop](Read Eval Print Loop))
5*5+10;3+4*5==3*1+4*5;5*10>40+5;((10+2)*30)==(300+20*3);(10+2)*30==300+20*3;500/2!=250;
puts(true==true);puts(false==true);
if(5*5+10>34){puts(99)}else{puts(100)}
leta=5;letb=a>3;letc=a*99;if(b){10}else{1};letd=if(c>a){99}else{100};d*c*a;
You can also see how function literals can be used.
lethello="Hello there, fellow Monkey users and fans!"letgiveMeHello=fn(){"Hello!"}giveMeHello();
letmyArray=["one","two","three"];len(myArray);first(myArray);rest(myArray);last(myArray);push(myArray,"four")
letmyHash={"name":"Jimmy","age":72,"band":"Led Zeppelin"};myHash["name"];myHash["age"];myHash["band"];
lettwo="two";leth={"one":10-9,two:1+1,"thr"+"ee":6/2,4:4,true:5,false:6};h["one"];
letaddTwo=fn(x){x+2;};addTwo(2);letmultiply=fn(x,y){x*y};multiply(50/2,1*2);fn(x){x==10}(5);false;fn(x){x==10}(10);true;
- Java, this project uses the JDK 16.
- Maven.
To build the .jar file, just type:
$ make
or you could just run:
$ mvn clean package
To run the REPL (Read Evaluate Print Loop):
make run
or:
java --enable-preview -jar target/monkeyj-jar-with-dependencies.jar
There are a few code examples of the language in theexamples directory. To run them, youcan use the following command:
$ java --enable-preview -jar target/monkeyj-jar-with-dependencies.jar< examples/strings/concat1.mnk
This code was brought to you byLeo Gutiérrez in his free time. If you want to thank me and support the development of this project, please make a small donation onPayPal. In case you also like my other open source contributions and articles, please consider motivating me by becoming a sponsor/patron onPatreon. Thank you! ❤️
About
This is a Java implementation of Thorsten Ball's Monkey Programming Language from his great book Writing An Interpreter in Go.
Topics
Resources
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Releases
Sponsor this project
Uh oh!
There was an error while loading.Please reload this page.