File tree Expand file tree Collapse file tree 2 files changed +9
-2
lines changed Expand file tree Collapse file tree 2 files changed +9
-2
lines changed Original file line number Diff line number Diff line change 150
150
(Type ('TRUE' ), transform .true2True ),
151
151
(Type ('IDENT' ), transform .keywordSafeIdent ),
152
152
153
+ (Type ('DECIMAL_LITERAL' ), transform .syntaxSafeDecimalLiteral ),
153
154
(Type ('FLOATING_POINT_LITERAL' ), transform .syntaxSafeFloatLiteral ),
154
155
155
156
(Type ('TYPE' ) > Type ('BOOLEAN' ), transform .typeSub ),
Original file line number Diff line number Diff line change @@ -48,15 +48,21 @@ def xform(node, config):
48
48
true2True = makeConst ('True' )
49
49
50
50
51
+ def syntaxSafeDecimalLiteral (node , config ):
52
+ """ Ensures a Java decimal literal is a valid Python decimal literal. """
53
+ value = node .token .text
54
+ if value .endswith (('l' , 'L' )):
55
+ value = value [:- 1 ]
56
+ node .token .text = value
57
+
58
+
51
59
def syntaxSafeFloatLiteral (node , config ):
52
60
""" Ensures a Java float literal is a valid Python float literal. """
53
61
value = node .token .text
54
62
if value .startswith ('.' ):
55
63
value = '0' + value
56
64
if value .lower ().endswith (('f' , 'd' )):
57
65
value = value [:- 1 ]
58
- elif value .endswith (('l' , 'L' )):
59
- value = value [:- 1 ] + 'L'
60
66
node .token .text = value
61
67
62
68
You can’t perform that action at this time.
0 commit comments