diff --git a/Krakatau/assembler/parse.py b/Krakatau/assembler/parse.py index 202c52fe..cbacd5e8 100644 --- a/Krakatau/assembler/parse.py +++ b/Krakatau/assembler/parse.py @@ -124,7 +124,7 @@ def eol(a): a.asserttype('NEWLINES'), a.consume() def _rawint(a): a.asserttype('INT_LITERAL') - return a.tok, ast.literal_eval(a.consume().val) + return a.tok, ast.literal_eval(a.consume().val.lstrip('+')) def boundedint(a, lower, upper): tok, x = a._rawint() @@ -170,7 +170,7 @@ def identifier(a): def intl(a): a.asserttype('INT_LITERAL') tok = a.consume() - x = ast.literal_eval(tok.val) + x = ast.literal_eval(tok.val.lstrip('+')) if not -1<<31 <= x < 1<<31: a.error('Value does not fit into int type.', tok) return x % (1 << 32) @@ -178,7 +178,7 @@ def intl(a): def longl(a): a.asserttype('LONG_LITERAL') tok = a.consume() - x = ast.literal_eval(tok.val) + x = ast.literal_eval(tok.val.lstrip('+')) if not -1 << 63 <= x < 1 << 63: a.error('Value does not fit into long type.', tok) return x % (1 << 64) diff --git a/tests/assembler/good/ldcs_plus.j b/tests/assembler/good/ldcs_plus.j new file mode 100644 index 00000000..e532b68e --- /dev/null +++ b/tests/assembler/good/ldcs_plus.j @@ -0,0 +1,39 @@ +.version +50 0x0 +.class public LdcTest +.super java/lang/Object + +.method public static print : (F)V + .code stack 910 locals 10 + ldc 0 + ldc -0 + ldc +0 + ldc +1 + ldc +0x1 + ldc -0x1 + ldc -10e1f + ldc +10e1f + ldc +0.0f + ldc -0.0f + ldc -0x80000000 + ldc -0x7FFFFFFF + ldc +0x7FFFFFFF + + ldc2_w 0L + ldc2_w -0L + ldc2_w +0L + ldc2_w +1L + ldc2_w +0x1L + ldc2_w -0x1L + ldc2_w -10e1 + ldc2_w +10e1 + ldc2_w +0.0 + ldc2_w -0.0 + ldc2_w -0x8000000000000000L + ldc2_w -0x7FFFFFFFffffffffL + ldc2_w +0x7FFFFFFFffffffffL + + + return + .end code +.end method +.end class \ No newline at end of file