# See: http://groups.google.com/group/protobuf/browse_thread/thread/1cccfc624cd612da proto ::= ( message | extend | enum | import | package | option | ";" )* import ::= "import" strLit ";" package ::= "package" ident ( "." ident )* ";" option ::= "option" optionBody ";" optionBody ::= ident ( "." ident )* "=" constant message ::= "message" ident messageBody extend ::= "extend" userType "{" ( field | group | ";" )* "}" 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 ::= label "group" camelIdent "=" intLit messageBody field ::= label type ident "=" intLit ( "[" fieldOption ( "," fieldOption )* "]" )? ";" # tag number must be 2^29-1 or lower, not 0, and not 19000-19999 (reserved) fieldOption ::= optionBody | "default" "=" constant # extension numbers must not overlap with field or other extension numbers extensions ::= "extensions" extension ( "," extension )* ";" extension ::= intLit ( "to" ( intLit | "max" ) )? label ::= "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 ( "." 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 ::= /[1-9]\d*/ hexInt ::= /0[xX]([A-Fa-f0-9])+/ octInt ::= /0[0-7]+/ # allow_f_after_float_ is disabled by default in tokenizer.cc floatLit ::= /\d+(\.\d+)?([Ee][\+-]?\d+)?/ boolLit ::= "true" | "false" # contents must not contain unescaped quote character strLit ::= quote ( hexEscape | octEscape | charEscape | /[^\0\n]/ )* quote quote ::= /["']/ hexEscape ::= /\\[Xx][A-Fa-f0-9]{1,2}/ octEscape ::= /\\0?[0-7]{1,3}/ charEscape ::= /\\[abfnrtv\\\?'"]/