-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into maven-build
- Loading branch information
Showing
18 changed files
with
454 additions
and
14 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,56 @@ | ||
# Loco - Lolcode Interpreter | ||
# **Loco** | ||
|
||
Loco is an interpreter for the [Lolcode][1] programming language. Syntax for the programming language can be found [here][2]. | ||
|
||
 | ||
 | ||
|
||
This project features a lexical analyzer (lexer), syntax analyzer (parser), and semantic analyzer coded in the Java programming language. The GUI wss made by utilizing [JavaFX][3] and [SceneBuilder][4]. | ||
Loco features a lexical analyzer, syntax analyzer, and semantic analyzer coded in the Java programming language. The GUI was made by utilizing [JavaFX][3] and [SceneBuilder][4]. | ||
|
||
Loco aims to able to correctly execute `.lol` files. Most of Lolcode syntax has already been implemented. | ||
Loco aims to able to correctly parse and execute `.lol` files according to specifications. Some sample Lolcode files are included [in the repo](Samples/). | ||
|
||
 | ||
## Usage | ||
### Run Hotkeys | ||
* F6: Run program | ||
* F7: Start Debugger | ||
* F8: Run Next Line (only allowed if Debugger is active) | ||
|
||
I also decided to include some fun little features in the GUI. Such as: | ||
## Features | ||
* Syntax Highlighting in the code editor | ||
* Lexeme list which identifies the TokenType of each lexeme | ||
* Symbol Table which displays the current values of variables | ||
* Adjustable code editor font size | ||
* Viewable parse tree | ||
* Line by line debugger | ||
|
||
Adjustable Panels | ||
 | ||
## Building | ||
Prerequisites are [Java][5] and [Maven][6]. | ||
1. Get the source by cloning the repo: | ||
|
||
`git clone https://github.com/jpcarreon/loco.git` | ||
2. `cd` into the root folder and switch to the `maven-build` branch with: | ||
|
||
Viewable Parse Tree | ||
 | ||
`git checkout maven-build` | ||
3. `cd` into the project folder `Loco`. Make sure you are in the folder with the `pom.xml` file. | ||
4. Use Maven to build and run using the following command: | ||
|
||
Line by Line Debugger | ||
 | ||
`mvn clean javafx:run` | ||
5. (Optional) A `.jar` file can be generated by the use of the following command: | ||
|
||
`mvn clean package` | ||
|
||
The `.jar` file will be located inside the `target` folder | ||
|
||
## Credits | ||
* [RichTextFx][7] for the code editor | ||
* [Flowless][8] for scrollbars in the code editor | ||
|
||
... and more minor features. | ||
|
||
|
||
[1]: http://www.lolcode.org/ | ||
[2]: https://github.com/justinmeza/lolcode-spec/blob/master/v1.2/lolcode-spec-v1.2.md | ||
[3]: https://openjfx.io/ | ||
[4]: https://gluonhq.com/products/scene-builder/ | ||
[4]: https://gluonhq.com/products/scene-builder/ | ||
[5]: https://www.oracle.com/java/technologies/downloads/ | ||
[6]: https://maven.apache.org/ | ||
[7]: https://github.com/FXMisc/RichTextFX | ||
[8]: https://github.com/FXMisc/Flowless |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
HAI | ||
I HAS A num1 | ||
I HAS A num2 | ||
I HAS A num3 | ||
|
||
GIMMEH num1 | ||
GIMMEH num2 | ||
GIMMEH num3 | ||
|
||
num1 IS NOW A NUMBR | ||
num2 IS NOW A NUMBR | ||
num3 IS NOW A NUMBR | ||
|
||
DIFFRINT num1 AN SMALLR OF num1 AN num2 | ||
O RLY? | ||
YA RLY | ||
DIFFRINT num1 AN SMALLR OF num1 AN num3 | ||
O RLY? | ||
YA RLY | ||
VISIBLE num1 | ||
NO WAI | ||
VISIBLE num3 | ||
OIC | ||
NO WAI | ||
DIFFRINT num2 AN SMALLR OF num2 AN num3 | ||
O RLY? | ||
YA RLY | ||
VISIBLE num2 | ||
NO WAI | ||
VISIBLE num3 | ||
OIC | ||
OIC | ||
KTHXBYE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
HAI | ||
I HAS A number ITZ 8 | ||
I HAS A row ITZ 0 | ||
I HAS A col ITZ 0 | ||
I HAS A mid | ||
I HAS A temp ITZ 0 | ||
|
||
BOTH SAEM MOD OF number AN 2 AN 0 | ||
O RLY? | ||
YA RLY | ||
number R DIFF OF number AN 1 | ||
OIC | ||
|
||
mid R QUOSHUNT OF number AN 2 | ||
|
||
IM IN YR printRowDiamond UPPIN YR row WILE DIFFRINT row AN BIGGR OF row AN number | ||
IM IN YR printColDiamond UPPIN YR col WILE DIFFRINT col AN BIGGR OF col AN number | ||
BOTH SAEM col AN SMALLR OF col AN SUM OF mid AN temp | ||
O RLY? | ||
YA RLY | ||
BOTH SAEM col AN BIGGR OF col AN DIFF OF mid AN temp | ||
O RLY? | ||
YA RLY | ||
VISIBLE "*" ! | ||
NO WAI | ||
VISIBLE " " ! | ||
OIC | ||
NO WAI | ||
VISIBLE " " ! | ||
OIC | ||
|
||
IM OUTTA YR printColDiamond | ||
VISIBLE "" | ||
col R 0 | ||
|
||
BOTH SAEM row AN BIGGR OF row AN mid | ||
O RLY? | ||
YA RLY | ||
temp R DIFF OF temp AN 1 | ||
NO WAI | ||
temp R SUM OF temp AN 1 | ||
OIC | ||
|
||
IM OUTTA YR printRowDiamond | ||
KTHXBYE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
HAI | ||
I HAS A temp ITZ 1 | ||
I HAS A temp2 ITZ 0 | ||
|
||
I HAS A limit | ||
GIMMEH limit | ||
limit IS NOW A NUMBR | ||
|
||
IM IN YR print10 UPPIN YR temp TIL BOTH SAEM temp AN limit | ||
VISIBLE temp ":: " ! | ||
|
||
IM IN YR printEven UPPIN YR temp2 TIL BOTH SAEM temp2 AN temp | ||
VISIBLE PRODUKT OF temp2 AN 2 " " ! | ||
IM OUTTA YR printEven | ||
|
||
temp2 R 0 | ||
|
||
VISIBLE " " | ||
IM OUTTA YR print10 | ||
KTHXBYE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
HAI | ||
HOW IZ I factNum YR X | ||
BOTH SAEM X AN 0 | ||
O RLY? | ||
YA RLY | ||
FOUND YR 1 | ||
NO WAI | ||
FOUND YR PRODUKT OF X AN I IZ factNum YR DIFF OF X AN 1 MKAY | ||
OIC | ||
IF U SAY SO | ||
|
||
VISIBLE I IZ factNum YR 5 MKAY | ||
KTHXBYE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
HAI | ||
HOW IZ I factNumHelper YR X AN YR acc | ||
BOTH SAEM X AN 1 | ||
O RLY? | ||
YA RLY | ||
FOUND YR acc | ||
NO WAI | ||
acc R PRODUKT OF acc AN X | ||
FOUND YR I IZ factNumHelper YR DIFF OF X AN 1 AN YR acc MKAY | ||
OIC | ||
IF U SAY SO | ||
|
||
HOW IZ I factNum YR X | ||
FOUND YR I IZ factNumHelper YR X AN YR 1 MKAY | ||
IF U SAY SO | ||
|
||
VISIBLE I IZ factNum YR 6 MKAY | ||
KTHXBYE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
HAI | ||
I HAS A number | ||
I HAS A row ITZ 0 | ||
I HAS A col ITZ 0 | ||
I HAS A mid | ||
I HAS A temp ITZ 0 | ||
|
||
GIMMEH number | ||
number IS NOW A NUMBR | ||
|
||
BOTH SAEM MOD OF number AN 2 AN 0 | ||
O RLY? | ||
YA RLY | ||
number R DIFF OF number AN 1 | ||
OIC | ||
|
||
mid R QUOSHUNT OF number AN 2 | ||
|
||
IM IN YR printRowDiamond UPPIN YR row WILE DIFFRINT row AN BIGGR OF row AN number | ||
VISIBLE ":>" ! | ||
|
||
IM IN YR printColDiamond UPPIN YR col WILE DIFFRINT col AN BIGGR OF col AN number | ||
BOTH SAEM col AN SUM OF mid AN temp | ||
O RLY? | ||
YA RLY | ||
VISIBLE "*" ! | ||
MEBBE BOTH SAEM col AN DIFF OF mid AN temp | ||
VISIBLE "*" ! | ||
NO WAI | ||
VISIBLE " " ! | ||
OIC | ||
IM OUTTA YR printColDiamond | ||
|
||
VISIBLE ":)" ! | ||
col R 0 | ||
|
||
BOTH SAEM row AN BIGGR OF row AN mid | ||
O RLY? | ||
YA RLY | ||
temp R DIFF OF temp AN 1 | ||
NO WAI | ||
temp R SUM OF temp AN 1 | ||
OIC | ||
|
||
IM OUTTA YR printRowDiamond | ||
KTHXBYE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
HAI | ||
HOW IZ I printDiamond YR midPoint AN YR number1 | ||
|
||
IM IN YR printRowDiamond UPPIN YR row WILE DIFFRINT row AN BIGGR OF row AN number1 | ||
VISIBLE ":>" ! | ||
|
||
IM IN YR printColDiamond UPPIN YR col WILE DIFFRINT col AN BIGGR OF col AN number1 | ||
BOTH SAEM col AN SUM OF midPoint AN temp | ||
O RLY? | ||
YA RLY | ||
VISIBLE "*" ! | ||
MEBBE BOTH SAEM col AN DIFF OF midPoint AN temp | ||
VISIBLE "*" ! | ||
NO WAI | ||
VISIBLE " " ! | ||
OIC | ||
IM OUTTA YR printColDiamond | ||
|
||
VISIBLE ":)" ! | ||
col R 0 | ||
|
||
BOTH SAEM row AN BIGGR OF row AN midPoint | ||
O RLY? | ||
YA RLY | ||
temp R DIFF OF temp AN 1 | ||
NO WAI | ||
temp R SUM OF temp AN 1 | ||
OIC | ||
|
||
IM OUTTA YR printRowDiamond | ||
|
||
IF U SAY SO | ||
|
||
I HAS A number | ||
I HAS A row ITZ 0 | ||
I HAS A col ITZ 0 | ||
I HAS A mid | ||
I HAS A temp ITZ 0 | ||
|
||
GIMMEH number | ||
number IS NOW A NUMBR | ||
|
||
BOTH SAEM MOD OF number AN 2 AN 0 | ||
O RLY? | ||
YA RLY | ||
number R DIFF OF number AN 1 | ||
OIC | ||
|
||
|
||
I IZ printDiamond YR QUOSHUNT OF number AN 2 AN YR number MKAY | ||
|
||
|
||
KTHXBYE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
HAI | ||
HOW IZ I factNum YR X | ||
BOTH SAEM X AN 0 | ||
O RLY? | ||
YA RLY | ||
FOUND YR 1 | ||
NO WAI | ||
BTW return X * factNum(X-1) | ||
FOUND YR PRODUKT OF X AN I IZ factNum YR DIFF OF X AN 1 MKAY | ||
OIC | ||
IF U SAY SO | ||
|
||
HOW IZ I getPascalNum YR row AN YR N | ||
BTW row! / (N! * (row - N)!) | ||
FOUND YR QUOSHUNT OF I IZ factNum YR row MKAY AN PRODUKT OF I IZ factNum YR N MKAY AN I IZ factNum YR DIFF OF row AN N MKAY | ||
IF U SAY SO | ||
|
||
I HAS A var1 | ||
I HAS A rowCounter ITZ 0 | ||
I HAS A colCounter ITZ 0 | ||
|
||
GIMMEH var1 | ||
var1 IS NOW A NUMBR | ||
|
||
IM IN YR printPyramid UPPIN YR rowCounter TIL BOTH SAEM rowCounter AN var1 | ||
|
||
colCounter R 0 | ||
|
||
IM IN YR printCol UPPIN YR colCounter TIL DIFFRINT colCounter AN SMALLR OF colCounter AN rowCounter | ||
VISIBLE I IZ getPascalNum YR rowCounter AN YR colCounter MKAY " " ! | ||
IM OUTTA YR printCol | ||
|
||
VISIBLE "" | ||
|
||
IM OUTTA YR printPyramid | ||
|
||
KTHXBYE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
HAI | ||
BTW Perfect numbers 6 = 1 + 2 + 3 | ||
|
||
I HAS A currentNumber ITZ 2 | ||
|
||
I HAS A summation | ||
I HAS A temp | ||
|
||
IM IN YR perfectNumber UPPIN YR currentNumber WILE DIFFRINT currentNumber AN BIGGR OF currentNumber AN 10001 | ||
summation R 0 | ||
temp R 1 | ||
|
||
IM IN YR getFactors UPPIN YR temp WILE DIFFRINT temp AN BIGGR OF temp AN currentNumber | ||
|
||
BOTH SAEM MOD OF currentNumber AN temp AN 0 | ||
O RLY? | ||
YA RLY | ||
summation R SUM OF summation AN temp | ||
OIC | ||
IM OUTTA YR getFactors | ||
|
||
BOTH SAEM summation AN currentNumber | ||
O RLY? | ||
YA RLY | ||
VISIBLE currentNumber | ||
OIC | ||
|
||
IM OUTTA YR perfectNumber | ||
|
||
KTHXBYE |
Oops, something went wrong.