summaryrefslogtreecommitdiff
path: root/src/Parser/Expr.hs
diff options
context:
space:
mode:
authorRoman Smrž <roman.smrz@seznam.cz>2024-09-23 19:44:17 +0200
committerRoman Smrž <roman.smrz@seznam.cz>2024-09-25 20:25:22 +0200
commit213e3523aead4c18b65ac85886203d2508b9b27e (patch)
tree6f207174a09ee312a366d0c22c08a31a056aaf3d /src/Parser/Expr.hs
parent274554243235d3013430a48973fd0f25244ac392 (diff)
Implement "guard" as a builtin
Diffstat (limited to 'src/Parser/Expr.hs')
-rw-r--r--src/Parser/Expr.hs10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/Parser/Expr.hs b/src/Parser/Expr.hs
index 04035c1..8ae0f77 100644
--- a/src/Parser/Expr.hs
+++ b/src/Parser/Expr.hs
@@ -66,8 +66,9 @@ someExpansion = do
void $ char '$'
choice
[do off <- stateOffset <$> getParserState
+ sline <- getSourceLine
name <- VarName . TL.toStrict <$> takeWhile1P Nothing (\x -> isAlphaNum x || x == '_')
- lookupVarExpr off name
+ lookupVarExpr off sline name
, between (char '{') (char '}') someExpr
]
@@ -348,9 +349,10 @@ literal = label "literal" $ choice
variable :: TestParser SomeExpr
variable = label "variable" $ do
off <- stateOffset <$> getParserState
+ sline <- getSourceLine
name <- varName
- lookupVarExpr off name >>= \case
- SomeExpr e'@(FunVariable (FunctionArguments argTypes) _) -> do
+ lookupVarExpr off sline name >>= \case
+ SomeExpr e'@(FunVariable (FunctionArguments argTypes) _ _) -> do
let check poff kw expr = do
case M.lookup kw argTypes of
Just expected -> do
@@ -364,7 +366,7 @@ variable = label "variable" $ do
Nothing -> "unexpected parameter"
return expr
- args <- functionArguments check someExpr literal (\poff -> lookupVarExpr poff . VarName)
+ args <- functionArguments check someExpr literal (\poff -> lookupVarExpr poff sline . VarName)
return $ SomeExpr $ ArgsApp args e'
e -> do
return e