Skip to content

Commit

Permalink
Move parsing of 'case' out of simpleExpr
Browse files Browse the repository at this point in the history
Even if this is possible, using it as an application unbracketed would
be unreadable! This speeds up parsing of nested case blocks massively.
(Or should I say "unslows down").
  • Loading branch information
edwinb committed Feb 4, 2014
1 parent 9e8f96c commit c15b21b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/Idris/ParseExpr.hs
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ InternalExpr ::=
| Let
| RewriteTerm
| Pi
| CaseExpr
| DoBlock
;
@
Expand All @@ -199,6 +200,7 @@ internalExpr syn =
<|> rewriteTerm syn
<|> try(pi syn)
<|> doBlock syn
<|> caseExpr syn
<|> simpleExpr syn
<?> "expression"

Expand Down Expand Up @@ -263,7 +265,6 @@ SimpleExpr ::=
| 'refl' ('{' Expr '}')?
| ProofExpr
| TacticsExpr
| CaseExpr
| FnName
| List
| Comprehension
Expand All @@ -290,7 +291,6 @@ simpleExpr syn =
<|> do reserved "elim_for"; fc <- getFC; t <- fnName; return (PRef fc (SN $ ElimN t))
<|> proofExpr syn
<|> tacticsExpr syn
<|> caseExpr syn
<|> do reserved "Type"; return PType
<|> try (do c <- constant
fc <- getFC
Expand Down
3 changes: 2 additions & 1 deletion src/Idris/ParseHelpers.hs
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,8 @@ operatorLetter = oneOf opChars
-- | Parses an operator
operator :: MonadicParsing m => m String
operator = do op <- token . some $ operatorLetter
when (op == ":") $ fail "(:) is not a valid operator"
when (op `elem` [":", "=>", "->", "<-", "=", "?="]) $
fail $ op ++ " is not a valid operator"
return op

{- * Position helpers -}
Expand Down

0 comments on commit c15b21b

Please sign in to comment.