From e72a2b8e778fff230848769643a125ae995fbe58 Mon Sep 17 00:00:00 2001 From: tomsmeding Date: Fri, 3 Feb 2017 16:30:40 +0100 Subject: Add array indexing (not writing yet, though...) --- parser.hs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'parser.hs') diff --git a/parser.hs b/parser.hs index 942c63c..40da1ca 100644 --- a/parser.hs +++ b/parser.hs @@ -111,7 +111,13 @@ pExCast = do return $ ExCast t e pExLit :: Parser Expression -pExLit = (exLit_ <$> pLiteral) <|> pParenExpr +pExLit = do + litex <- (exLit_ <$> pLiteral) <|> pParenExpr + option litex $ do + symbol "[" + arg <- pExpression + symbol "]" + return $ exBinOp_ Index litex arg pParenExpr :: Parser Expression pParenExpr = do -- cgit v1.2.3-70-g09d2