language-ats 0.3.0.6 → 0.3.0.7
raw patch · 4 files changed
+22/−16 lines, 4 filesPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
API changes (from Hackage documentation)
- Language.ATS: WhereExp :: Expression -> [Declaration] -> Expression
+ Language.ATS: WhereExp :: Expression -> ATS -> Expression
Files
- language-ats.cabal +1/−1
- src/Language/ATS/Parser.y +4/−2
- src/Language/ATS/PrettyPrint.hs +16/−12
- src/Language/ATS/Types.hs +1/−1
language-ats.cabal view
@@ -1,5 +1,5 @@ name: language-ats-version: 0.3.0.6+version: 0.3.0.7 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/Parser.y view
@@ -411,7 +411,7 @@ | while openParen PreExpression closeParen PreExpression { While $1 $3 $5 } | lineComment PreExpression { CommentExpr (to_string $1) $2 } | comma openParen identifier closeParen { MacroVar $1 (to_string $3) }- | PreExpression where lbrace Declarations rbrace { WhereExp $1 $4 }+ | PreExpression where lbrace ATS rbrace { WhereExp $1 $4 } | include {% Left $ Expected $1 "Expression" "include" } | staload {% Left $ Expected (token_posn $1) "Expression" "staload" } | overload {% Left $ Expected $1 "Expression" "overload" }@@ -423,6 +423,7 @@ | let openParen {% Left $ Expected $1 "Expression" "let (" } | let ATS in Expression lineComment {% Left $ Expected (token_posn $5) "end" (take 2 $ to_string $5) } | let ATS in Expression extern {% Left $ Expected $5 "end" "extern" }+ | let ATS in Expression else {% Left $ Expected $5 "end" "else" } | let ATS in Expression fun {% Left $ Expected $5 "end" "fun" } | let ATS in Expression vtypedef {% Left $ Expected $5 "end" "vtypedef" } | let ATS in Expression implement {% Left $ Expected $5 "end" "implement" }@@ -503,7 +504,6 @@ | dollar identifier dot identifierSpace { Qualified $1 (to_string $4) (to_string $2) } | dollar identifier dot identifier dollar IdentifierOr { Qualified $1 (to_string $4 ++ ('$' : $6)) (to_string $2) } | specialIdentifier { SpecialName (token_posn $1) (to_string $1) }- | customOperator { Unqualified (to_string $1) } | dollar {% Left $ Expected $1 "Name" "$" } -- | Parse a list of values in a record@@ -773,6 +773,7 @@ | implement FunArgs Implementation { Impl $2 $3 } | StaticDeclaration { $1 } | overload BinOp with Name { OverloadOp $1 $2 $4 Nothing }+ | overload BinOp with customOperator { OverloadOp $1 $2 (Unqualified $ to_string $4) Nothing } | overload BinOp with identifierSpace of intLit { OverloadOp $1 $2 (Unqualified $ to_string $4) (Just $6) } | overload identifierSpace with Name { OverloadIdent $1 (to_string $2) $4 Nothing } | overload identifierSpace with identifierSpace of intLit { OverloadIdent $1 (to_string $2) (Unqualified $ to_string $4) (Just $6) }@@ -786,6 +787,7 @@ | tkindef IdentifierOr eq string { TKind $1 (Unqualified $2) $4 } | TypeDecl { $1 } | symintr Name { SymIntr $1 $2 }+ | symintr customOperator { SymIntr $1 (Unqualified $ to_string $2) } | stacst IdentifierOr colon Type OptExpression { Stacst $1 (Unqualified $2) $4 $5 } | propdef IdentifierOr openParen Args closeParen eq Type { PropDef $1 $2 $4 $7 } | exception identifierSpace of doubleParens { Exception (to_string $2) (Tuple $4 mempty) }
src/Language/ATS/PrettyPrint.hs view
@@ -53,13 +53,13 @@ printATSCustom :: Float -- ^ Ribbon fraction -> Int -- ^ Ribbon width -> ATS -> String-printATSCustom r i (ATS x) = g mempty- where g = (displayS . renderSmart r i . pretty) (ATS $ reverse x)+printATSCustom r i x = g mempty+ where g = (displayS . renderSmart r i . pretty) x -- | Slightly faster pretty-printer without indendation (for code generation). printATSFast :: ATS -> String-printATSFast (ATS x) = g mempty- where g = (displayS . renderCompact . (<> "\n") . pretty) (ATS $ reverse x)+printATSFast x = g mempty+ where g = (displayS . renderCompact . (<> "\n") . pretty) x instance Pretty Name where pretty (Unqualified n) = text n@@ -141,8 +141,8 @@ a (IfF e e' (Just e'')) = "if" <+> e <+> "then" <$> indent 2 e' <$> "else" <$> indent 2 e'' a (IfF e e' Nothing) = "if" <+> e <+> "then" <$> indent 2 e' a (LetF _ e e') = flatAlt- ("let" <$> indent 2 (pretty ((\(ATS x) -> ATS $ reverse x) e)) <$> endLet e')- ("let" <+> pretty ((\(ATS x) -> ATS $ reverse x) e) <$> endLet e')+ ("let" <$> indent 2 (pretty e) <$> endLet e')+ ("let" <+> pretty e <$> endLet e') a (BoolLitF True) = "true" a (BoolLitF False) = "false" a (TimeLitF s) = text s@@ -184,10 +184,10 @@ a (CharLitF c) = "'" <> char c <> "'" a (ProofExprF _ e e') = "(" <> e <+> "|" <+> e' <> ")" a (TypeSignatureF e t) = e <+> ":" <+> pretty t- a (WhereExpF e d) = e <+> "where" <$> braces (" " <> nest 2 (pretty (ATS $ reverse d)) <> " ")+ a (WhereExpF e d) = e <+> "where" <$> braces (" " <> nest 2 (pretty d) <> " ") a (TupleExF _ es) = parens (mconcat $ punctuate ", " (reverse es)) a (WhileF _ e e') = "while" <> parens e <> e'- a (ActionsF as) = "{" <$> indent 2 (pretty ((\(ATS x) -> ATS $ reverse x) as)) <$> "}"+ a (ActionsF as) = "{" <$> indent 2 (pretty as) <$> "}" a UnderscoreLitF{} = "_" a (BeginF _ e) | not (startsParens e) = linebreak <> indent 2 ("begin" <$> indent 2 e <$> "end")@@ -269,8 +269,8 @@ a (SPrecedeF e e') = e <> ";" <+> e' a (SUnaryF op e) = pretty op <> e a (SLetF _ e e') = flatAlt- ("let" <$> indent 2 (pretty ((ATS . reverse) e)) <$> endLet e')- ("let" <+> pretty ((ATS . reverse) e) <$> endLet e')+ ("let" <$> indent 2 (pretty e) <$> endLet e')+ ("let" <+> pretty e <$> endLet e') instance Pretty Sort where pretty (T0p ad) = "t@ype" <> pretty ad@@ -330,7 +330,7 @@ pretty (Universal bs ty es) = lbrace <+> mconcat (punctuate ", " (fmap pretty (reverse bs))) <> gan ty <> "|" <+> mconcat (punctuate "; " (fmap pretty es)) <+> rbrace instance Pretty ATS where- pretty (ATS xs) = concatSame (fmap rewriteDecl xs)+ pretty (ATS xs) = concatSame (fmap rewriteDecl (reverse xs)) prettyOr :: (Pretty a) => [[a]] -> Doc prettyOr [] = mempty@@ -361,6 +361,10 @@ glue Define{} Define{} = True glue Include{} Include{} = True glue ViewTypeDef{} ViewTypeDef{} = True+glue AbsViewType{} AbsViewType{} = True+glue AbsType{} AbsType{} = True+glue AbsType{} AbsViewType{} = True+glue AbsViewType{} AbsType{} = True glue TypeDef{} TypeDef{} = True glue Comment{} _ = True glue (Func _ Fnx{}) (Func _ And{}) = True@@ -580,7 +584,7 @@ pretty (Stacst _ n t Nothing) = "stacst" </> pretty n <+> ":" </> pretty t pretty (Stacst _ n t (Just e)) = "stacst" </> pretty n <+> ":" </> pretty t <+> "=" </> pretty e pretty (PropDef _ s as t) = "propdef" </> text s <+> prettyArgsNil as <+> "=" </> pretty t- pretty (Local _ d (ATS [])) = "local" <$> indent 2 (pretty d) <$> "in end"+ pretty (Local _ (ATS ds) (ATS [])) = "local" <$> indent 2 (pretty (ATS $ reverse ds)) <$> "in end" pretty (Local _ d d') = "local" <$> indent 2 (pretty d) <$> "in" <$> indent 2 (pretty d') <$> "end" pretty (FixityDecl f ss) = pretty f <+> hsep (fmap text ss) pretty (StaVal us i t) = "val" </> mconcat (fmap pretty us) <+> text i <+> ":" <+> pretty t
src/Language/ATS/Types.hs view
@@ -306,7 +306,7 @@ | Precede Expression Expression | ProofExpr AlexPosn Expression Expression | TypeSignature Expression Type- | WhereExp Expression [Declaration]+ | WhereExp Expression ATS | TupleEx AlexPosn [Expression] -- TODO support boxed tuples | While AlexPosn Expression Expression | Actions ATS