diff --git a/core/src/main/java/org/nwapw/abacus/parsing/LexerTokenizer.java b/core/src/main/java/org/nwapw/abacus/parsing/LexerTokenizer.java index 790882a..b7bdd1f 100644 --- a/core/src/main/java/org/nwapw/abacus/parsing/LexerTokenizer.java +++ b/core/src/main/java/org/nwapw/abacus/parsing/LexerTokenizer.java @@ -34,6 +34,7 @@ public class LexerTokenizer implements Tokenizer>, PluginListen register(" ", TokenType.WHITESPACE); register(",", TokenType.COMMA); register("[0-9]*(\\.[0-9]+)?", TokenType.NUM); + register("[a-zA-Z]+", TokenType.VARIABLE); register("\\(", TokenType.OPEN_PARENTH); register("\\)", TokenType.CLOSE_PARENTH); }}; diff --git a/core/src/main/java/org/nwapw/abacus/parsing/ShuntingYardParser.java b/core/src/main/java/org/nwapw/abacus/parsing/ShuntingYardParser.java index c7a5615..af9936b 100644 --- a/core/src/main/java/org/nwapw/abacus/parsing/ShuntingYardParser.java +++ b/core/src/main/java/org/nwapw/abacus/parsing/ShuntingYardParser.java @@ -61,7 +61,7 @@ public class ShuntingYardParser implements Parser>, PluginListe Match match = from.remove(0); previousType = matchType; matchType = match.getType(); - if (matchType == TokenType.NUM) { + if (matchType == TokenType.NUM || matchType == TokenType.VARIABLE) { output.add(match); } else if (matchType == TokenType.FUNCTION) { output.add(new Match<>("", TokenType.INTERNAL_FUNCTION_END)); @@ -144,6 +144,8 @@ public class ShuntingYardParser implements Parser>, PluginListe } } else if (matchType == TokenType.NUM) { return new NumberNode(abacus.numberFromString(match.getContent())); + } else if (matchType == TokenType.VARIABLE) { + return new VariableNode(match.getContent()); } else if (matchType == TokenType.FUNCTION) { String functionName = match.getContent(); FunctionNode node = new FunctionNode(functionName);