Skip to main content



      Home
Home » Modeling » TMF (Xtext) » Testing: Different start symbol for parsing
Testing: Different start symbol for parsing [message #1795899] Tue, 02 October 2018 03:04
Eclipse UserFriend
Hello,

I am looking for a way to change the start symbol for parsing in unit tests.

Example Pseudo-Grammar:
Model:   
  list+=AbstractNode*;
AbstractNode:  
  NodeA | NodeB;

NodeA:
 attr1=Timeframe
 attr2=SomeNode;

NodeB: 
 attr1=Timeframe
 attr2=SomeOtherNode;

Timeframe:
  "[" startDate=Date  ":"  endDate=Date "]";


I want to test my "Timeframe" directly without having to start from the Model.

Example Test (broken )
 ...
 @Inject extension ParseHelper<Timeframe>
 @Test 
 def void myBrokenTest(){ 
     val timeframe = '''[10.10.2018:11.10.2018]'''.parse
     AssertSomething("...",timeframe.startDate)
 }


Error: My val timeframe is null.

If this could work somehow I would appreciate code samples
but I'm also happy for alternative solutions that allow me to test
single symbols without having to hardcode everything above it (coming
from the model).

Thank you :)
Previous Topic:Parsing in-memory codes with crossrefs between resources in RCP application
Next Topic:Is it possible to write ValueConverter for EClass elements?
Goto Forum:
  


Current Time: Fri Jun 20 04:27:46 EDT 2025

Powered by FUDForum. Page generated in 0.21718 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top