File tree Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -46,6 +46,22 @@ func advanceLexer(lexer: Lexer) throws -> Token {
46
46
return token
47
47
}
48
48
49
+ /**
50
+ * Returns a non-empty list of parse nodes, determined by the parseFn.
51
+ * This list may begin with a lex token of delimiterKind followed by items separated by lex tokens of tokenKind.
52
+ * Advances the parser to the next lex token after last item in the list.
53
+ */
54
+ func delimitedMany< T> ( lexer: Lexer , kind: Token . Kind , parseFn: ( Lexer ) throws -> T ) throws -> [ T ] {
55
+ _ = try expectOptional ( lexer: lexer, kind: kind)
56
+
57
+ var nodes : [ T ] = [ ]
58
+ repeat {
59
+ try nodes. append ( parseFn ( lexer) )
60
+ } while ( try expectOptional ( lexer: lexer, kind: kind) != nil )
61
+
62
+ return nodes
63
+ }
64
+
49
65
/**
50
66
* The return type of createLexer.
51
67
*/
You can’t perform that action at this time.
0 commit comments