packages feed

language-ats 0.3.0.4 → 0.3.0.5

raw patch · 7 files changed

+42/−29 lines, 7 filesPVP: minor bump suggested

API additions: PVP suggests at least a minor version bump

API changes (from Hackage documentation)

+ Language.ATS: ExtVar :: AlexPosn -> String -> Expression -> Declaration
+ Language.ATS: KwExtVar :: Keyword

Files

language-ats.cabal view
@@ -1,5 +1,5 @@ name:                language-ats-version:             0.3.0.4+version:             0.3.0.5 synopsis:            Parser and pretty-printer for ATS. description:         Parser and pretty-printer for [ATS](http://www.ats-lang.org/), written with Happy and Alex. license:             BSD3
src/Language/ATS.hs view
@@ -1,3 +1,5 @@+{-# LANGUAGE OverloadedStrings #-}+ -- | Main module for the library module Language.ATS ( -- * Functions for working with syntax                       lexATS@@ -65,7 +67,7 @@ rewriteATS' (ATS ds) = ATS (rewriteDecl <$> ds)  printErr :: MonadIO m => ATSError String -> m ()-printErr = liftIO . hPutDoc stderr . pretty+printErr = liftIO . hPutDoc stderr . (<> "\n") . pretty  -- | Parse a string containing ATS source. parse :: String -> Either (ATSError String) ATS
src/Language/ATS/Lexer.x view
@@ -39,8 +39,8 @@ $alpha = [a-zA-Z] $terminal = $printable # $white $esc_char = \27-@escape_ch = \\ ([nt\'\\] | $octal+)-@escape_str = \\ ([nt\"\\] | $octal+)+@escape_ch = \\ ([nrt\'\\] | $octal+)+@escape_str = \\ ([nrt\"\\] | $octal+) @char = ($terminal # [\\\']) | " " | @escape_ch | $esc_char @char_lit = \' @char \' @@ -98,7 +98,7 @@  @fixity_decl = "infixr" | "infixl" | "prefix" | "postfix" -@builtin = \$ (("effmask_" (wrt | all | ref)) | "extfcall" | "ldelay" | "delay" | "list_vt" | "tempenver" | "extype" | "mylocation" | "showtype")+@builtin = \$ (("effmask_" (wrt | all | ref)) | "extfcall" | "ldelay" | "delay" | "list_vt" | "tempenver" | "extval" | "extype" | "mylocation" | "showtype")  @block_comment_start = \(\* | \/\* @block_comment_end = \*\) | \*\/@@ -195,6 +195,7 @@     <0> overload                 { tok (\p s -> alex $ Keyword p KwOverload) }     <0> with                     { tok (\p s -> alex $ Keyword p KwWith) }     <0> extern                   { tok (\p s -> alex $ Keyword p KwExtern) }+    <0> extvar                   { tok (\p s -> alex $ Keyword p KwExtVar) }     <0> sortdef                  { tok (\p s -> alex $ Keyword p KwSortdef) }     <0> propdef                  { tok (\p s -> alex $ Keyword p KwPropdef) }     <0> tkindef                  { tok (\p s -> alex $ Keyword p KwTKind) }@@ -317,6 +318,7 @@              | KwAbsvtype              | KwProofImplement              | KwSortdef+             | KwExtVar              | KwPropdef              | KwRaise              | KwTKind@@ -432,6 +434,7 @@     pretty KwProofImplement = "primplmnt"     pretty KwSortdef = "sortdef"     pretty KwPropdef = "propdef"+    pretty KwExtVar = "extvar"     pretty KwTKind = "tkind"     pretty KwMod = "mod"     pretty KwFixAt = "fix@"
src/Language/ATS/Parser.y view
@@ -82,6 +82,7 @@     with { Keyword $$ KwWith }     dataprop { Keyword $$ KwDataprop }     praxi { Keyword $$ KwPraxi }+    extvar { Keyword $$ KwExtVar }     extern { Keyword $$ KwExtern }     t0pPlain { Keyword $$ (KwT0p None) }     t0pCo { Keyword $$ (KwT0p Plus) }@@ -209,6 +210,7 @@      | Name doubleParens { Dependent $1 [] }      | identifierSpace openParen TypeInExpr closeParen { Dependent (Unqualified $ to_string $1) $3 }      | identifierSpace { Named (Unqualified $ to_string $1) }+     | specialIdentifier string { Dependent (SpecialName (token_posn $1) (to_string $1)) [Named (Unqualified $ $2)] }      | Name { Named $1 }      | exclamation Type { Unconsumed $2 }      | Type mutateArrow Type { FunctionType "->" $1 $3 }@@ -744,6 +746,7 @@ -- | Parse a declaration Declaration : include string { Include $2 }             | define { Define $1 }+            | extvar string eq Expression { ExtVar $1 $2 $4 }             | define identifierSpace string { Define ($1 ++ " " ++ to_string $2 ++ $3) } -- FIXME better approach?             | define identifier string { Define ($1 ++ " " ++ to_string $2 ++ $3) } -- FIXME better approach?             | define identifierSpace intLit { Define ($1 ++ " " ++ to_string $2 ++ " " ++ show $3) }
src/Language/ATS/PrettyPrint.hs view
@@ -282,29 +282,30 @@  instance Pretty Type where     pretty = cata a where-        a (NamedF n)              = pretty n-        a (ViewTypeF _ t)         = "view@" <> parens t-        a (ExF e (Just t))        = pretty e <+> t-        a (ExF e Nothing)         = pretty e-        a (DependentF n ts)       = pretty n <> parens (mconcat (punctuate ", " (fmap pretty (reverse ts))))-        a (ForAF u t)             = pretty u <+> t-        a (UnconsumedF t)         = "!" <> t-        a (AsProofF t (Just t'))  = t <+> ">>" <+> t'-        a (AsProofF t Nothing)    = t <+> ">> _"-        a (FromVTF t)             = t <> "?!"-        a (MaybeValF t)           = t <> "?"-        a (AtExprF _ t t')        = t <+> "@" <+> pretty t'-        a (AtTypeF _ t)           = "@" <> t-        a (ProofTypeF _ t t')     = parens (prettyArgsG "" "" t <+> "|" <+> t')-        a (ConcreteTypeF e)       = pretty e-        a (TupleF _ ts)           = parens (mconcat (punctuate ", " (fmap pretty (reverse ts))))-        a (RefTypeF t)            = "&" <> t-        a (FunctionTypeF s t t')  = t <+> string s <+> t'-        a (ViewLiteralF c)        = "view" <> pretty c-        a NoneTypeF{}             = "()"-        a ImplicitTypeF{}         = ".."-        a (AnonymousRecordF _ rs) = prettyRecord rs-        a (ParenTypeF _ t)        = parens t+        a (NamedF n)                       = pretty n+        a (ViewTypeF _ t)                  = "view@" <> parens t+        a (ExF e (Just t))                 = pretty e <+> t+        a (ExF e Nothing)                  = pretty e+        a (DependentF n@SpecialName{} [t]) = pretty n <+> pretty t+        a (DependentF n ts)                = pretty n <> parens (mconcat (punctuate ", " (fmap pretty (reverse ts))))+        a (ForAF u t)                      = pretty u <+> t+        a (UnconsumedF t)                  = "!" <> t+        a (AsProofF t (Just t'))           = t <+> ">>" <+> t'+        a (AsProofF t Nothing)             = t <+> ">> _"+        a (FromVTF t)                      = t <> "?!"+        a (MaybeValF t)                    = t <> "?"+        a (AtExprF _ t t')                 = t <+> "@" <+> pretty t'+        a (AtTypeF _ t)                    = "@" <> t+        a (ProofTypeF _ t t')              = parens (prettyArgsG "" "" t <+> "|" <+> t')+        a (ConcreteTypeF e)                = pretty e+        a (TupleF _ ts)                    = parens (mconcat (punctuate ", " (fmap pretty (reverse ts))))+        a (RefTypeF t)                     = "&" <> t+        a (FunctionTypeF s t t')           = t <+> string s <+> t'+        a (ViewLiteralF c)                 = "view" <> pretty c+        a NoneTypeF{}                      = "()"+        a ImplicitTypeF{}                  = ".."+        a (AnonymousRecordF _ rs)          = prettyRecord rs+        a (ParenTypeF _ t)                 = parens t  gan :: Maybe Sort -> Doc gan (Just t) = " : " <> pretty t <> " "@@ -544,7 +545,8 @@     pretty (AndDecl t p e)                 = "and" <+> pretty p <> valSig t <+> "=" <+> pretty e     pretty (Val a t p e)                   = "val" <> pretty a <+> pretty p <> valSig t <+> "=" <+> pretty e     pretty (Var t p Nothing (Just e))      = "var" <+> pretty p <> valSig t <+> "with" <+> pretty e-    pretty (Var t p e Nothing)             = "var" <+> pretty p <> valSig t <+> "=" <+> pretty e+    pretty (Var t p (Just e) Nothing)      = "var" <+> pretty p <> valSig t <+> "=" <+> pretty e+    pretty (Var t p Nothing Nothing)       = "var" <+> pretty p <> valSig t     pretty (Var _ _ _ Just{})              = undefined     pretty (Include s)                     = "#include" <+> pretty s     pretty (Staload b Nothing s)           = bool "" "#" b <> "staload" <+> pretty s@@ -585,10 +587,12 @@     pretty (AndD d (Stadef i as t))        = pretty d <+> "and" <+> text i <+> prettySortArgs as <> pretty t     pretty (AbsView _ i as t)              = "absview" <+> text i <> prettySortArgs as <> prettyMaybeType t     pretty (AbsVT0p _ i as t)              = "absvt@ype" <+> text i <> prettySortArgs as <> prettyMaybeType t+    pretty (AbsT0p _ i Nothing t)          = "abst@ype" <+> text i <+> "=" <+> pretty t     pretty (AbsT0p _ i as t)               = "abst@ype" <+> text i <> prettySortArgs as <> "=" <+> pretty t     pretty (ViewDef _ s as t)              = "viewdef" <+> text s <> prettySortArgs as <+> "=" <#> pretty t     pretty (TKind _ n s)                   = pretty n <+> "=" <+> text s     pretty (SortDef _ s t)                 = "sortdef" <+> text s <+> "=" <+> either pretty pretty t     pretty (AndD d (SortDef _ i t))        = pretty d <+> "and" <+> text i <+> "=" <+> either pretty pretty t     pretty (MacDecl _ n is e)              = "macdef" <+> text n <> "(" <> mconcat (punctuate ", " (fmap text is)) <> ") =" <+> pretty e+    pretty (ExtVar _ s e)                  = "extvar" <+> text s <+> "=" <+> pretty e     pretty AndD{}                          = undefined -- probably not valid syntax if we get to this point
src/Language/ATS/Types.hs view
@@ -131,6 +131,7 @@                  | MacDecl AlexPosn String [String] Expression                  | DataSort AlexPosn String [DataSortLeaf]                  | Exception String Type+                 | ExtVar AlexPosn String Expression                  deriving (Show, Eq, Generic, NFData)  data DataSortLeaf = DataSortLeaf [Universal] Sort (Maybe Sort)
+ test/data/integer_ptr.out view