problem with string rule and double quote rule [message #900500] |
Tue, 07 August 2012 06:10  |
Eclipse User |
|
|
|
Hi,
I'm working on a DSL and i have a problem on the rule
It's just a part of my dsl:
Program:
'program' name=DoubleQuoteID
Value=STRING
'end'
;
DoubleQuoteID:
('"'ID'"')
;
terminal ID : ('a'..'z'|'A'..'Z') ('a'..'z'|'A'..'Z'|'0'..'9')*;
terminal STRING :
'"' ( '\\' ('b'|'t'|'n'|'f'|'r'|'u'|'"'|"'"|'\\') | !('\\'|'"') )* '"' |
"'" ( '\\' ('b'|'t'|'n'|'f'|'r'|'u'|'"'|"'"|'\\') | !('\\'|"'") )* "'"
;
terminal SL_COMMENT : (';') !('\n'|'\r')* ('\r'? '\n')?;
terminal WS : (' '|'\t'|'\r'|'\n')+;
I use to in parallel Xtend for realise junit test
My test :
class test{
@Inject extension ParseHelper<Program>
@Test def void testBadProgramDeclaration() {
val program =
'''
program toto
"abc"
end
'''.parse
Assert::assertNotNull(program)
Assert::assertEquals("toto",program.name)//test pass but it shouldn't pass
Assert::assertEquals("abc",program.value)
}
@Test def void testGoodProgramDeclaration() {
val program =
'''
program "toto"
"abc"
end
'''.parse
Assert::assertNotNull(program)
Assert::assertEquals("toto",program.name)// FAILED ==> expected:<toto> but was:<null>
Assert::assertEquals("abc",program.value)
}
}
I have a problem with the rule DoubleQuoteID because Double quote are obligatory but it's not define obligatory
I can't create a terminal for DoubledQuoteID because it create conflict with String rule
I don't know how i can do it
I'm new to Xtext and so this question might be quite stupid. Maybe somebody has an idea or can point me into the right direction? Thanks in advance!
Best regards,
Jérôme
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.02964 seconds