@@ -42,6 +42,7 @@ import {
42
42
Definition ,
43
43
ImportName ,
44
44
Kind ,
45
+ Stream ,
45
46
} from "./ast" ;
46
47
47
48
type parseFunction = ( ) => Node ;
@@ -325,7 +326,13 @@ class Parser {
325
326
const colon = this . expectOptionalToken ( TokenKind . COLON ) ;
326
327
let type : Type = new Named ( undefined , new Name ( undefined , "void" ) ) ;
327
328
if ( colon ) {
329
+ const streamLoc = this . loc ( this . _lexer . token ) ;
330
+ const stream = this . expectOptionalKeyword ( "stream" ) ;
328
331
type = this . parseType ( ) ;
332
+ if ( stream ) {
333
+ const streamLoc = this . loc ( this . _lexer . token ) ;
334
+ type = new Stream ( streamLoc , type ) ;
335
+ }
329
336
}
330
337
const annotations = this . parseAnnotations ( ) ;
331
338
@@ -798,7 +805,7 @@ class Parser {
798
805
} else if ( unary && this . peek ( TokenKind . BRACE_L ) ) {
799
806
// unary
800
807
this . _lexer . advance ( ) ;
801
- const inputValueDef = this . parseParameterDefinition ( ) ;
808
+ const inputValueDef = this . parseParameterDefinition ( true ) ;
802
809
this . expectToken ( TokenKind . BRACE_R ) ;
803
810
const arr = new Array < ParameterDefinition > ( ) ;
804
811
arr . push ( inputValueDef ) ;
@@ -814,12 +821,17 @@ class Parser {
814
821
* ParameterDefinition :
815
822
* - Description? Name : Type DefaultValue? Annotations[Const]?
816
823
*/
817
- parseParameterDefinition ( ) : ParameterDefinition {
824
+ parseParameterDefinition ( allowStream : boolean = false ) : ParameterDefinition {
818
825
const start = this . _lexer . token ;
819
826
const description = this . parseDescription ( ) ;
820
827
const name = this . parseName ( ) ;
821
828
this . expectToken ( TokenKind . COLON ) ;
822
- const type = this . parseType ( ) ;
829
+ const streamLoc = this . loc ( this . _lexer . token ) ;
830
+ const stream = allowStream && this . expectOptionalKeyword ( "stream" ) ;
831
+ var type = this . parseType ( ) ;
832
+ if ( stream ) {
833
+ type = new Stream ( streamLoc , type ) ;
834
+ }
823
835
let defaultValue : Value | undefined ;
824
836
if ( this . expectOptionalToken ( TokenKind . EQUALS ) ) {
825
837
defaultValue = this . parseConstValue ( ) ;
0 commit comments