Avoid getters for final fields

This commit is contained in:
serso 2016-01-24 21:11:04 +01:00
parent e751d2cbd4
commit 0e4960dc4e
30 changed files with 125 additions and 146 deletions

View File

@ -13,7 +13,7 @@ public class BracketedExpression implements Parser<ExpressionVariable> {
}
public ExpressionVariable parse(@Nonnull Parameters p, Generic previousSumElement) throws ParseException {
int pos0 = p.getPosition().intValue();
int pos0 = p.position.intValue();
ParserUtils.tryToParse(p, pos0, '(');
@ -21,7 +21,7 @@ public class BracketedExpression implements Parser<ExpressionVariable> {
try {
result = ExpressionParser.parser.parse(p, previousSumElement);
} catch (ParseException e) {
p.getPosition().setValue(pos0);
p.position.setValue(pos0);
throw e;
}

View File

@ -13,7 +13,7 @@ public class CommaAndExpression implements Parser<Generic> {
}
public Generic parse(@Nonnull Parameters p, @Nullable Generic previousSumElement) throws ParseException {
int pos0 = p.getPosition().intValue();
int pos0 = p.position.intValue();
ParserUtils.skipWhitespaces(p);

View File

@ -15,7 +15,7 @@ public class CommaAndVector implements Parser<JsclVector> {
@Nonnull
public JsclVector parse(@Nonnull Parameters p, @Nullable Generic previousSumElement) throws ParseException {
int pos0 = p.getPosition().intValue();
int pos0 = p.position.intValue();
ParserUtils.skipWhitespaces(p);

View File

@ -14,7 +14,7 @@ public class CompoundIdentifier implements Parser<String> {
@Nonnull
public String parse(@Nonnull Parameters p, @Nullable Generic previousSumElement) throws ParseException {
int pos0 = p.getPosition().intValue();
int pos0 = p.position.intValue();
StringBuilder result = new StringBuilder();
@ -23,7 +23,7 @@ public class CompoundIdentifier implements Parser<String> {
String s = Identifier.parser.parse(p, previousSumElement);
result.append(s);
} catch (ParseException e) {
p.getPosition().setValue(pos0);
p.position.setValue(pos0);
throw e;
}
@ -49,7 +49,7 @@ class DotAndIdentifier implements Parser<String> {
}
public String parse(@Nonnull Parameters p, Generic previousSumElement) throws ParseException {
int pos0 = p.getPosition().intValue();
int pos0 = p.position.intValue();
ParserUtils.tryToParse(p, pos0, '.');
@ -57,7 +57,7 @@ class DotAndIdentifier implements Parser<String> {
try {
result = Identifier.parser.parse(p, previousSumElement);
} catch (ParseException e) {
p.getPosition().setValue(pos0);
p.position.setValue(pos0);
throw e;
}

View File

@ -64,7 +64,7 @@ class Superscript implements Parser<Integer> {
}
public Integer parse(@Nonnull Parameters p, Generic previousSumElement) throws ParseException {
int pos0 = p.getPosition().intValue();
int pos0 = p.position.intValue();
ParserUtils.tryToParse(p, pos0, '{');
@ -73,7 +73,7 @@ class Superscript implements Parser<Integer> {
try {
result = IntegerParser.parser.parse(p, previousSumElement);
} catch (ParseException e) {
p.getPosition().setValue(pos0);
p.position.setValue(pos0);
throw e;
}

View File

@ -18,22 +18,22 @@ public class Digits implements Parser<String> {
// returns digit
public String parse(@Nonnull Parameters p, @Nullable Generic previousSumElement) throws ParseException {
int pos0 = p.getPosition().intValue();
int pos0 = p.position.intValue();
final StringBuilder result = new StringBuilder();
ParserUtils.skipWhitespaces(p);
if (p.getPosition().intValue() < p.getExpression().length() && nb.getAcceptableCharacters().contains(p.getExpression().charAt(p.getPosition().intValue()))) {
result.append(p.getExpression().charAt(p.getPosition().intValue()));
p.getPosition().increment();
if (p.position.intValue() < p.expression.length() && nb.getAcceptableCharacters().contains(p.expression.charAt(p.position.intValue()))) {
result.append(p.expression.charAt(p.position.intValue()));
p.position.increment();
} else {
ParserUtils.throwParseException(p, pos0, Messages.msg_9);
}
while (p.getPosition().intValue() < p.getExpression().length() && nb.getAcceptableCharacters().contains(p.getExpression().charAt(p.getPosition().intValue()))) {
result.append(p.getExpression().charAt(p.getPosition().intValue()));
p.getPosition().increment();
while (p.position.intValue() < p.expression.length() && nb.getAcceptableCharacters().contains(p.expression.charAt(p.position.intValue()))) {
result.append(p.expression.charAt(p.position.intValue()));
p.position.increment();
}
return result.toString();

View File

@ -39,7 +39,7 @@ class Singularity implements Parser<Double> {
@Nonnull
public Double parse(@Nonnull Parameters p, Generic previousSumElement) throws ParseException {
int pos0 = p.getPosition().intValue();
int pos0 = p.position.intValue();
double result = 0d;
@ -64,7 +64,7 @@ class FloatingPointLiteral implements Parser<Double> {
}
public Double parse(@Nonnull Parameters p, Generic previousSumElement) throws ParseException {
int pos0 = p.getPosition().intValue();
int pos0 = p.position.intValue();
final NumeralBase nb = NumeralBaseParser.parser.parse(p, previousSumElement);
@ -88,7 +88,7 @@ class FloatingPointLiteral implements Parser<Double> {
point = true;
} catch (ParseException e) {
if (!digits) {
p.getPosition().setValue(pos0);
p.position.setValue(pos0);
throw e;
}
}
@ -101,7 +101,7 @@ class FloatingPointLiteral implements Parser<Double> {
result.append(digitsParser.parse(p, previousSumElement));
} catch (ParseException e) {
if (!digits) {
p.getPosition().setValue(pos0);
p.position.setValue(pos0);
throw e;
}
}
@ -111,7 +111,7 @@ class FloatingPointLiteral implements Parser<Double> {
exponent = true;
} catch (ParseException e) {
if (!point) {
p.getPosition().setValue(pos0);
p.position.setValue(pos0);
throw e;
}
}
@ -124,7 +124,7 @@ class FloatingPointLiteral implements Parser<Double> {
try {
return nb.toDouble(doubleString);
} catch (NumberFormatException e) {
throw new ParseException(Messages.msg_8, p.getPosition().intValue(), p.getExpression(), doubleString);
throw new ParseException(Messages.msg_8, p.position.intValue(), p.expression, doubleString);
}
}
}
@ -138,7 +138,7 @@ class DecimalPoint implements Parser<Void> {
@Nullable
public Void parse(@Nonnull Parameters p, Generic previousSumElement) throws ParseException {
int pos0 = p.getPosition().intValue();
int pos0 = p.position.intValue();
ParserUtils.skipWhitespaces(p);
@ -157,15 +157,15 @@ class ExponentPart implements Parser<String> {
@Nonnull
public String parse(@Nonnull Parameters p, Generic previousSumElement) throws ParseException {
int pos0 = p.getPosition().intValue();
int pos0 = p.position.intValue();
final StringBuilder result = new StringBuilder();
ParserUtils.skipWhitespaces(p);
if (p.getPosition().intValue() < p.getExpression().length() && (p.getExpression().charAt(p.getPosition().intValue()) == 'e' || p.getExpression().charAt(p.getPosition().intValue()) == 'E')) {
char c = p.getExpression().charAt(p.getPosition().intValue());
p.getPosition().increment();
if (p.position.intValue() < p.expression.length() && (p.expression.charAt(p.position.intValue()) == 'e' || p.expression.charAt(p.position.intValue()) == 'E')) {
char c = p.expression.charAt(p.position.intValue());
p.position.increment();
result.append(c);
} else {
ParserUtils.throwParseException(p, pos0, Messages.msg_10, 'e', 'E');
@ -174,7 +174,7 @@ class ExponentPart implements Parser<String> {
try {
result.append(SignedInteger.parser.parse(p, previousSumElement));
} catch (ParseException e) {
p.getPosition().setValue(pos0);
p.position.setValue(pos0);
throw e;
}
@ -191,22 +191,22 @@ class SignedInteger implements Parser<String> {
@Nonnull
public String parse(@Nonnull Parameters p, Generic previousSumElement) throws ParseException {
int pos0 = p.getPosition().intValue();
int pos0 = p.position.intValue();
final StringBuilder result = new StringBuilder();
ParserUtils.skipWhitespaces(p);
if (p.getPosition().intValue() < p.getExpression().length() && (p.getExpression().charAt(p.getPosition().intValue()) == '+' || p.getExpression().charAt(p.getPosition().intValue()) == '-')) {
char c = p.getExpression().charAt(p.getPosition().intValue());
p.getPosition().increment();
if (p.position.intValue() < p.expression.length() && (p.expression.charAt(p.position.intValue()) == '+' || p.expression.charAt(p.position.intValue()) == '-')) {
char c = p.expression.charAt(p.position.intValue());
p.position.increment();
result.append(c);
}
try {
result.append(IntegerParser.parser.parse(p, previousSumElement).intValue());
} catch (ParseException e) {
p.getPosition().setValue(pos0);
p.position.setValue(pos0);
throw e;
}

View File

@ -18,7 +18,7 @@ class ExponentParser implements Parser<Generic> {
}
public Generic parse(@Nonnull Parameters p, @Nullable Generic previousSumElement) throws ParseException {
int pos0 = p.getPosition().intValue();
int pos0 = p.position.intValue();
boolean sign = MinusParser.parser.parse(p, previousSumElement).isSign();

View File

@ -28,22 +28,22 @@ public class Identifier implements Parser<String> {
// returns getVariable/constant getName
@Nonnull
public String parse(@Nonnull Parameters p, @Nullable Generic previousSumElement) throws ParseException {
int pos0 = p.getPosition().intValue();
int pos0 = p.position.intValue();
final StringBuilder result = new StringBuilder();
ParserUtils.skipWhitespaces(p);
if (p.getPosition().intValue() < p.getExpression().length() && isValidFirstCharacter(p.getExpression().charAt(p.getPosition().intValue()))) {
result.append(p.getExpression().charAt(p.getPosition().intValue()));
p.getPosition().increment();
if (p.position.intValue() < p.expression.length() && isValidFirstCharacter(p.expression.charAt(p.position.intValue()))) {
result.append(p.expression.charAt(p.position.intValue()));
p.position.increment();
} else {
ParserUtils.throwParseException(p, pos0, Messages.msg_5);
}
while (p.getPosition().intValue() < p.getExpression().length() && isValidNotFirstCharacter(p.getExpression(), p.getPosition())) {
result.append(p.getExpression().charAt(p.getPosition().intValue()));
p.getPosition().increment();
while (p.position.intValue() < p.expression.length() && isValidNotFirstCharacter(p.expression, p.position)) {
result.append(p.expression.charAt(p.position.intValue()));
p.position.increment();
}
return result.toString();

View File

@ -19,13 +19,13 @@ public class ImplicitFunctionParser implements Parser<Function> {
}
public Function parse(@Nonnull Parameters p, Generic previousSumElement) throws ParseException {
int pos0 = p.getPosition().intValue();
int pos0 = p.position.intValue();
Generic a[];
final String name = ParserUtils.parseWithRollback(CompoundIdentifier.parser, pos0, previousSumElement, p);
if (FunctionsRegistry.getInstance().getNames().contains(name) || OperatorsRegistry.getInstance().getNames().contains(name)) {
p.getPosition().setValue(pos0);
throw new ParseException(Messages.msg_6, p.getPosition().intValue(), p.getExpression(), name);
p.position.setValue(pos0);
throw new ParseException(Messages.msg_6, p.position.intValue(), p.expression, name);
}
final List<Generic> subscripts = new ArrayList<Generic>();
@ -46,7 +46,7 @@ public class ImplicitFunctionParser implements Parser<Function> {
try {
a = ParameterListParser.parser1.parse(p, previousSumElement);
} catch (ParseException e) {
p.getPosition().setValue(pos0);
p.position.setValue(pos0);
throw e;
}
@ -87,7 +87,7 @@ class SuperscriptList implements Parser<int[]> {
}
public int[] parse(@Nonnull Parameters p, Generic previousSumElement) throws ParseException {
int pos0 = p.getPosition().intValue();
int pos0 = p.position.intValue();
ParserUtils.tryToParse(p, pos0, '{');
@ -95,7 +95,7 @@ class SuperscriptList implements Parser<int[]> {
try {
result.add(IntegerParser.parser.parse(p, previousSumElement));
} catch (ParseException e) {
p.getPosition().setValue(pos0);
p.position.setValue(pos0);
throw e;
}
@ -123,7 +123,7 @@ class CommaAndInteger implements Parser<Integer> {
}
public Integer parse(@Nonnull Parameters p, Generic previousSumElement) throws ParseException {
int pos0 = p.getPosition().intValue();
int pos0 = p.position.intValue();
ParserUtils.skipWhitespaces(p);

View File

@ -15,7 +15,7 @@ public class IntegerParser implements Parser<Integer> {
}
public Integer parse(@Nonnull Parameters p, @Nullable Generic previousSumElement) throws ParseException {
int pos0 = p.getPosition().intValue();
int pos0 = p.position.intValue();
/*int n;
@ -40,18 +40,18 @@ public class IntegerParser implements Parser<Integer> {
final StringBuilder result = new StringBuilder();
ParserUtils.skipWhitespaces(p);
if (p.getPosition().intValue() < p.getExpression().length() && nb.getAcceptableCharacters().contains(p.getExpression().charAt(p.getPosition().intValue()))) {
char c = p.getExpression().charAt(p.getPosition().intValue());
p.getPosition().increment();
if (p.position.intValue() < p.expression.length() && nb.getAcceptableCharacters().contains(p.expression.charAt(p.position.intValue()))) {
char c = p.expression.charAt(p.position.intValue());
p.position.increment();
result.append(c);
} else {
p.getPosition().setValue(pos0);
throw new ParseException(Messages.msg_7, p.getPosition().intValue(), p.getExpression());
p.position.setValue(pos0);
throw new ParseException(Messages.msg_7, p.position.intValue(), p.expression);
}
while (p.getPosition().intValue() < p.getExpression().length() && nb.getAcceptableCharacters().contains(p.getExpression().charAt(p.getPosition().intValue()))) {
char c = p.getExpression().charAt(p.getPosition().intValue());
p.getPosition().increment();
while (p.position.intValue() < p.expression.length() && nb.getAcceptableCharacters().contains(p.expression.charAt(p.position.intValue()))) {
char c = p.expression.charAt(p.position.intValue());
p.position.increment();
result.append(c);
}
@ -59,7 +59,7 @@ public class IntegerParser implements Parser<Integer> {
try {
return nb.toInteger(number);
} catch (NumberFormatException e) {
throw new ParseException(Messages.msg_8, p.getPosition().intValue(), p.getExpression(), number);
throw new ParseException(Messages.msg_8, p.position.intValue(), p.expression, number);
}
}
}

View File

@ -16,7 +16,7 @@ public class JsclIntegerParser implements Parser<JsclInteger> {
}
public JsclInteger parse(@Nonnull Parameters p, @Nullable Generic previousSumElement) throws ParseException {
int pos0 = p.getPosition().intValue();
int pos0 = p.position.intValue();
final NumeralBase nb = NumeralBaseParser.parser.parse(p, previousSumElement);
@ -25,7 +25,7 @@ public class JsclIntegerParser implements Parser<JsclInteger> {
try {
result.append(new Digits(nb).parse(p, previousSumElement));
} catch (ParseException e) {
p.getPosition().setValue(pos0);
p.position.setValue(pos0);
throw e;
}
@ -33,7 +33,7 @@ public class JsclIntegerParser implements Parser<JsclInteger> {
try {
return nb.toJsclInteger(number);
} catch (NumberFormatException e) {
throw new ParseException(Messages.msg_8, p.getPosition().intValue(), p.getExpression(), number);
throw new ParseException(Messages.msg_8, p.position.intValue(), p.expression, number);
}
}
}

View File

@ -17,7 +17,7 @@ public class MatrixParser implements Parser<Matrix> {
}
public Matrix parse(@Nonnull Parameters p, Generic previousSumElement) throws ParseException {
int pos0 = p.getPosition().intValue();
int pos0 = p.position.intValue();
final List<Generic> vectors = new ArrayList<Generic>();
@ -26,7 +26,7 @@ public class MatrixParser implements Parser<Matrix> {
try {
vectors.add(VectorParser.parser.parse(p, previousSumElement));
} catch (ParseException e) {
p.getPosition().setValue(pos0);
p.position.setValue(pos0);
throw e;
}

View File

@ -21,16 +21,16 @@ class MinusParser implements Parser<MinusParser.Result> {
public Result parse(@Nonnull Parameters p, @Nullable Generic previousSumElement) {
final boolean result;
int pos0 = p.getPosition().intValue();
int pos0 = p.position.intValue();
ParserUtils.skipWhitespaces(p);
if (p.getPosition().intValue() < p.getExpression().length() && p.getExpression().charAt(p.getPosition().intValue()) == '-') {
if (p.position.intValue() < p.expression.length() && p.expression.charAt(p.position.intValue()) == '-') {
result = true;
p.getPosition().increment();
p.position.increment();
} else {
result = false;
p.getPosition().setValue(pos0);
p.position.setValue(pos0);
}
return new Result(result);

View File

@ -23,11 +23,11 @@ class MultiplyOrDivideFactor implements Parser<Generic> {
}
public Generic parse(@Nonnull Parameters p, Generic previousSumElement) throws ParseException {
int pos0 = p.getPosition().intValue();
int pos0 = p.position.intValue();
ParserUtils.skipWhitespaces(p);
if (p.getPosition().intValue() < p.getExpression().length() && p.getExpression().charAt(p.getPosition().intValue()) == (multiplication ? '*' : '/')) {
p.getPosition().increment();
if (p.position.intValue() < p.expression.length() && p.expression.charAt(p.position.intValue()) == (multiplication ? '*' : '/')) {
p.position.increment();
} else {
ParserUtils.throwParseException(p, pos0, Messages.msg_10, '*', '/');
}

View File

@ -14,9 +14,9 @@ public class NumeralBaseParser implements Parser<NumeralBase> {
}
public NumeralBase parse(@Nonnull Parameters p, @Nullable Generic previousSumElement) {
int pos0 = p.getPosition().intValue();
int pos0 = p.position.intValue();
NumeralBase result = p.getMathContext().getNumeralBase();
NumeralBase result = p.context.getNumeralBase();
ParserUtils.skipWhitespaces(p);

View File

@ -21,7 +21,7 @@ public class OperatorParser implements Parser<Operator> {
@Nonnull
public Operator parse(@Nonnull Parameters p, Generic previousSumElement) throws ParseException {
int pos0 = p.getPosition().intValue();
int pos0 = p.position.intValue();
final String operatorName = Identifier.parser.parse(p, previousSumElement);
if (!valid(operatorName)) {

View File

@ -22,7 +22,7 @@ public class ParameterListParser implements Parser<Generic[]> {
@Nonnull
public Generic[] parse(@Nonnull Parameters p, Generic previousSumElement) throws ParseException {
int pos0 = p.getPosition().intValue();
int pos0 = p.position.intValue();
final List<Generic> result = new ArrayList<Generic>();
@ -32,7 +32,7 @@ public class ParameterListParser implements Parser<Generic[]> {
result.add(ExpressionParser.parser.parse(p, previousSumElement));
} catch (ParseException e) {
if (minNumberOfParameters > 0) {
p.getPosition().setValue(pos0);
p.position.setValue(pos0);
throw e;
}
}

View File

@ -6,7 +6,6 @@ import jscl.math.Generic;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
/**
@ -26,29 +25,29 @@ public interface Parser<T> {
*/
T parse(@Nonnull Parameters p, @Nullable Generic previousSumElement) throws ParseException;
static class Parameters {
class Parameters {
@Nonnull
private final String expression;
public final String expression;
@Nonnull
private final MutableInt position;
public final MutableInt position;
@Nonnull
private final List<ParseException> exceptions = new ArrayList<ParseException>();
public final List<ParseException> exceptions = new ArrayList<ParseException>();
@Nonnull
private final MathContext mathContext;
public final MathContext context;
/**
* @param expression expression to be parsed
* @param position current position of expression. Side effect: if parsing is successful this parameter should be increased on the number of parsed letters (incl whitespaces etc)
* @param mathContext math engine to be used in parsing
* @param context math engine to be used in parsing
*/
Parameters(@Nonnull String expression, @Nonnull MutableInt position, @Nonnull MathContext mathContext) {
Parameters(@Nonnull String expression, @Nonnull MutableInt position, @Nonnull MathContext context) {
this.expression = expression;
this.position = position;
this.mathContext = mathContext;
this.context = context;
}
@Nonnull
@ -56,30 +55,10 @@ public interface Parser<T> {
return new Parameters(expression, position, mathEngine);
}
@Nonnull
public String getExpression() {
return expression;
}
@Nonnull
public MutableInt getPosition() {
return position;
}
public void addException(@Nonnull ParseException e) {
if (!exceptions.contains(e)) {
exceptions.add(e);
}
}
@Nonnull
public MathContext getMathContext() {
return mathContext;
}
@Nonnull
public List<ParseException> getExceptions() {
return Collections.unmodifiableList(exceptions);
}
}
}

View File

@ -21,8 +21,8 @@ public class ParserUtils {
}
public static void skipWhitespaces(@Nonnull Parser.Parameters p) {
final MutableInt position = p.getPosition();
final String expression = p.getExpression();
final MutableInt position = p.position;
final String expression = p.expression;
while (position.intValue() < expression.length() && Character.isWhitespace(expression.charAt(position.intValue()))) {
position.increment();
@ -34,10 +34,10 @@ public class ParserUtils {
char ch) throws ParseException {
skipWhitespaces(p);
if (p.getPosition().intValue() < p.getExpression().length()) {
char actual = p.getExpression().charAt(p.getPosition().intValue());
if (p.position.intValue() < p.expression.length()) {
char actual = p.expression.charAt(p.position.intValue());
if (actual == ch) {
p.getPosition().increment();
p.position.increment();
} else {
throwParseException(p, pos0, Messages.msg_12, ch);
}
@ -51,9 +51,9 @@ public class ParserUtils {
@Nonnull String s) throws ParseException {
skipWhitespaces(p);
if (p.getPosition().intValue() < p.getExpression().length()) {
if (p.getExpression().startsWith(s, p.getPosition().intValue())) {
p.getPosition().add(s.length());
if (p.position.intValue() < p.expression.length()) {
if (p.expression.startsWith(s, p.position.intValue())) {
p.position.add(s.length());
} else {
throwParseException(p, pos0, Messages.msg_11, s);
}
@ -66,8 +66,8 @@ public class ParserUtils {
int pos0,
@Nonnull String messageId,
Object... parameters) throws ParseException {
final MutableInt position = p.getPosition();
final ParseException parseException = new ParseException(messageId, position.intValue(), p.getExpression(), parameters);
final MutableInt position = p.position;
final ParseException parseException = new ParseException(messageId, position.intValue(), p.expression, parameters);
position.setValue(pos0);
throw parseException;
}
@ -83,7 +83,7 @@ public class ParserUtils {
try {
result = parser.parse(p, previousSumParser);
} catch (ParseException e) {
p.getPosition().setValue(initialPosition);
p.position.setValue(initialPosition);
throw e;
}

View File

@ -18,14 +18,14 @@ class PlusOrMinusTerm implements Parser<Generic> {
}
public Generic parse(@Nonnull Parameters p, Generic previousSumElement) throws ParseException {
int pos0 = p.getPosition().intValue();
int pos0 = p.position.intValue();
ParserUtils.skipWhitespaces(p);
boolean sign = false;
if (p.getPosition().intValue() < p.getExpression().length() && (p.getExpression().charAt(p.getPosition().intValue()) == '+' || p.getExpression().charAt(p.getPosition().intValue()) == '-')) {
sign = p.getExpression().charAt(p.getPosition().intValue()) == '-';
p.getPosition().increment();
if (p.position.intValue() < p.expression.length() && (p.expression.charAt(p.position.intValue()) == '+' || p.expression.charAt(p.position.intValue()) == '-')) {
sign = p.expression.charAt(p.position.intValue()) == '-';
p.position.increment();
} else {
ParserUtils.throwParseException(p, pos0, Messages.msg_10, '+', '-');
}

View File

@ -20,17 +20,17 @@ public class PostfixFunctionParser implements Parser<PostfixFunctionParser.Resul
@Nonnull
public Result parse(@Nonnull Parameters p, Generic previousSumElement) throws ParseException {
int pos0 = p.getPosition().intValue();
int pos0 = p.position.intValue();
final boolean postfixFunction;
ParserUtils.skipWhitespaces(p);
if (p.getPosition().intValue() < p.getExpression().length() && p.getExpression().startsWith(postfixFunctionName, p.getPosition().intValue())) {
p.getPosition().add(postfixFunctionName.length());
if (p.position.intValue() < p.expression.length() && p.expression.startsWith(postfixFunctionName, p.position.intValue())) {
p.position.add(postfixFunctionName.length());
postfixFunction = true;
} else {
p.getPosition().setValue(pos0);
p.position.setValue(pos0);
postfixFunction = false;
}

View File

@ -44,9 +44,9 @@ public class PostfixFunctionsParser implements Parser<Generic> {
if (postfixFunction == null) {
if (TripleFactorial.NAME.equals(postfixResult.getPostfixFunctionName())) {
throw new ParseException(Messages.msg_18, parseParameters.getPosition().intValue(), parseParameters.getExpression());
throw new ParseException(Messages.msg_18, parseParameters.position.intValue(), parseParameters.expression);
} else {
throw new ParseException(Messages.msg_4, parseParameters.getPosition().intValue(), parseParameters.getExpression(), postfixResult.getPostfixFunctionName());
throw new ParseException(Messages.msg_4, parseParameters.position.intValue(), parseParameters.expression, postfixResult.getPostfixFunctionName());
}
}

View File

@ -18,12 +18,12 @@ class PowerExponentParser implements Parser<Generic> {
}
public Generic parse(@Nonnull Parameters p, @Nullable Generic previousSumElement) throws ParseException {
int pos0 = p.getPosition().intValue();
int pos0 = p.position.intValue();
try {
PowerParser.parser.parse(p, previousSumElement);
} catch (ParseException e) {
p.getPosition().setValue(pos0);
p.position.setValue(pos0);
throw e;
}
@ -31,7 +31,7 @@ class PowerExponentParser implements Parser<Generic> {
try {
result = ExponentParser.parser.parse(p, previousSumElement);
} catch (ParseException e) {
p.getPosition().setValue(pos0);
p.position.setValue(pos0);
throw e;
}

View File

@ -20,16 +20,16 @@ class PowerParser implements Parser<Void> {
@Nullable
public Void parse(@Nonnull Parameters p, Generic previousSumElement) throws ParseException {
int pos0 = p.getPosition().intValue();
int pos0 = p.position.intValue();
ParserUtils.skipWhitespaces(p);
if (p.getPosition().intValue() < p.getExpression().length() && p.getExpression().charAt(p.getPosition().intValue()) == '^') {
p.getPosition().increment();
if (p.position.intValue() < p.expression.length() && p.expression.charAt(p.position.intValue()) == '^') {
p.position.increment();
} else {
if (isDoubleStar(p.getExpression(), p.getPosition())) {
p.getPosition().increment();
p.getPosition().increment();
if (isDoubleStar(p.expression, p.position)) {
p.position.increment();
p.position.increment();
} else {
ParserUtils.throwParseException(p, pos0, Messages.msg_10, '^', "**");
}

View File

@ -14,21 +14,21 @@ public class PrimeCharacters implements Parser<Integer> {
public Integer parse(@Nonnull Parameters p, @Nullable Generic previousSumElement) throws ParseException {
int pos0 = p.getPosition().intValue();
int pos0 = p.position.intValue();
int result = 0;
ParserUtils.skipWhitespaces(p);
if (p.getPosition().intValue() < p.getExpression().length() && p.getExpression().charAt(p.getPosition().intValue()) == '\'') {
p.getPosition().increment();
if (p.position.intValue() < p.expression.length() && p.expression.charAt(p.position.intValue()) == '\'') {
p.position.increment();
result = 1;
} else {
ParserUtils.throwParseException(p, pos0, Messages.msg_12, '\'');
}
while (p.getPosition().intValue() < p.getExpression().length() && p.getExpression().charAt(p.getPosition().intValue()) == '\'') {
p.getPosition().increment();
while (p.position.intValue() < p.expression.length() && p.expression.charAt(p.position.intValue()) == '\'') {
p.position.increment();
result++;
}

View File

@ -14,7 +14,7 @@ public class RootParser implements Parser<Function> {
}
public Function parse(@Nonnull Parameters p, Generic previousSumElement) throws ParseException {
int pos0 = p.getPosition().intValue();
int pos0 = p.position.intValue();
final String name = Identifier.parser.parse(p, previousSumElement);
if (name.compareTo("root") != 0) {

View File

@ -13,7 +13,7 @@ public class Subscript implements Parser<Generic> {
}
public Generic parse(@Nonnull Parameters p, @Nullable Generic previousSumElement) throws ParseException {
int pos0 = p.getPosition().intValue();
int pos0 = p.position.intValue();
ParserUtils.tryToParse(p, pos0, '[');
@ -21,7 +21,7 @@ public class Subscript implements Parser<Generic> {
try {
a = ExpressionParser.parser.parse(p, previousSumElement);
} catch (ParseException e) {
p.getPosition().setValue(pos0);
p.position.setValue(pos0);
throw e;
}

View File

@ -28,7 +28,7 @@ class UsualFunctionParser implements Parser<Function> {
}
public Function parse(@Nonnull Parameters p, Generic previousSumElement) throws ParseException {
int pos0 = p.getPosition().intValue();
int pos0 = p.position.intValue();
final String name = Identifier.parser.parse(p, previousSumElement);

View File

@ -16,7 +16,7 @@ public class VectorParser implements Parser<JsclVector> {
}
public JsclVector parse(@Nonnull Parameters p, Generic previousSumElement) throws ParseException {
int pos0 = p.getPosition().intValue();
int pos0 = p.position.intValue();
ParserUtils.skipWhitespaces(p);
@ -26,7 +26,7 @@ public class VectorParser implements Parser<JsclVector> {
try {
result.add(ExpressionParser.parser.parse(p, previousSumElement));
} catch (ParseException e) {
p.getPosition().setValue(pos0);
p.position.setValue(pos0);
throw e;
}