|
|
Re: Looking for antlr+emf samples [message #417377 is a reply to message #417368] |
Thu, 06 March 2008 23:43 |
Jim Steel Messages: 54 Registered: July 2009 |
Member |
|
|
One of the catches with this is that it can be hard to build the model
completely at parse-time. Often you need to go back and make one (or
more) passes to link up, for example, uses to definitions, etc. So an
alternative is to parse the text into some intermediate object model,
then make a visitor or something and go back and link it up.
I believe the Kermeta guys (www.kermeta.org) used Emfatic (and about a
half dozen post-parse linking passes!) to build their parser, and they
have a reasonably big metamodel, and pretty big models, and as far as I
know, Emfatic hasn't caused them any scalability or expressiveness
problems. I'm sure they'd be happy to respond to questions about it.
Tefkat (http://tefkat.sourceforge.net) builds its models using an antlr
grammar. Its probably not a great example to start with, since its not
small (the .g file is 2500 lines long!), and the metamodel may not be
the most accessible (its not a library metamodel :), so the code is
there if you really want to look at it.
Jim.
Sven Efftinge wrote:
> Hi Felix,
>
> basically you have to create the model using Antlr actions.
> Here is an example of how ugly such grammar code looks like:
>
> ruleXtendFile returns [XtendFile r]
> @init{
> $r = factory.createXtendFile();
> }
> :
> (i=ruleImport {$r.getImports().add(i);})*
> (c=ruleConcept {$r.getConcepts().add(i);})*
> ;
>
> regards,
> Sven
>
>
> Felix Dorner wrote:
>> Hey,
>>
>> I look for _basic_ examples how to specify an antlr grammar where the
>> generated parser creates an emf model instance. I know that Emfatic
>> and XText actually generate such grammar specs to avoid specifying
>> such grammars manually. But I don't know if they're powerful enough,
>> so I want to get my hands dirty... Before Installing one of those to
>> see how the generated grammars look like, I'd like to ask if someone
>> has a _basic_ hand-written example? I also thought of the OCL
>> Component but they don't use antlr...
>>
>> Felix
>>
>>
|
|
|
|
Powered by
FUDForum. Page generated in 0.02987 seconds