Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » problem with string rule and double quote rule
problem with string rule and double quote rule [message #900500] Tue, 07 August 2012 06:10 Go to previous message
Laigle jérôme is currently offline Laigle jérôme
Messages: 26
Registered: August 2012
Junior Member
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
 
Read Message
Read Message
Read Message
Previous Topic:How does the Serializer work? Reg. NFA + NodeModel
Next Topic:Rename/Move Resource refactoring for importURI-style includes
Goto Forum:
  


Current Time: Sun May 26 03:24:12 EDT 2013

Powered by FUDForum. Page generated in 0.01668 seconds