on master help sign in
Fixes layout parsing of operators
commit7932797e7bf7c79051efa7f3ea4d7e83a6e13077 authorAhmad Salim Al-Sibahi <asal@itu.dk> dateFri 3 Jan 2014, 12:59 (13 years ago) parent3eb8fc8
4 files changed+28−1
src/Idris/ParseOps.hs+6−1 test/test036/expected+1 test/test036/run+4 test/test036/test036.idr+17
src/Idris/ParseOps.hs+6−1
@@ -55,7 +55,9 @@ toTable fs = map (map toBin)
5555-- | Binary operator
5656binary :: String -> (FC -> PTerm -> PTerm -> PTerm) -> Assoc -> Operator IdrisParser PTerm
5757binary name f = Infix (do fc <- getFC
58+ indentPropHolds gtProp
5859 reservedOp name
60+ indentPropHolds gtProp
5961 doc <- option "" (docComment '^')
6062 return (f fc))
6163
@@ -63,12 +65,15 @@ binary name f = Infix (do fc <- getFC
6365prefix :: String -> (FC -> PTerm -> PTerm) -> Operator IdrisParser PTerm
6466prefix name f = Prefix (do reservedOp name
6567 fc <- getFC
68+ indentPropHolds gtProp
6669 return (f fc))
6770
6871-- | Backtick operator
6972backtick :: Operator IdrisParser PTerm
70−backtick = Infix (do lchar '`'; n <- fnName
73+backtick = Infix (do indentPropHolds gtProp
74+ lchar '`'; n <- fnName
7175 lchar '`'
76+ indentPropHolds gtProp
7277 fc <- getFC
7378 return (\x y -> PApp fc (PRef fc n) [pexp x, pexp y])) AssocNone
7479
test/test036/expectednew file+1
@@ -0,0 +1 @@
1+Just 2
test/test036/runnew file+4
@@ -0,0 +1,4 @@
1+#!/usr/bin/env bash
2+idris $@ test036.idr -o test036
3+./test036
4+rm -f test036 *.ibc
test/test036/test036.idrnew file+17
@@ -0,0 +1,17 @@
1+module Main
2+
3+maybechoice : Maybe a -> Maybe a -> Maybe a
4+maybechoice (Just x) _ = Just x
5+maybechoice Nothing r = r
6+
7+unused : a -> a -> a
8+unused _ s = s
9+
10+doTest : Maybe Nat
11+doTest = do
12+ a <- Nothing
13+ unused a (return 3)
14+ `maybechoice` return 2
15+
16+main : IO ()
17+main = putStrLn . show $ doTest