on master help sign in
Merge pull request #763 from ahmadsalim/feature/parserlayoutfixes

Fixes layout parsing of operators

commitd0ed56f7a584b576d78825cd66ffabcacba7efa4 authorEdwin Brady <edwin.brady@gmail.com> dateMon 6 Jan 2014, 15:31 (13 years ago) parent1b53cc57932797
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