diff options
| author | jantuomi <jans.tuomi@gmail.com> | 2016-07-28 15:25:19 +0300 |
|---|---|---|
| committer | jantuomi <jans.tuomi@gmail.com> | 2016-07-28 15:25:19 +0300 |
| commit | 8c48145314883caefc9b6a5daa6b5b7adacfa2e6 (patch) | |
| tree | 386c6b2d90310b337c0ba5ae10b6ea13561ecf2a /src | |
| parent | 4b415805f7b6b0ee7c03e69e1f34898dce554c82 (diff) | |
Add more line number information
Diffstat (limited to 'src')
4 files changed, 6 insertions, 8 deletions
diff --git a/src/main/com/jantuomi/tunkki/core/parser/ast/FunctionDefineNode.java b/src/main/com/jantuomi/tunkki/core/parser/ast/FunctionDefineNode.java index 9d9c33b..d8d6aa2 100644 --- a/src/main/com/jantuomi/tunkki/core/parser/ast/FunctionDefineNode.java +++ b/src/main/com/jantuomi/tunkki/core/parser/ast/FunctionDefineNode.java @@ -41,7 +41,7 @@ public class FunctionDefineNode extends VarargOperatorNode { } } catch (Exception ex) { - throw new TunkkiError(TunkkiError.ExceptionType.ExpectedTokenError, getLine(), getText()); + throw new TunkkiError(TunkkiError.ExceptionType.ExpectedDifferentTokenError, getLine(), getText()); } Function function = new Function(argumentNames, (BlockBodyNode) body); function.setName(name); diff --git a/src/main/com/jantuomi/tunkki/core/parser/ast/SymbolNode.java b/src/main/com/jantuomi/tunkki/core/parser/ast/SymbolNode.java index b4996e4..dc3a6e4 100644 --- a/src/main/com/jantuomi/tunkki/core/parser/ast/SymbolNode.java +++ b/src/main/com/jantuomi/tunkki/core/parser/ast/SymbolNode.java @@ -48,10 +48,8 @@ public class SymbolNode extends ASTNode { if (value != null) { paramValues.add(value); } - } - DataContainer returnValue; try { returnValue = State.getInstance().getSymbolValue(name, paramValues); diff --git a/src/main/com/jantuomi/tunkki/core/tokenizer/token/types/FunctionDefineToken.java b/src/main/com/jantuomi/tunkki/core/tokenizer/token/types/FunctionDefineToken.java index 1ea99b7..89b8fd4 100644 --- a/src/main/com/jantuomi/tunkki/core/tokenizer/token/types/FunctionDefineToken.java +++ b/src/main/com/jantuomi/tunkki/core/tokenizer/token/types/FunctionDefineToken.java @@ -21,7 +21,7 @@ public class FunctionDefineToken extends VarargOperatorToken { FunctionDefineNode node = new FunctionDefineNode(this); if (args.size() == 0) { - throw new TunkkiError(TunkkiError.ExceptionType.ExpectedTokenError, -1, getText(), getText()); + throw new TunkkiError(TunkkiError.ExceptionType.ExpectedDifferentTokenError, getLine(), getText()); } node.setName(args.get(0).getText()); @@ -37,7 +37,7 @@ public class FunctionDefineToken extends VarargOperatorToken { bodyNode = (BlockBodyNode) args.get(args.size() - 1).generateNode(); } catch (Exception ex) { - throw new TunkkiError(TunkkiError.ExceptionType.ExpectedTokenError, -1, getText()); + throw new TunkkiError(TunkkiError.ExceptionType.ExpectedDifferentTokenError, getLine(), getText()); } node.setBody(bodyNode); return node; diff --git a/src/main/com/jantuomi/tunkki/exception/TunkkiError.java b/src/main/com/jantuomi/tunkki/exception/TunkkiError.java index 1ffcad3..24431ba 100644 --- a/src/main/com/jantuomi/tunkki/exception/TunkkiError.java +++ b/src/main/com/jantuomi/tunkki/exception/TunkkiError.java @@ -16,7 +16,7 @@ public class TunkkiError extends Exception { SyntaxError, TypeError, FunctionArgumentError, - ExpectedTokenError, + ExpectedDifferentTokenError, UndeclaredSymbolError, IncludeError, GeneralError @@ -28,7 +28,7 @@ public class TunkkiError extends Exception { errorTexts.put(ExceptionType.IllegalTokenError, "Unknown or illegal token %s found."); errorTexts.put(ExceptionType.SyntaxError, "Unexpected %s."); errorTexts.put(ExceptionType.TypeError, "Incompatible types %s and %s."); - errorTexts.put(ExceptionType.ExpectedTokenError, "Token '%s' expects a different token stack."); + errorTexts.put(ExceptionType.ExpectedDifferentTokenError, "Token '%s' expects a different token stack."); errorTexts.put(ExceptionType.FunctionArgumentError, "The parameter list given to function %s is either of wrong length or the parameters are of wrong type. Actual: %s"); errorTexts.put(ExceptionType.UndeclaredSymbolError, "No symbol %s defined, parameters: [%s]."); errorTexts.put(ExceptionType.IncludeError, "File %s could not be included."); @@ -52,7 +52,7 @@ public class TunkkiError extends Exception { if (line == -1) { return "\n" + message; } else { - return String.format("\nline %d: ", line) + message; + return String.format("\nLine #%d: ", line) + message; } } |
