on master help sign in
Merge pull request #4243 from eraserhd/deprecated-parser-features

Remove deprecated parser features

commit1e4133b093fdf15a559a5cbcbfd468431f9f647e authorJason Felice <jason.m.felice@gmail.com> dateThu 21 Dec 2017, 08:32 (9 years ago) parent76e45a3b7e2e18
6 files changed+27−36
CHANGELOG.md+4−1 docs/reference/syntax-guide.rst−1 samples/tutorial/BTreeMod.idr+5−5 src/Idris/Parser.hs+13−5 src/Idris/Parser/Expr.hs−3 src/Idris/Parser/Helpers.hs+5−21
CHANGELOG.md+4−1
@@ -31,7 +31,10 @@
3131 intMax : IO Int
3232 intMax = foreign FFI_C "#INT_MAX" (IO Int)
3333 ```
34−
34++ The deprecated keywords `%assert_total`, `abstract`, and `[static]` have
35+ been removed as well as the use of "public" instead of "public export" to
36+ expose a symbol.
37+
3538## Library Updates
3639
3740+ Removed `oldeffects` library from `libs` folder, use `effects` or `Control.ST` instead.
docs/reference/syntax-guide.rst−1
@@ -407,7 +407,6 @@ Options
407407 %no_implicit
408408 %error_handler
409409 %error_reverse
410− %assert_total
411410 %reflection
412411 %specialise [<name list>]
413412
samples/tutorial/BTreeMod.idr+5−5
@@ -1,20 +1,20 @@
11module btree
22
3−abstract data BTree a = Leaf
4− | Node (BTree a) a (BTree a)
3+export data BTree a = Leaf
4+ | Node (BTree a) a (BTree a)
55
6−abstract
6+export
77insert : Ord a => a -> BTree a -> BTree a
88insert x Leaf = Node Leaf x Leaf
99insert x (Node l v r) = if (x < v) then (Node (insert x l) v r)
1010 else (Node l v (insert x r))
1111
12−abstract
12+export
1313toList : BTree a -> List a
1414toList Leaf = []
1515toList (Node l v r) = btree.toList l ++ (v :: btree.toList r)
1616
17−abstract
17+export
1818toTree : Ord a => List a -> BTree a
1919toTree [] = Leaf
2020toTree (x :: xs) = insert x (toTree xs)
src/Idris/Parser.hs+13−5
@@ -650,9 +650,6 @@ fnOpt = do keyword "total"; return TotalFn
650650 <|> NoImplicit <$ P.try (lchar '%' *> reserved "no_implicit")
651651 <|> Inlinable <$ P.try (lchar '%' *> reserved "inline")
652652 <|> StaticFn <$ P.try (lchar '%' *> reserved "static")
653− <|> do fc <- P.try $ extent $ lchar '%' *> reserved "assert_total"
654− parserWarning fc Nothing (Msg "%assert_total is deprecated. Use the 'assert_total' function instead.")
655− return AssertTotal
656653 <|> ErrorHandler <$ P.try (lchar '%' *> reserved "error_handler")
657654 <|> ErrorReverse <$ P.try (lchar '%' *> reserved "error_reverse")
658655 <|> ErrorReduce <$ P.try (lchar '%' *> reserved "error_reduce")
@@ -881,10 +878,15 @@ interface_ syn = do (doc, argDocs, acc)
881878 fundeps :: IdrisParser [(Name, FC)]
882879 fundeps = do lchar '|'; P.sepBy (withExtent name) (lchar ',')
883880
881+ classWarning :: String
882+ classWarning = "Use of a fragile keyword `class`. " ++
883+ "`class` is provided for those coming from Haskell. " ++
884+ "Please use `interface` instead, which is equivalent."
885+
884886 interfaceKeyword :: IdrisParser ()
885887 interfaceKeyword = keyword "interface"
886888 <|> do fc <- extent $ keyword "class"
887− parserWarning fc Nothing (Msg "The 'class' keyword is deprecated. Use 'interface' instead.")
889+ parserWarning fc Nothing (Msg classWarning)
888890
889891 carg :: IdrisParser (Name, FC, PTerm)
890892 carg = do lchar '('; (i, ifc) <- withExtent name; lchar ':'; ty <- expr syn; lchar ')'
@@ -929,10 +931,16 @@ implementation syn = do (doc, argDocs) <- docstring syn
929931 let n = expandNS syn n_in
930932 return n
931933 <?> "implementation name"
934+
935+ instanceWarning :: String
936+ instanceWarning = "Use of fragile keyword `instance`. " ++
937+ "`instance` is provided for those coming from Haskell. " ++
938+ "Please use `implementation` (which is equivalent) instead, or omit it."
939+
932940 implementationKeyword :: IdrisParser ()
933941 implementationKeyword = keyword "implementation"
934942 <|> do fc <- extent $ keyword "instance"
935− parserWarning fc Nothing (Msg "The 'instance' keyword is deprecated. Use 'implementation' (or omit it) instead.")
943+ parserWarning fc Nothing (Msg instanceWarning)
936944
937945 implementationUsing :: IdrisParser [Name]
938946 implementationUsing = do keyword "using"
src/Idris/Parser/Expr.hs−3
@@ -1408,9 +1408,6 @@ Static ::=
14081408-}
14091409static :: IdrisParser Static
14101410static = Static <$ reserved "%static"
1411− <|> do fc <- extent $ reserved "[static]"
1412− parserWarning fc Nothing (Msg "The use of [static] is deprecated, use %static instead.")
1413− return Static
14141411 <|> return Dynamic
14151412 <?> "static modifier"
14161413
src/Idris/Parser/Helpers.hs+5−21
@@ -260,7 +260,7 @@ float = token . P.try $ P.float
260260reservedIdentifiers :: HS.HashSet String
261261reservedIdentifiers = HS.fromList
262262 [ "Type"
263− , "abstract", "case", "class", "codata", "constructor", "corecord", "data"
263+ , "case", "class", "codata", "constructor", "corecord", "data"
264264 , "do", "dsl", "else", "export", "if", "implementation", "implicit"
265265 , "import", "impossible", "in", "infix", "infixl", "infixr", "instance"
266266 , "interface", "let", "mutual", "namespace", "of", "parameters", "partial"
@@ -520,26 +520,10 @@ notOpenBraces = do ist <- get
520520
521521{- | Parses an accessibilty modifier (e.g. public, private) -}
522522accessibility' :: IdrisParser Accessibility
523−accessibility'
524− = do fc <- extent $ reserved "public"
525− gotexp <- optional (reserved "export")
526− case gotexp of
527− Just _ -> return ()
528− Nothing -> do
529− ist <- get
530− put ist { parserWarnings =
531− (fc, Msg "'public' is deprecated. Use 'public export' instead.")
532− : parserWarnings ist }
533− return Public
534− <|> do fc <- extent $ reserved "abstract"
535− ist <- get
536− put ist { parserWarnings =
537− (fc, Msg "The 'abstract' keyword is deprecated. Use 'export' instead.")
538− : parserWarnings ist }
539− return Frozen
540− <|> do reserved "export"; return Frozen
541− <|> do reserved "private"; return Private
542− <?> "accessibility modifier"
523+accessibility' = Public <$ reserved "public" <* reserved "export"
524+ <|> Frozen <$ reserved "export"
525+ <|> Private <$ reserved "private"
526+ <?> "accessibility modifier"
543527
544528accessibility :: IdrisParser Accessibility
545529accessibility = do acc <- optional accessibility'