Skip to content

Commit 223e95c

Browse files
authored
Merge pull request #1 from paceuniversity/maren
Maren
2 parents 3967c6e + ea8d47b commit 223e95c

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

.github/workflows/classroom.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
uses: classroom-resources/autograding-command-grader@v1
1919
with:
2020
test-name: Parser Tests
21-
setup-command: "./setup.sh"
21+
setup-command: ""
2222
command: gradle test
2323
timeout: 10
2424
- name: Autograding Reporter

src/main/java/com/scanner/project/ConcreteSyntax.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ public Program program() {
5050
this.match("main");
5151
this.match("{");
5252
Program p = new Program();
53-
p.decpart = this.declarations();
54-
p.body = this.statements();
53+
p.decpart = declarations();
54+
p.body = statements();
5555
this.match("}");
5656
return p;
5757
}
@@ -79,9 +79,9 @@ private Type type() {
7979
// Type --> integer | bool
8080
Type t = null;
8181
if (token.getValue().equals("integer"))
82-
t = new Type(token.getValue());
82+
t = new Type(Type.INTEGER);
8383
else if (token.getValue().equals("bool"))
84-
t = new Type(token.getValue());
84+
t = new Type(Type.BOOLEAN);
8585
else
8686
// kept message consistent with the keywords used elsewhere
8787
throw new RuntimeException(SyntaxError("integer | bool"));
@@ -132,7 +132,7 @@ else if (token.getValue().equals("while")) { // WhileStatement
132132
} else if (token.getType().equals("Identifier")) { // Assignment
133133
// TODO TO BE COMPLETED
134134
s = assignment();
135-
match(";");
135+
//match(";");
136136
} else
137137
throw new RuntimeException(SyntaxError("Statement"));
138138
return s;
@@ -152,13 +152,13 @@ private Assignment assignment() {
152152
Assignment a = new Assignment();
153153
if (token.getType().equals("Identifier")) {
154154
// TODO TO BE COMPLETED
155-
Variable target = new Variable();
156-
target.id = token.getValue();
157-
a.target = target;
155+
Variable v = new Variable();
156+
v.id = token.getValue();
157+
a.target = v;
158158
token = input.nextToken();
159-
160159
match(":=");
161160
a.source = expression();
161+
match(";");
162162
} else
163163
throw new RuntimeException(SyntaxError("Identifier"));
164164
return a;
@@ -308,7 +308,7 @@ private Conditional ifStatement() {
308308
c.thenbranch = statement();
309309

310310
if (token.getValue().equals("else")){
311-
match("else");
311+
token = input.nextToken();
312312
c.elsebranch = statement();
313313
} else {
314314
c.elsebranch = null;

0 commit comments

Comments
 (0)