on master help sign in
Readded [static] but with a deprecation warning.

Also refactored the way parser warnings are added to make it easier to call.

commit060caf433261b3a47141ce1c060adaab5829113a authorAhmad Salim Al-Sibahi <asal@itu.dk> dateThu 28 Jan 2016, 16:54 (11 years ago) parentf3cc145
4 files changed+15−19
src/Idris/ParseData.hs+1−5 src/Idris/ParseExpr.hs+5−5 src/Idris/ParseHelpers.hs+7 src/Idris/Parser.hs+2−9
src/Idris/ParseData.hs+1−5
@@ -167,11 +167,7 @@ dataOpts opts
167167 <|> return opts
168168 <?> "data options"
169169 where warnElim fc =
170− do ist <- get
171− let cmdline = opt_cmdline (idris_options ist)
172− unless (NoElimDeprecationWarnings `elem` cmdline) $
173− put ist { parserWarnings =
174− (fc, Msg "Eliminator generation is deprecated. Use an eliminator generator in a library instead.") : parserWarnings ist }
170+ parserWarning fc (Just NoElimDeprecationWarnings) (Msg "The 'class' keyword is deprecated. Use 'interface' instead.")
175171
176172{- | Parses a data type declaration
177173Data ::= DocComment? Accessibility? DataI DefaultEliminator FnName TypeSig ExplicitTypeDataRest?
src/Idris/ParseExpr.hs+5−5
@@ -333,11 +333,7 @@ caseOption syn = do lhs <- expr (syn { inPattern = True })
333333
334334warnTacticDeprecation :: FC -> IdrisParser ()
335335warnTacticDeprecation fc =
336− do ist <- get
337− let cmdline = opt_cmdline (idris_options ist)
338− unless (NoOldTacticDeprecationWarnings `elem` cmdline) $
339− put ist { parserWarnings =
340− (fc, Msg "This style of tactic proof is deprecated. See %runElab for the replacement.") : parserWarnings ist }
336+ parserWarning fc (Just NoOldTacticDeprecationWarnings) (Msg "This style of tactic proof is deprecated. See %runElab for the replacement.")
341337
342338{- | Parses a proof block
343339@
@@ -1390,6 +1386,10 @@ Static ::=
13901386-}
13911387static :: IdrisParser Static
13921388static = do reserved "%static"; return Static
1389+ <|> do reserved "[static]"
1390+ fc <- getFC
1391+ parserWarning fc Nothing (Msg "The use of [static] is deprecated, use %static instead.")
1392+ return Static
13931393 <|> return Dynamic
13941394 <?> "static modifier"
13951395
src/Idris/ParseHelpers.hs+7
@@ -666,3 +666,10 @@ collect (PInstance doc argDocs f s cs n nfc ps t en ds : ds')
666666 = PInstance doc argDocs f s cs n nfc ps t en (collect ds) : collect ds'
667667collect (d : ds) = d : collect ds
668668collect [] = []
669+
670+parserWarning :: FC -> Maybe Opt -> Err -> IdrisParser ()
671+parserWarning fc warnOpt warnErr = do
672+ is <- get
673+ let cmdline = opt_cmdline (idris_options ist)
674+ unless (maybe False (`elem` cmdline) warnOpt) $
675+ put ist { parserWarnings = (fc, warnErr) : parserWarnings ist }
src/Idris/Parser.hs+2−9
@@ -878,10 +878,7 @@ class_ syn = do (doc, argDocs, acc)
878878 classKeyword = reservedHL "interface"
879879 <|> do reservedHL "class"
880880 fc <- getFC
881− ist <- get
882− put ist { parserWarnings =
883− (fc, Msg "The 'class' keyword is deprecated. Use 'interface' instead.")
884− : parserWarnings ist }
881+ parserWarning fc Nothing (Msg "The 'class' keyword is deprecated. Use 'interface' instead.")
885882
886883 carg :: IdrisParser (Name, FC, PTerm)
887884 carg = do lchar '('; (i, ifc) <- name; lchar ':'; ty <- expr syn; lchar ')'
@@ -928,11 +925,7 @@ instance_ kwopt syn
928925 instanceKeyword = reservedHL "implementation"
929926 <|> do reservedHL "instance"
930927 fc <- getFC
931− ist <- get
932− put ist { parserWarnings =
933− (fc, Msg "The 'instance' keyword is deprecated. Use 'implementation' (or omit it) instead.")
934− : parserWarnings ist }
935−
928+ parserWarning fc Nothing (Msg "The 'instance' keyword is deprecated. Use 'implementation' (or omit it) instead.")
936929
937930-- | Parse a docstring
938931docstring :: SyntaxInfo