Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions src/compiler/Parser.java
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ private void STMT_LIST(final TreeNode parentNode) throws ParseException {
list.add(Token.READ);
list.add(Token.IF);
list.add(Token.WHILE);
list.add(Token.DO);

if(list.contains(lexer.currentToken()))
{
Expand Down Expand Up @@ -132,25 +133,27 @@ else if (lexer.currentToken() == Token.IF) {
this.CONDITION(thisNode);
this.MATCH(thisNode, Token.THEN);
this.STMT_LIST(thisNode);

if (lexer.currentToken() == Token.ELSE) {
this.MATCH(thisNode, Token.ELSE);
this.STMT_LIST(thisNode);
}

this.MATCH(thisNode, Token.FI);
}
else if (lexer.currentToken() == Token.WHILE){
else if (lexer.currentToken() == Token.DO) { //Meaning this is do until
this.MATCH(thisNode, Token.DO); //It annoys me I don't know how to implement it not being in a while loop
this.STMT_LIST(thisNode);
this.MATCH(thisNode, Token.UNTIL);
this.CONDITION(thisNode);
}
else{ //Meaning this is a while loop
this.MATCH(thisNode, Token.WHILE);
this.CONDITION(thisNode);
this.MATCH(thisNode, Token.DO);
this.STMT_LIST(thisNode);
this.MATCH(thisNode, Token.OD);
}
else if (lexer.currentToken() == Token.DO) { //Meaning this is do until
this.MATCH(thisNode, Token.DO);
this.STMT_LIST(thisNode);
this.MATCH(thisNode, Token.UNTIL);
this.CONDITION(thisNode);
}
}

// <EXPR> ::= <TERM> <TERM_TAIL>
Expand Down