Help with expressions, pretty please? [message #755884] |
Wed, 09 November 2011 20:33  |
Eclipse User |
|
|
|
Greetings,
I apologize in advance for the length of this question 
I've struggling for a couple of days trying to figure out how to add expressions to the protobuf-dt grammar. I read Sven's post on expressions and it was great! I think I understood it. The problem is that I don't know how to apply what I learned.
What I'm trying to accomplish is something called "message notation" in protocol buffer grammar. For example:
option (abc) = 3;
option (spanner.database_options) = {
acls: {
owner: "chubby!*"
admin: "chubby!*"
field_acls: {
reader: "chubby!*"
writer: "chubby!*"
}
}
};
whose grammar can be defined as (this doesn't work in Xtext, but it is the simplest way to describe it)
ValueRef:
MessageNotation | SimpleRef;
// { foo: 1, bar: 2 }
MessageNotation:
'{'
fields+=FieldNotation ((',')? fields+=FieldNotation)*
'}'
;
FieldNotation:
name=Name ':' value=SimpleRef;
SimpleRef:
LiteralRef | BooleanRef | NumberRef | StringRef;
The value of an option can be a simple value (SimpleRef) or message notation (MessageNotation). MessageNotation has fields, and the value of each field can be a SimpleRef or another MessageNotation.
I have tried everything I could image, and nothing. Whatever I try fails when I generate Java code from the grammar.
Any help will be greatly, greatly, greatly appreciated! 
Many thanks in advance,
-Alex
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.19272 seconds