Skip to content
Snippets Groups Projects
Commit 660dadfa authored by stepan's avatar stepan
Browse files

Parser: hex float literals without decimal point (e.g. 0x0p0)

parent ba3fcfb7
No related branches found
No related tags found
No related merge requests found
......@@ -86,6 +86,7 @@ public class ParserGeneration {
"remove deprecated calls to Source functions",
"remove restricion on fixed number of digits in UTF codes",
"support ? for help",
"support for hex float literals"
"support for hex float literals",
"support for hex float literals without decimal point: 0x0p0",
};
}
......@@ -575,13 +575,13 @@ INTEGER
COMPLEX
: ('0'..'9')+ '.' ('0'..'9')* EXPONENT? 'i' { setText(getText().substring(0, getText().length()-1)); }
| '.'? ('0'..'9')+ EXPONENT? 'i' { setText(getText().substring(0, getText().length()-1)); }
| '0x' HEX_DIGIT+ ('.' HEX_DIGIT* HEX_EXPONENT)? 'i' { setText(getText().substring(0, getText().length()-1)); }
| '0x' HEX_DIGIT+ ('.'? HEX_DIGIT* HEX_EXPONENT)? 'i' { setText(getText().substring(0, getText().length()-1)); }
;
DOUBLE
: ('0'..'9')+ '.' ('0'..'9')* EXPONENT?
| '.'? ('0'..'9')+ EXPONENT?
| '0x' HEX_DIGIT+ ('.' HEX_DIGIT* HEX_EXPONENT)?
| '0x' HEX_DIGIT+ ('.'? HEX_DIGIT* HEX_EXPONENT)?
;
DD : '..' ('0'..'9')+ ;
......
......@@ -54,6 +54,8 @@ public class TestParser extends TestBase {
@Test
public void testDoubleLiterals() {
assertEval("0x1.1p2");
assertEval("0x1p2");
assertEval("0x0p0");
assertEval("0x1.aP2");
assertEval("0xa.p2");
assertEval("0xa.bp1i");
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment