|
|
Re: Parsing a portion of the model [message #723166 is a reply to message #723152] |
Wed, 07 September 2011 21:12 |
drew frantz Messages: 340 Registered: July 2009 |
Senior Member |
|
|
Based on what I see in PartialParser (which is a 2.0 class, I am still using
1.x). I just tried doing this in 1.x by doing the following experiments in
1.x.
Experiment 1: Cast to IAntlrParser gets me the correct rootAstElement
Result: Get back a valid rootAstElement that has most of what I need, but
leaves the references null inside the child elements. (Essentially the same
behavior I already had).
EObject existingItemInModel = theItem;
XtextResource xResource = (XtextResource )existingItemInModel.eResource();
IAntrlParser theParser = (IAntrlParser )xResource.getParser();
IParseResult res = theParser.parse(theRule, new
StringInputStream(expression));
Experiment 2: Just use IParser
Result: this nulls out the rootAstElement, and just has a rootNode which I
would need to somehow translate into EMF elements,
EObject existingItemInModel = theItem;
XtextResource xResource = (XtextResource )existingItemInModel.eResource();
IParser theParser = xResource.getParser();
IParseResult res = theParser.parse(new StringInputStream(expression));
"Sebastian Zarnekow" <Sebastian.Zarnekow@itemis.de> wrote in message
news:j48igr$tmq$1@news.eclipse.org...
> Hi Drew,
>
> please have a look at
> org.eclipse.xtext.ui.codetemplates.ui.projectedEditing.PartialParser.assignRootRule(XtextResource,
> ParserRule)
>
> Regards,
> Sebastian
> --
> Need professional support for Eclipse Modeling?
> Go visit: http://xtext.itemis.com
>
> On 07.09.11 18:46, Drew wrote:
>> I am trying to parse a single statement of my grammar and upon doing so
>> with the code below the elements of the rule that are references are
>> null. I am sure I am missing something because in order to resolve
>> references I must need to pass those statements containing the referred
>> to elements to the parser , but I am not clear on how to accomplish this.
>>
>> Everything works as expected below except that any grammar rules that
>> contain references are null. Anyone have a suggestion on how to parse a
>> portion of a model that contains references?
>>
>> IParseResult getParsedResult(String theRule, String expression)
>> {
>>
>> IParseResult res = myAntlrParser.parse(theRule, new
>> StringInputStream(expression));
>> return res;
>> }
>
>
|
|
|
Powered by
FUDForum. Page generated in 0.02943 seconds