[Xtext 2.0] How to loose up member order in grammar [message #668738] |
Fri, 06 May 2011 22:15 |
Alex Ruiz Messages: 103 Registered: March 2011 |
Senior Member |
|
|
Greetings,
I'm working on a protocol buffer editor for Eclipse using Xtext 2.0. Here is the relevant part of the grammar:
import "http://www.eclipse.org/emf/2002/Ecore" as ecore
generate protobuf "http://www.google.com/eclipse/protobuf/Protobuf"
Protobuf:
(syntax=Syntax)?
(package=Package)?
(imports+=Import)*
(options+=Option)*
(elements+=ProtobufElement)*;
Syntax:
'syntax' '=' name=STRING ';';
Package:
'package' name=QualifiedName ';';
Import:
'import' importURI=STRING ';';
QualifiedName:
ID ('.' ID)*;
Option:
'option' name=ID '=' value=ValueRef ';';
ProtobufElement:
Type | ExtendMessage | Service;
In the editor, I must specify "package" as the first element, then "imports" and "options". If I specify "options" before "imports" Xtext shows syntax errors.
It turns out that the protocol buffer compiler considers having imports before or after options as valid. How can I emulate this behavior in Xtext?
Many thanks in advance,
-Alex
|
|
|
Powered by
FUDForum. Page generated in 0.03619 seconds