on master help sign in
Parsing for Big Integer constants fixed
commit477820a86310649067f112c6821cea6a8297f455 authorJan Bessai <Jan.Bessai@tu-dortmund.de> dateMon 1 Apr 2013, 23:23 (14 years ago) parent25aef32
4 files changed+26−6
src/Idris/Parser.hs+5−6 test/reg016/expected+6 test/reg016/reg016.idr+11 test/reg016/run+4
src/Idris/Parser.hs+5−6
@@ -801,13 +801,13 @@ pCaseOpt syn = do lhs <- pExpr (syn { inPattern = True })
801801 return (lhs, rhs)
802802
803803modifyConst :: SyntaxInfo -> FC -> PTerm -> PTerm
804−modifyConst syn fc (PConstant (I x))
804+modifyConst syn fc (PConstant (BI x))
805805 | not (inPattern syn)
806806 = PAlternative False
807− [PApp fc (PRef fc (UN "fromInteger")) [pexp (PConstant (I x))],
808− PConstant (I x), PConstant (BI (toEnum x))]
807+ [PApp fc (PRef fc (UN "fromInteger")) [pexp (PConstant (I (fromInteger x)))],
808+ PConstant (I (fromInteger x)), PConstant (BI x)]
809809 | otherwise = PAlternative False
810− [PConstant (I x), PConstant (BI (toEnum x))]
810+ [PConstant (I (fromInteger x)), PConstant (BI x)]
811811modifyConst syn fc x = x
812812
813813pList syn = do lchar '['; fc <- pfc; xs <- sepBy (pExpr syn) (lchar ','); lchar ']'
@@ -1106,8 +1106,7 @@ pConstant = do reserved "Integer";return BIType
11061106 <|> do reserved "Bits32"; return B32Type
11071107 <|> do reserved "Bits64"; return B64Type
11081108 <|> try (do f <- float; return $ Fl f)
1109−-- <|> try (do i <- natural; lchar 'L'; return $ BI i)
1110− <|> try (do i <- natural; return $ I (fromInteger i))
1109+ <|> try (do i <- natural; return $ BI i)
11111110 <|> try (do s <- strlit; return $ Str s)
11121111 <|> try (do c <- chlit; return $ Ch c)
11131112
test/reg016/expectednew file+6
@@ -0,0 +1,6 @@
1+4294967295
2+4294967296
3+4294967297
4+-1
5+0
6+1
test/reg016/reg016.idrnew file+11
@@ -0,0 +1,11 @@
1+module Main
2+
3+main : IO ()
4+main = do print $ the Integer 4294967295
5+ print $ the Integer 4294967296
6+ print $ the Integer 4294967297
7+ print $ the Int 4294967295
8+ print $ the Int 4294967296
9+ print $ the Int 4294967297
10+
11+
test/reg016/runnew file+4
@@ -0,0 +1,4 @@
1+#!/bin/bash
2+idris $@ reg016.idr -o reg016
3+./reg016
4+rm -f reg016 *.ibc