Skip to content

Commit 3762d04

Browse files
committed
Credit to the homeslice, @dospunk
1 parent b6c7121 commit 3762d04

File tree

5 files changed

+51
-61
lines changed

5 files changed

+51
-61
lines changed

LICENSE

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
Copyright (c) 2020 Connor Dooley (@dospunk)
2+
3+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"),
4+
to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
5+
and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6+
7+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8+
9+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
10+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
11+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
12+
IN THE SOFTWARE.

README.md

Lines changed: 36 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1,66 +1,42 @@
1-
# Codelike
2-
A 2D programming language
1+
# ACGA Codelike
32

4-
*Note: I made this back in 2016, and haven't touched it much since. Even still, I'm proud of it as it was my first attempt at file IO and it works fairly well.*
3+
A port of the 2D, array-based [codelike language](https://github.com/dospunk/codelike) with added commands to expand the range of the language to complete
4+
code golf challenges.
55

6-
## Some notes
6+
## Notes
77

8-
Specify the file to run by passing it as an argument when running Interpreter
9-
10-
When reading a source file, the interpreter will always start at the top left corner and will be going down.
11-
12-
Y coordinates increase going down, X coordinates increase going left
13-
14-
Please note that tabs only count as one character! Make sure to use spaces.
15-
16-
If you get a `j` error first thing when running but your file does not start with a `j`, it means that the file could not be found
17-
18-
turn on debugging mode by changing the `debugging` boolean at the begining of the Interpreter file to `true` [(x)](https://github.com/dospunk/codelike/blob/master/Interpreter.java#L13)
8+
- When reading a source file, the interpreter will always start at the top left corner and will be going down.
9+
- `Y` coordinates increase going down, `X` coordinates increase going left
10+
- Please note that tabs only count as one character; make sure to use spaces
11+
- If you get a `j` error first thing when running but your file does not start with a j, it means that the file could not be found
12+
- turn on debugging mode by changing the [`debugging` boolean at the beginning of the Main.java file](https://github.com/Allegheny-Code-Colf-Association/acga-codelike/blob/master/src/main/java/com/interpreter/acga-codelike/Main.java#L16) to true
1913

2014
## Commands
2115

22-
-: continue horizontally
23-
24-
|: continue vertically
25-
26-
\: continue up+left or down+right
27-
28-
/: continue down+left or up+right
29-
30-
+: increment top value on the stack and continue
31-
32-
_: decrement top value on the stack and continue
33-
34-
\>: If moving to the left, will continue up+left if the top value on the stack is greater than 0, or down+left if it is less than zero
35-
36-
<: If moving to the right, will continue up+right if the top value on the stack is greater than 0, or down+right if it is less than zero
37-
38-
^: If moving to the down, will continue down+right if the top value on the stack is greater than 0, or down+left if it is less than zero
39-
40-
*: pop the top two values from the stack, multiply them, and push the result to the stack
41-
42-
a: pop the top two values from the stack, add them, and push the result to the stack
43-
44-
b: print the top value from the stack
45-
46-
c: change direction: scan clockwise and continue
47-
48-
d: pop the top two values from the stack, divide the top by the second, and push the result rounded down to the stack
49-
50-
f: discard the top value from the stack
51-
52-
j: take the top two values from the stack as coordinates (top val = x, second val = y) and go to those coordinates in the grid
53-
54-
n: push a 0 onto the stack
55-
56-
o: change direction: scan counter-clockwise and continue
57-
58-
p: print the ASCII character corresponding to the top value on the stack
59-
60-
r: reverses the direction
61-
62-
s: pop the top two values from the stack, subtract them, and push the result to the stack
63-
64-
u: push a number from user input to the stack
65-
66-
e: end the program
16+
|Command |Functionality |
17+
|:-------|:-------------|
18+
|`-` |Continue horizontally |
19+
|`|` |Continue vertically |
20+
|`\` |Continue up-left or down-right |
21+
|`/` |Continue down-left or up-right |
22+
|`+` |Increment top value on the stack and continue |
23+
|`_` |Decrement top value on the stack and continue |
24+
|`\>` |If moving to the left, will continue up-left if the top value on the stack is greater than `0`, or down-left if it is less than zero |
25+
|`<` |If moving to the right, will continue up-right if the top value on the stack is greater than `0`, or down-right if it is less than zero |
26+
|`^` |If moving to the down, will continue down-right if the top value on the stack is greater than `0`, or down-left if it is less than zero |
27+
|`*` |Pop the top two values from the stack, multiply them, and push the result to the stack |
28+
|`a` |Pop the top two values from the stack, add them, and push the result to the stack |
29+
|`b` |Print the top value from the stack |
30+
|`c` |Change direction: scan clockwise and continue |
31+
|`d` |Pop the top two values from the stack, divide the top by the second, and push the result rounded down to the stack |
32+
|`f` |Discard the top value from the stack |
33+
|`j` |Take the top two values from the stack as coordinates (top val = `x`, second val = `y`) and go to those coordinates in the grid |
34+
|`n` |Push a `0` onto the stack |
35+
|`o` |Change direction: scan counter-clockwise and continue |
36+
|`p` |Print the ASCII character corresponding to the top value on the stack |
37+
|`r` |Reverses the direction |
38+
|`v` |Print the number of values in the stack |
39+
|`z` |Copy the number `n` positions down in the stack where `n` is the current top value of the stack |
40+
|`s` |Pop the top two values from the stack, subtract them, and push the result to the stack |
41+
|`u` |Push a number from user input to the stack |
42+
|`e` |End the program |

src/main/java/com/interpreter/acga-codelike/Main.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -568,7 +568,7 @@ public String readFile(String filename) throws IOException {
568568
}
569569

570570
public static void main(String[] args){
571-
Interpreter x = new Interpreter();
571+
Main x = new Main();
572572
try{
573573
x.createMap(x.readFile(args[0]));
574574
if(x.debugging){
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
com/interpreter/codelike/Main.class
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/home/dluman/cmpsc201/acga/acga-codelike/src/main/java/com/interpreter/acga-codelike/Main.java

0 commit comments

Comments
 (0)