Skip to content
This repository has been archived by the owner on Apr 13, 2023. It is now read-only.

Commit

Permalink
prototype implementation of |> #6615 using AST transform
Browse files Browse the repository at this point in the history
  • Loading branch information
gavinking committed Apr 16, 2018
1 parent 28cba50 commit bcdec18
Showing 1 changed file with 39 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1763,18 +1763,31 @@ specificationStatement returns [Statement statement]
expressionStatement returns [Statement statement]
@init { ExpressionStatement es=new ExpressionStatement(null); }
: e2=expression
: e1=expression
{ $statement = es;
if ($e2.expression!=null)
es.setExpression($e2.expression); }
if ($e1.expression!=null)
es.setExpression($e1.expression); }
(
pipelineOperator
{ $pipelineOperator.operator.setLeftTerm($e2.expression);
/*{ $pipelineOperator.operator.setLeftTerm($e1.expression);
Expression ex = new Expression(null);
ex.setTerm($pipelineOperator.operator);
es.setExpression(ex); }
e3=functionOrExpression
{ $pipelineOperator.operator.setRightTerm($e3.expression); }
es.setExpression(ex); }*/
e2=functionOrExpression
/*{ $pipelineOperator.operator.setRightTerm($e2.expression); }*/
{ InvocationExpression ie = new InvocationExpression(null);
ie.setPrimary($e2.expression);
if ($e2.expression.getTerm() instanceof Primary) {
ie.setPrimary((Primary) $e2.expression.getTerm());
}
ListedArgument la = new ListedArgument(null);
la.setExpression(es.getExpression());
PositionalArgumentList pal = new PositionalArgumentList(null);
pal.addPositionalArgument(la);
ie.setPositionalArgumentList(pal);
Expression e = new Expression(null);
e.setTerm(ie);
es.setExpression(e); }
)*
{ expecting=SEMICOLON; }
(
Expand Down Expand Up @@ -2691,15 +2704,28 @@ anonymousFunctionStart
;
pipelinedExpression returns [Expression expression]
: fe1=functionOrExpression
{ $expression = $fe1.expression; }
: e1=functionOrExpression
{ $expression = $e1.expression; }
(
pipelineOperator
{ $pipelineOperator.operator.setLeftTerm($expression);
/*{ $pipelineOperator.operator.setLeftTerm($expression);
$expression = new Expression(null);
$expression.setTerm($pipelineOperator.operator); }
fe2=functionOrExpression
{ $pipelineOperator.operator.setRightTerm($fe2.expression); }
$expression.setTerm($pipelineOperator.operator); }*/
e2=functionOrExpression
/*{ $pipelineOperator.operator.setRightTerm($e2.expression); }*/
{ InvocationExpression ie = new InvocationExpression(null);
ie.setPrimary($e2.expression);
if ($e2.expression.getTerm() instanceof Primary) {
ie.setPrimary((Primary) $e2.expression.getTerm());
}
ListedArgument la = new ListedArgument(null);
la.setExpression($expression);
PositionalArgumentList pal = new PositionalArgumentList(null);
pal.addPositionalArgument(la);
ie.setPositionalArgumentList(pal);
Expression e = new Expression(null);
e.setTerm(ie);
$expression = e; }
)*
;
Expand Down

0 comments on commit bcdec18

Please sign in to comment.