term = parseTerm(true); } else { tokenizer.pushBack(); term = null;
/** * Parses a function argument list <i>'(' arg1 ',' arg2 ',' arg3 ',' ... ')'</i> * * @return The generated term. * @throws ParseException if a parse error occurs */ private Term[] parseArgumentList() throws ParseException { final Term[] args = parseTermList(); final int tt = tokenizer.next(); if (tt != ')') { tokenizer.pushBack(); reportError("Missing ')' or ','."); /*I18N*/ } return args; }
/** * Parses an assignment expression <i>x '=' y</i>. * * @param required true, if the expression is required. * @return The generated term. * @throws ParseException if a parse error occurs */ private Term parseAssign(final boolean required) throws ParseException { Term t1 = parseConditional(required); while (t1 != null) { int tt = tokenizer.next(); if (tt == '=') { Term t2 = parseAssign(true); if (t1 instanceof Term.Ref && ((Term.Ref) t1).getVariable() != null) { t1 = new Term.Assign(t1, t2); } else { reportError("Variable expected on the left side of assignment '='."); } } else { tokenizer.pushBack(); break; } } return t1; }
return createConditionTerm(t1, t2, t3); } else { tokenizer.pushBack(); reportError("Missing 'else' in a conditional 'if' term."); tokenizer.pushBack(); reportError("Missing 'then' in a conditional 'if' term."); tokenizer.pushBack(); t1 = createConditionTerm(t1, t2, t3); } else { tokenizer.pushBack(); reportError("Missing ':' part of conditional '?:' term."); tokenizer.pushBack();
/** * Parses a bitwise XOR expression <i>x '^' y</i>. * * @param required true, if the expression is required. * @return The generated term. * @throws ParseException if a parse error occurs */ private Term parseBtwiseXOr(final boolean required) throws ParseException { Term t1 = parseBitwiseAnd(required); while (t1 != null) { int tt = tokenizer.next(); if (tt == '^') { Term t2 = parseBitwiseAnd(true); if ((t1.isI() && t2.isI()) || !isTypeChecking()) { t1 = new Term.XOrI(t1, t2); } else { reportTypeErrorI2("'^'"); } } else { tokenizer.pushBack(); break; } } return t1; }
/** * Parses a bitwise OR expression <i>x '|' y</i>. * * @param required true, if the expression is required. * @return The generated term. * @throws ParseException if a parse error occurs */ private Term parseBitwiseOr(final boolean required) throws ParseException { Term t1 = parseBtwiseXOr(required); while (t1 != null) { int tt = tokenizer.next(); if (tt == '|') { Term t2 = parseBtwiseXOr(true); if ((t1.isI() && t2.isI()) || !isTypeChecking()) { t1 = new Term.OrI(t1, t2); } else { reportTypeErrorI2("'|'"); } } else { tokenizer.pushBack(); break; } } return t1; }
/** * Parses a bitwise AND expression <i>x '&' y</i>. * * @param required true, if the expression is required. * @return The generated term. * @throws ParseException if a parse error occurs */ private Term parseBitwiseAnd(final boolean required) throws ParseException { Term t1 = parseAdd(required); while (t1 != null) { int tt = tokenizer.next(); if (tt == '&') { Term t2 = parseAdd(true); if ((t1.isI() && t2.isI()) || !isTypeChecking()) { t1 = new Term.AndI(t1, t2); } else { reportTypeErrorI2("'&'"); } } else { tokenizer.pushBack(); break; } } return t1; }
private Term parseCallOrRef(final String name) throws ParseException { final int tt; Term t1 = null; tt = tokenizer.next(); if (tt == '(') { Term[] args = parseArgumentList(); Function function = defaultNamespace.resolveFunction(name, args); if (function != null) { t1 = new Term.Call(function, args); } else { reportError("Undefined function '" + getFunctionCallString(name, args) + "'."); /*I18N*/ } } else { tokenizer.pushBack(); Symbol symbol = defaultNamespace.resolveSymbol(name); if (symbol != null) { t1 = new Term.Ref(symbol); } else { reportError("Undefined symbol '" + name + "'."); /*I18N*/ } } return t1; }
/** * Parses a logical OR expression <i>x '||' y</i>. * * @param required true, if the expression is required. * @return The generated term. * @throws ParseException if a parse error occurs */ private Term parseLogicalOr(final boolean required) throws ParseException { Term t1 = parseLogicalAnd(required); while (t1 != null) { /*int tt =*/ tokenizer.next(); if (isSpecial("||") || isKeyword("or")) { Term t2 = parseLogicalAnd(true); if ((t1.isB() && t2.isB()) || !isTypeChecking()) { t1 = new Term.OrB(t1, t2); } else { reportTypeErrorB2("'||' or 'or'"); } } else { tokenizer.pushBack(); break; } } return t1; }
/** * Parses a logical AND expression <i>x '&&' y</i>. * * @param required true, if the expression is required. * @return The generated term. * @throws ParseException if a parse error occurs */ private Term parseLogicalAnd(final boolean required) throws ParseException { Term t1 = parseComparison(required); while (t1 != null) { /*int tt =*/ tokenizer.next(); if (isSpecial("&&") || isKeyword("and")) { Term t2 = parseComparison(true); if ((t1.isB() && t2.isB()) || !isTypeChecking()) { t1 = new Term.AndB(t1, t2); } else { reportTypeErrorB2("'&&' or 'and'"); } } else { tokenizer.pushBack(); break; } } return t1; }
tokenizer.pushBack(); break;
tokenizer.pushBack(); t1 = parsePostfix(required);
tokenizer.pushBack(); break;
tokenizer.pushBack(); break;