File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 150150 (Type ('TRUE' ), transform .true2True ),
151151 (Type ('IDENT' ), transform .keywordSafeIdent ),
152152
153+ (Type ('DECIMAL_LITERAL' ), transform .syntaxSafeDecimalLiteral ),
153154 (Type ('FLOATING_POINT_LITERAL' ), transform .syntaxSafeFloatLiteral ),
154155
155156 (Type ('TYPE' ) > Type ('BOOLEAN' ), transform .typeSub ),
Original file line number Diff line number Diff line change @@ -48,15 +48,21 @@ def xform(node, config):
4848true2True = makeConst ('True' )
4949
5050
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+
5159def syntaxSafeFloatLiteral (node , config ):
5260 """ Ensures a Java float literal is a valid Python float literal. """
5361 value = node .token .text
5462 if value .startswith ('.' ):
5563 value = '0' + value
5664 if value .lower ().endswith (('f' , 'd' )):
5765 value = value [:- 1 ]
58- elif value .endswith (('l' , 'L' )):
59- value = value [:- 1 ] + 'L'
6066 node .token .text = value
6167
6268
You can’t perform that action at this time.
0 commit comments