--- /dev/null
+main() {
+ [Int] x = [1,2,3];
+ var y = [[1], [1,2,3], [4,5,900]];
+ var z = [(\x->x+1), (\x->3), (\x->x*3)];
+ var f = \x->x+1;
+ var fs = [f, f, f, f];
+ var gs = [\x->x+1];
+ return;
+}
\ No newline at end of file
| '(' <Expr> ')'
| <FunCall> <FieldSels>
| '[]' <Expr>
+ | '[' (<Expr> ',')* (<Expr>) ']'
| '(' <Expr> ',' <Expr> ')'
| '"' <char> '"'
<Op1> ::= '~' | '!'
(trans2 (StringToken []) (\(StringToken cs)->makeStrExpr pos cs)) <|>
(TupleExpr pos <$> (parseTuple parseExpr)) <|>
parseBBraces parseExpr <|>
+ parseListLiteral <|>
trans1 EmptyListToken (EmptyListExpr pos) <|>
trans1 TrueToken (BoolExpr pos True) <|>
trans1 FalseToken (BoolExpr pos False) <|>
pure $ FunExpr pos ident args fs) <|>
(VarExpr pos <$> parseVarDef)
+ parseListLiteral :: Parser Token Expr
+ parseListLiteral = peekPos >>= \p->
+ satTok SquareOpenToken >>|
+ many (parseExpr <* satTok CommaToken) >>= \es->
+ parseExpr >>= \e->
+ foldM (\res e-> pure $ Op2Expr p e BiCons res)
+ (EmptyListExpr p)
+ [e : reverse es] >>= \res->
+ satTok SquareCloseToken >>|
+ pure res
+
parseLambda :: Parser Token Expr
parseLambda = LambdaExpr <$> peekPos
<*> (satTok BackslashToken *> many parseIdent)
pure ([fd], fe)
unfoldL_ (FunExpr p f es fs) = flattenT <$> mapM unfoldL_ es >>= \(fds, es_)->
pure (fds, FunExpr p f es_ fs)
+ unfoldL_ (Op2Expr p e1 op e2) = unfoldL_ e1 >>= \(fds1, e1_)->
+ unfoldL_ e2 >>= \(fds2, e2_)->
+ pure (fds1++fds2, Op2Expr p e1_ op e2_)
+ unfoldL_ (Op1Expr p op e1) = unfoldL_ e1 >>= \(fds, e1_)->pure (fds, Op1Expr p op e1_)
+ unfoldL_ (TupleExpr p (e1, e2)) = unfoldL_ e1 >>= \(fds1, e1_)->
+ unfoldL_ e2 >>= \(fds2, e2_)->
+ pure (fds1++fds2, TupleExpr p (e1_, e2_))
unfoldL_ e = pure ([], e)
//------------