Skip to content

Commit 3bd19b9

Browse files
committed
Implement first draft of program piping
1 parent d6bd287 commit 3bd19b9

1 file changed

Lines changed: 22 additions & 0 deletions

File tree

parser/parser.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1381,6 +1381,28 @@ func (p *Parser) evaluateSingleExpression(ctx context) (Expression, bool) {
13811381
}
13821382
}
13831383
expr = call
1384+
nextToken = p.peek()
1385+
1386+
if ok && nextToken.Type == lexer.PIPE {
1387+
p.eat()
1388+
1389+
if appCall, castOk := expr.(*AppCall); !castOk {
1390+
p.atError("pipe can only be used on program-calls", nextToken)
1391+
} else {
1392+
var nextCall Expression
1393+
1394+
nextToken = p.peek()
1395+
nextCall, ok = p.evaluateSingleExpression(ctx)
1396+
1397+
if ok {
1398+
if nextAppCall, castOk := nextCall.(*AppCall); !castOk {
1399+
p.atError("output can only be piped into program-calls", nextToken)
1400+
} else {
1401+
appCall.Next = nextAppCall
1402+
}
1403+
}
1404+
}
1405+
}
13841406
}
13851407
return expr, ok
13861408
}

0 commit comments

Comments
 (0)