@@ -103,12 +103,10 @@ singleIdentifier = Single <$> token identifierName
103
103
identifier :: ProtoParser DotProtoIdentifier
104
104
identifier = token _identifier
105
105
106
- -- [note] message and enum types are defined by the proto3 spec to have an optional leading period (messageType and enumType in the spec)
107
- -- what this indicates is, as far as i can tell, not documented, and i haven't found this syntax used in practice
108
- -- it's ommitted but can be fairly easily added if there is in fact a use for it
109
-
110
- -- [update] the leading dot denotes that the identifier path starts in global scope
111
- -- i still haven't seen a use case for this but i can add it upon request
106
+ -- Parses a full identifier, consuming trailing space.
107
+ -- The leading dot denotes that the identifier path starts in global scope.
108
+ globalIdentifier :: ProtoParser DotProtoIdentifier
109
+ globalIdentifier = token $ string " ." >> _identifier
112
110
113
111
-- Parses a nested identifier, consuming trailing space.
114
112
nestedIdentifier :: ProtoParser DotProtoIdentifier
@@ -162,7 +160,7 @@ primType = try (symbol "double" $> Double)
162
160
<|> try (symbol " string" $> String )
163
161
<|> try (symbol " bytes" $> Bytes )
164
162
<|> try (symbol " bool" $> Bool )
165
- <|> Named <$> identifier
163
+ <|> Named <$> ( identifier <|> globalIdentifier)
166
164
167
165
--------------------------------------------------------------------------------
168
166
-- top-level parser and version annotation
@@ -256,7 +254,7 @@ rpcOptions = braces $ many topOption
256
254
257
255
rpcClause :: ProtoParser (DotProtoIdentifier , Streaming )
258
256
rpcClause = do
259
- let sid ctx = (,ctx) <$> identifier
257
+ let sid ctx = (,ctx) <$> ( identifier <|> globalIdentifier)
260
258
-- NB: Distinguish "stream stream.foo" from "stream.foo"
261
259
try (symbol " stream" *> sid Streaming ) <|> sid NonStreaming
262
260
@@ -296,6 +294,7 @@ messagePart = try (DotProtoMessageDefinition <$> enum)
296
294
<|> try (DotProtoMessageDefinition <$> message)
297
295
<|> try messageOneOf
298
296
<|> try (DotProtoMessageField <$> messageField)
297
+ <|> try (DotProtoMessageOption <$> topOption)
299
298
300
299
messageType :: ProtoParser DotProtoType
301
300
messageType = try mapType <|> try repType <|> (Prim <$> primType)
0 commit comments