Skip to content

Commit

Permalink
Added support for the "stream" keyword for Service definitions
Browse files Browse the repository at this point in the history
  • Loading branch information
IceMan81 committed Dec 11, 2015
1 parent bb3f2b6 commit ece3b7a
Show file tree
Hide file tree
Showing 7 changed files with 286 additions and 278 deletions.
7 changes: 4 additions & 3 deletions .idea/encodings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion src/protobuf/lang/PbTokenTypes.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ public interface PbTokenTypes {

IElementType RPC = new PbElementType("RPC");
IElementType RETURNS = new PbElementType("RETURNS");
IElementType STREAM = new PbElementType("STREAM");
IElementType EXTENSIONS = new PbElementType("EXTENSIONS");
//--

Expand Down Expand Up @@ -110,7 +111,7 @@ public interface PbTokenTypes {
FIXED32,FIXED64,SFIXED32,
SFIXED64,BOOL,STRING,BYTES); //keywords

TokenSet OTHER_KEYWORDS = TokenSet.create(RPC,RETURNS,GROUP,EXTENSIONS,TO,MAX);//keywords
TokenSet OTHER_KEYWORDS = TokenSet.create(RPC,RETURNS,GROUP,EXTENSIONS,TO,MAX,STREAM);//keywords

//Options
//--File settings
Expand Down
544 changes: 274 additions & 270 deletions src/protobuf/lang/lexer/_ProtobufLexer.java

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions src/protobuf/lang/lexer/protobuf.flex
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ WRONG_STRING_SINGLE_QUOTED = \'[^\'\r\n]*
"enum" {return (ENUM);}
"oneof" {return (ONEOF);}
"returns" {return (RETURNS);}
"stream" {return (STREAM);}
"option" {return (OPTION);}
"group" {return (GROUP);}
"extensions" {return (EXTENSIONS);}
Expand Down
2 changes: 2 additions & 0 deletions src/protobuf/lang/parser/parsing/ServiceDeclaration.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,14 @@ public static boolean parseServiceMethod(PbPatchedPsiBuilder builder) {
builder.match(IK, "identifier.expected");
//builder.matchAs(IK,NAME, "identifier.expected");
builder.match(OPEN_PARENTHESIS, "open.parenthesis.expected");
builder.match(STREAM);
if (!ReferenceElement.parseForCustomType(builder)) {
builder.error("user.defined.type.expected");
}
builder.match(CLOSE_PARENTHESIS, "close.parenthesis.expected");
builder.match(RETURNS, "returns.expected");
builder.match(OPEN_PARENTHESIS, "open.parenthesis.expected");
builder.match(STREAM);
if (!ReferenceElement.parseForCustomType(builder)) {
builder.error("user.defined.type.expected");
}
Expand Down
2 changes: 1 addition & 1 deletion src/protobuf/lang/parser/parsing/protobuf-grammar.bnf
Original file line number Diff line number Diff line change
Expand Up @@ -63,5 +63,5 @@ STRING_LITERALS ::= NUMBERS | IDENTIFIER | STRING | KEYWORD | BOOL_VALUES
<Service Declaration> ::= 'service' IDENTIFIER <Service Block>
<Service Block> ::= '{' (<Service Member> | ';')* '}'
<Service Member> ::= <Service Method> | <Option Declaration>
<Service Method> ::= 'rpc' IDENTIFIER '(' <User Defined Type> ')' 'returns' '(' <User Defined Type> ')' <Service Method Block>? ';'
<Service Method> ::= 'rpc' IDENTIFIER '(' <User Defined Type> ')' 'returns' '(' ('stream' | <User Defined Type>) ')' <Service Method Block>? ';'
<Service Method Block> ::= '{' (<Option Declaration>|';')* '}'

0 comments on commit ece3b7a

Please sign in to comment.