This commit is contained in:
TomyLobo
2011-11-23 02:29:48 +01:00
parent 1a57f6e95d
commit 7e13b60a51
161 changed files with 1433 additions and 1412 deletions

View File

@ -182,8 +182,7 @@ public class Parser {
if (peek().id() == ';') {
++position;
break;
}
else {
} else {
break loop;
}
@ -205,8 +204,7 @@ public class Parser {
break loop;
}
break;
}
else {
} else {
break loop;
}
}
@ -253,7 +251,7 @@ public class Parser {
} else {
RValue variable = variables.get(identifierToken.value);
if (variable == null) {
if (next instanceof OperatorToken && ((OperatorToken)next).operator.equals("=")) {
if (next instanceof OperatorToken && ((OperatorToken) next).operator.equals("=")) {
// Ugly hack to make temporary variables work while not sacrificing error reporting.
variables.put(identifierToken.value, variable = new Variable(0));
} else {

View File

@ -35,32 +35,32 @@ public final class ParserProcessors {
final Object[][][] binaryOpsLA = {
{
{ "^", "pow" },
{ "**", "pow" },
{ "^", "pow" },
{ "**", "pow" },
},
{
{ "*", "mul" },
{ "/", "div" },
{ "%", "mod" },
{ "*", "mul" },
{ "/", "div" },
{ "%", "mod" },
},
{
{ "+", "add" },
{ "-", "sub" },
{ "+", "add" },
{ "-", "sub" },
},
{
{ "<<", "shl" },
{ ">>", "shr" },
{ "<<", "shl" },
{ ">>", "shr" },
},
{
{ "<", "lth" },
{ ">", "gth" },
{ "<=", "leq" },
{ ">=", "geq" },
{ "<", "lth" },
{ ">", "gth" },
{ "<=", "leq" },
{ ">=", "geq" },
},
{
{ "==", "equ" },
{ "!=", "neq" },
{ "~=", "near" },
{ "==", "equ" },
{ "!=", "neq" },
{ "~=", "near" },
},
{
{ "&&", "and" },
@ -71,13 +71,13 @@ public final class ParserProcessors {
};
final Object[][][] binaryOpsRA = {
{
{ "=", "ass" },
{ "+=", "aadd" },
{ "-=", "asub" },
{ "*=", "amul" },
{ "/=", "adiv" },
{ "%=", "amod" },
{ "^=", "aexp" },
{ "=", "ass" },
{ "+=", "aadd" },
{ "-=", "asub" },
{ "*=", "amul" },
{ "/=", "adiv" },
{ "%=", "amod" },
{ "^=", "aexp" },
},
};
@ -230,19 +230,17 @@ public final class ParserProcessors {
final Identifiable last = input.removeLast();
if (last instanceof OperatorToken) {
postfixes.addLast(new UnaryOperator(last.getPosition(), "x"+((OperatorToken)last).operator));
}
else if (last instanceof UnaryOperator) {
postfixes.addLast(new UnaryOperator(last.getPosition(), "x"+((UnaryOperator)last).operator));
}
else {
postfixes.addLast(new UnaryOperator(last.getPosition(), "x" + ((OperatorToken) last).operator));
} else if (last instanceof UnaryOperator) {
postfixes.addLast(new UnaryOperator(last.getPosition(), "x" + ((UnaryOperator) last).operator));
} else {
center = last;
break;
}
} while (true);
if (!(center instanceof RValue)) {
throw new ParserException(center.getPosition(), "Expected expression, found "+center);
throw new ParserException(center.getPosition(), "Expected expression, found " + center);
}
input.addAll(postfixes);

View File

@ -13,7 +13,7 @@ public class UnaryOperator extends PseudoToken {
public UnaryOperator(OperatorToken operatorToken) {
this(operatorToken.getPosition(), operatorToken.operator);
}
public UnaryOperator(int position, String operator) {
super(position);
this.operator = operator;