Use ANTLR grammar within Xtext [message #958257] |
Thu, 25 October 2012 22:04 |
Frank Schrank Messages: 4 Registered: October 2012 |
Junior Member |
|
|
Greetings!
A simple question in addition to my other thread: Can I somehow reuse an already existing ANTLR grammar within Xtext? (or do I have to define it anew with the Xtext grammar language?)
Here's an excerpt of what my grammar looks like:
...
fragment operationBlock
: deleteWorkspaceOperation
| ( (createWorkspaceOperation | selectWorkspaceOperation) dataOperation* )
;
fragment dataOperation
: assignOperation
| upsertOperation
;
//namespace
fragment namespaceDeclarationBlock
: defaultNamespaceDeclaration? namespaceDeclaration*
//-> defaultNamespaceDeclaration? namespaceDeclaration*
;
defaultNamespaceDeclaration
: DEFAULT NAMESPACE uri SEMI
-> ^(NAMESPACE uri)
;
...
Thank you,
best regards
[Updated on: Fri, 26 October 2012 18:02] Report message to a moderator
|
|
|
|
|
Re: Use ANTLR grammar within Xtext [message #959819 is a reply to message #959685] |
Sat, 27 October 2012 01:28 |
Henrik Lindberg Messages: 2509 Registered: July 2009 |
Senior Member |
|
|
On 2012-27-10 24:53, Frank Schrank wrote:
> Hello Henrik,
> and thank you for this information. Just to get this clear: So it is not
> possible, to simply take the ANTLR grammar I have and use it instead of
> translating it into a .text grammar?
> I think .xtext provides all the functionality I need, I just wanted to
> know, whether I could conveniently reuse the ANTLR grammar I already
> have before going through the effort of defining the language a second
> time.
>
Hi,
read my response again, my 'yes' was quite ambiguous.
so...
No, you can not reuse the ANTLR grammar.
You may be able to reuse some of the lexer rules.
There are good reasons for this - an ANTLR grammar allows you to do many
things that are not declarative and hence difficult (i.e. impossible) to
generate default implementations for.
Unless your grammar is terribly complex, it should not be that difficult
to re-implement.
Regards
- henrik
|
|
|
|
Powered by
FUDForum. Page generated in 0.02994 seconds