I think 'extensions' should be a message-level option, not its own
keyword. It's not a field or a declaration, it's just... an option.
In addition, options should use text format, because they're really
just setting values in descriptor.proto.
The descriptor would be
exposed through the object's name. So the example above would become:
proto ::= ( message | extend | enum | import | package | option |
";" )*
import ::= "import" strLit ";"
package ::= "package" ident ";"
option ::= "option" optionBody ";"
optionBody ::= ident ( "." ident )* "=" constant
message ::= "message" ident messageBody
extend ::= "extend" userType messageBody
enum ::= "enum" ident "{" ( option | enumField | ";" )* "}"
enumField ::= ident "=" intLit ";"
service ::= "service" ident "{" ( option | rpc | ";" )* "}"
rpc ::= "rpc" ident "(" userType ")" "returns" "(" userType ")" ";"
messageBody ::= "{" ( field | enum | message | extend | extensions |
group | option | ":" )* "}"
group ::= modifier "group" camelIdent "=" intLit messageBody
# tag number must be 2^28-1 or lower
field ::= modifier type ident "=" intLit ( "[" fieldOption ( ","
fieldOption )* "]" )? ";"
fieldOption ::= optionBody | "default" "=" constant
extensions ::= "extensions" intLit "to" ( intLit | "max" ) ";"
modifier ::= "required" | "optional" | "repeated"
type ::= "double" | "float" | "int32" | "int64" | "uint32" | "uint64"
| "sint32" | "sint64" | "fixed32" | "fixed64" | "sfixed32" |
"sfixed64"
| "bool" | "string" | "bytes" | userType
# leading dot for identifiers means they're fully qualified
userType ::= ( "."? ident )+
constant ::= ident | intLit | floatLit | strLit | boolLit
ident ::= /[A-Za-z_][\w_]*/
# according to parser.cc, group names must start with a capital letter
as a
# hack for backwards-compatibility
camelIdent ::= /[A-Z][\w_]*/
intLit ::= decInt | hexInt | octInt
decInt ::= /\d+/
hexInt ::= /0[xX]([A-Fa-f0-9])+/
octInt ::= /0[0-7]+/
floatLit ::= /\d+(\.\d+)?([Ee][\+-]?\d+)?/ # allow_f_after_float_ is
disabled by default in tokenizer.cc
boolLit ::= "true" | "false"
strLit ::= quote ( hexEscape | octEscape | charEscape | /[^\0\n]/ )*
quote
Okay, I checked the source, and you're right. But what if I want to
add a message to an already-defined message's namespace?
Looks like an error in src/google/protobuf/unittest.proto. Line 331
says 2^28-1, and that's what it's using for its test value. I checked,
and protoc barfs on 2^29, not 2^28, so unittest.proto needs to be
fixed. Shouldn't have trusted the documentation on that one.
Hey this is great, I am working on a lisp implementation of PB (oh ps,
I'm working on a common lisp implementation**) and I was hoping to get
my hands on some more specific specifications or BNF for the .proto
file language, but I was waiting until my implementation was a little
further before I started asking a lot of questions though.
since we're on the topic, question:
I'm assuming name spaces and package statements are always local to
the file they are in, and don't apply to imported files. ie. imported
files start in a clean namespace, and it's not the same as inlining
their contents into the current file. also import statements can only
occur at the top level in a file.
He didn't mean the top line, he meant the top *level*. As in, theycan't occur inside a message declaration.
Ok, although, in that case context can make it clear what is what. Sothen, just to be pedantic, it's a violation of style, but technically
allowed to have the following definitions (with different/conflicting
bodies).
message Foo { ... }
message FOO { ... }
message foo { ... }
ident ::= /[A-Za-z_][\w_]*/
enum A()?@@@@@$$$$$009934^^^^°
{
A$ = 1;
A$$ = 2;
A%%% = 3;
}
--
You received this message because you are subscribed to the Google Groups "Protocol Buffers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to protobuf+u...@googlegroups.com.
To post to this group, send email to prot...@googlegroups.com.
Visit this group at http://groups.google.com/group/protobuf?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.