1
0
mirror of https://gitlab.com/camelot/kickc.git synced 2024-11-20 02:32:36 +00:00

Fixed error message when encountering non-integer number. Closes #286

This commit is contained in:
jespergravgaard 2019-08-25 14:38:44 +02:00
parent 0456279c94
commit 56b0026452
3 changed files with 8 additions and 6 deletions

View File

@ -1,5 +1,6 @@
package dk.camelot64.kickc;
import dk.camelot64.kickc.model.CompileError;
import dk.camelot64.kickc.model.types.SymbolType;
import dk.camelot64.kickc.model.values.ConstantInteger;
@ -10,7 +11,7 @@ public class NumberParser {
boolean isInt = !literal.contains(".");
if(!isInt) {
throw new NumberFormatException("Not Implemented: non-integer parsing. " + literal);
throw new NumberFormatException("Non-integer numbers are not supported. " + literal);
}
SymbolType type = SymbolType.NUMBER;

View File

@ -1678,7 +1678,11 @@ public class Pass0GenerateStatementSequence extends KickCParserBaseVisitor<Objec
@Override
public RValue visitExprNumber(KickCParser.ExprNumberContext ctx) {
return NumberParser.parseIntegerLiteral(ctx.getText());
try {
return NumberParser.parseIntegerLiteral(ctx.getText());
} catch(NumberFormatException e) {
throw new CompileError(e.getMessage(), new StatementSource(ctx));
}
}
/** The current string encoding used if no explicit encoding is specified. */

View File

@ -72,13 +72,10 @@ public class TestPrograms {
}
// TODO: Fix float error message https://gitlab.com/camelot/kickc/issues/286
/*
@Test
public void testFloatErrorMessage() throws IOException, URISyntaxException {
compileAndCompare("float-error-message");
assertError("float-error-message", "Non-integer numbers are not supported");
}
*/
@Test
public void testFunctionAsArray() throws IOException, URISyntaxException {