updated parseFactor
This commit is contained in:
+8
-32
@@ -126,51 +126,27 @@ public class Parser {
|
|||||||
if ( token.isKind("num") ) {
|
if ( token.isKind("num") ) {
|
||||||
return new Node("num", token.getDetails(), null, null, null );
|
return new Node("num", token.getDetails(), null, null, null );
|
||||||
}
|
}
|
||||||
|
|
||||||
else if ( token.isKind("var") ) {
|
else if ( token.isKind("var") ) {
|
||||||
return new Node("var", token.getDetails(), null, null, null );
|
return new Node("var", token.getDetails(), null, null, null );
|
||||||
}
|
}
|
||||||
|
|
||||||
else if ( token.matches("single","(") ) {
|
else if ( token.matches("single","(") ) {
|
||||||
Node first = parseExpr();
|
Node first = parseExpr();
|
||||||
token = lex.getNextToken();
|
token = lex.getNextToken();
|
||||||
errorCheck( token, "single", ")" );
|
errorCheck( token, "single", ")" );
|
||||||
return first;
|
return first;
|
||||||
}
|
}
|
||||||
else if ( token.isKind("bif0") ) {
|
|
||||||
String bifName = token.getDetails();
|
|
||||||
token = lex.getNextToken();
|
|
||||||
errorCheck( token, "single", "(" );
|
|
||||||
token = lex.getNextToken();
|
|
||||||
errorCheck( token, "single", ")" );
|
|
||||||
|
|
||||||
return new Node( bifName, null, null, null );
|
|
||||||
}
|
|
||||||
else if ( token.isKind("bif1") ) {
|
|
||||||
String bifName = token.getDetails();
|
|
||||||
token = lex.getNextToken();
|
|
||||||
errorCheck( token, "single", "(" );
|
|
||||||
Node first = parseExpr();
|
|
||||||
token = lex.getNextToken();
|
|
||||||
errorCheck( token, "single", ")" );
|
|
||||||
|
|
||||||
return new Node( bifName, first, null, null );
|
|
||||||
}
|
|
||||||
else if ( token.isKind("bif2") ) {
|
|
||||||
String bifName = token.getDetails();
|
|
||||||
token = lex.getNextToken();
|
|
||||||
errorCheck( token, "single", "(" );
|
|
||||||
Node first = parseExpr();
|
|
||||||
token = lex.getNextToken();
|
|
||||||
errorCheck( token, "single", "," );
|
|
||||||
Node second = parseExpr();
|
|
||||||
token = lex.getNextToken();
|
|
||||||
errorCheck( token, "single", ")" );
|
|
||||||
|
|
||||||
return new Node( bifName, first, second, null );
|
|
||||||
}
|
|
||||||
else if ( token.matches("single","-") ) {
|
else if ( token.matches("single","-") ) {
|
||||||
Node first = parseFactor();
|
Node first = parseFactor();
|
||||||
return new Node("opp", first, null, null );
|
return new Node("opp", first, null, null );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
else if (token.isKind("funcCall")) {
|
||||||
|
return new Node("funcCall", token.getDetails(), null, null, null);
|
||||||
|
}
|
||||||
|
|
||||||
else {
|
else {
|
||||||
System.out.println("Can't have factor starting with " + token );
|
System.out.println("Can't have factor starting with " + token );
|
||||||
System.exit(1);
|
System.exit(1);
|
||||||
|
|||||||
Reference in New Issue
Block a user