| Summary: | Validation of Real literals delivers wrong results | ||||||
|---|---|---|---|---|---|---|---|
| Product: | [Modeling] M2T | Reporter: | Jochen Schmich <jochen.schmich> | ||||
| Component: | Xpand | Assignee: | Karsten Thoms <karsten.thoms> | ||||
| Status: | CLOSED FIXED | QA Contact: | |||||
| Severity: | normal | ||||||
| Priority: | P3 | CC: | sebastian.zarnekow | ||||
| Version: | unspecified | ||||||
| Target Milestone: | --- | ||||||
| Hardware: | PC | ||||||
| OS: | Windows Vista | ||||||
| Whiteboard: | |||||||
| Attachments: |
|
||||||
|
Description
Jochen Schmich
Created attachment 202033 [details]
Reproducing Xpand Project
The Lexer rule "IntValue" accepts only a single "0" or "1..9" followed by other digits.
IntLiteral : ('0' | '1'..'9' '0'..'9'*) ;
I think the reason was that no integer values with leading zeros should be allowed.
================================================================
numberLiteral returns [Expression e] :
a=IntLiteral {$e=factory.createIntegerLiteral(id(a));}
| a=IntLiteral b='.' c=IntLiteral {$e=factory.createRealLiteral(id(a).append(id(b)).append(id(c)));}
;
================================================================
Changing the IntValue to
IntLiteral : '0'..'9'+ ;
would solve the issue, but also allow leading zeros.
I think leading zeros are ok and they won't break existing templates. Sebastian, thanks for your input. I also think this is reasonable, but wanted a second thought. I'll fix that now. Thanks from my side, too - nice work Changed the definition of IntLiteral in Xpand.g and Xtend.g.
In Xpand.g I had to comment out
--------------------------------------------
fragment
VOCAB :
('\3'..'\u00aa'|'\u00ac'..'\u00ba'|'\u00bc'..'\ufffe')
;
--------------------------------------------
AntlWorks refused to generate the parser with the error message:
Xpand.g:469:3: syntax error: antlr: Xpand.g:469:3: unexpected token: '\3'
Added unit tests:
- StatementParserTest#testReal
- ExtensionParserTest#testReal
Bug resolved before Xpand 1.2 release date => Closing |