mirror of
https://github.com/DanilaFe/abacus
synced 2024-12-23 07:50:09 -08:00
Change the constructor for NumberNode
This commit is contained in:
parent
9e3b550a15
commit
eac4ce8600
|
@ -22,19 +22,10 @@ public class NumberNode extends TreeNode {
|
|||
|
||||
/**
|
||||
* Creates a new number node with the given double value.
|
||||
* @param value the value to use.
|
||||
* @param newNumber the number for which to create a number node.
|
||||
*/
|
||||
public NumberNode(double value){
|
||||
number = new NaiveNumber(value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new number node with the given string value, converted
|
||||
* to a double.
|
||||
* @param value the value.
|
||||
*/
|
||||
public NumberNode(String value){
|
||||
this(Double.parseDouble(value));
|
||||
public NumberNode(NumberInterface newNumber){
|
||||
this.number = newNumber;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -5,6 +5,8 @@ import org.nwapw.abacus.function.OperatorType;
|
|||
import org.nwapw.abacus.lexing.Lexer;
|
||||
import org.nwapw.abacus.lexing.pattern.Match;
|
||||
import org.nwapw.abacus.lexing.pattern.Pattern;
|
||||
import org.nwapw.abacus.number.NaiveNumber;
|
||||
import org.nwapw.abacus.number.PreciseNumber;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
|
@ -170,7 +172,7 @@ public class TreeBuilder {
|
|||
else return new UnaryPrefixNode(operator, applyTo);
|
||||
}
|
||||
} else if(matchType == TokenType.NUM){
|
||||
return new NumberNode(Double.parseDouble(source.substring(match.getFrom(), match.getTo())));
|
||||
return new NumberNode(new NaiveNumber(Double.parseDouble(source.substring(match.getFrom(), match.getTo()))));
|
||||
} else if(matchType == TokenType.FUNCTION){
|
||||
String functionName = source.substring(match.getFrom(), match.getTo());
|
||||
FunctionNode node = new FunctionNode(functionName);
|
||||
|
|
Loading…
Reference in New Issue
Block a user