ats-format 0.1.0.21 → 0.1.0.22
raw patch · 5 files changed
+17/−7 lines, 5 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- ats-format.cabal +1/−1
- man/atsfmt.1 +1/−1
- src/Language/ATS/Lexer.x +4/−0
- src/Language/ATS/Parser.y +4/−2
- src/Language/ATS/PrettyPrint.hs +7/−3
ats-format.cabal view
@@ -1,5 +1,5 @@ name: ats-format-version: 0.1.0.21+version: 0.1.0.22 synopsis: A source-code formatter for ATS description: An opinionated source-code formatter for [ATS](http://www.ats-lang.org/). homepage: https://hub.darcs.net/vmchale/ats-format#readme
man/atsfmt.1 view
@@ -1,4 +1,4 @@-.\" Automatically generated by Pandoc 2.0.6+.\" Automatically generated by Pandoc 2.1 .\" .TH "atsfmt (1)" "" "" "" "" .hy
src/Language/ATS/Lexer.x view
@@ -15,6 +15,7 @@ , Addendum (..) , lexATS , token_posn+ , to_string ) where import Data.Data (Typeable, Data)@@ -436,6 +437,9 @@ pretty DoubleBracesTok{} = "{}" pretty DoubleBracketTok{} = "<>" pretty SpecialBracket{} = "{"++to_string (CommentLex _ s) = s+to_string _ = mempty token_posn (Identifier p _) = p token_posn (IdentifierSpace p _) = p
src/Language/ATS/Parser.y view
@@ -15,6 +15,7 @@ , Keyword (..) , Addendum (..) , token_posn+ , to_string ) import Data.Char (toLower)@@ -166,7 +167,7 @@ openExistential { Operator $$ "#[" } -- Same as `[` in ATS2 cblock { CBlockLex _ $$ } define { MacroBlock _ $$ }- lineComment { CommentLex _ $$ }+ lineComment { $$@CommentLex{} } lspecial { SpecialBracket $$ } atbrace { Operator $$ "@{" } mod { Keyword $$ KwMod }@@ -398,6 +399,7 @@ | prfTransform {% Left $ Expected $1 "Expression" ">>" } | maybeProof {% Left $ Expected $1 "Expression" "?" } | let openParen {% Left $ Expected $1 "Expression" "let (" }+ | let ATS in Expression lineComment {% Left $ Expected (token_posn $5) "end" (take 2 $ to_string $5) } -- | Parse a termetric Termetric : openTermetric StaticExpression closeTermetric { ($1, $2) }@@ -596,7 +598,7 @@ | define identifierSpace string { Define ($1 ++ $2 ++ $3) } -- FIXME better approach? | define identifierSpace int { Define ($1 ++ $2 ++ " " ++ show $3) } | cblock { CBlock $1 }- | lineComment { Comment $1 }+ | lineComment { Comment (to_string $1) } | staload underscore eq string { Staload (Just "_") $4 } | staload string { Staload Nothing $2 } | staload IdentifierOr eq string { Staload (Just $2) $4 }
src/Language/ATS/PrettyPrint.hs view
@@ -126,8 +126,12 @@ pretty = cata a . rewriteATS where 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 (Just e')) = "let" <$> indent 2 (pretty ((\(ATS x) -> ATS $ reverse x) e)) <$> "in" <$> indent 2 e' <$> "end" -- TODO soft linebreak?- a (LetF _ e Nothing) = "let" <$> indent 2 (pretty ((\(ATS x) -> ATS $ reverse x) e)) <$> "in end"+ a (LetF _ e (Just e')) = flatAlt+ ("let" <$> indent 2 (pretty ((\(ATS x) -> ATS $ reverse x) e)) <$> "in" <$> indent 2 e' <$> "end")+ ("let" <+> pretty ((\(ATS x) -> ATS $ reverse x) e) <$> "in" <+> e' <$> "end")+ a (LetF _ e Nothing) = flatAlt+ ("let" <$> indent 2 (pretty ((\(ATS x) -> ATS $ reverse x) e)) <$> "in end")+ ("let" <+> pretty ((\(ATS x) -> ATS $ reverse x) e) <$> "in end") a (BoolLitF True) = "true" a (BoolLitF False) = "false" a (TimeLitF s) = string s@@ -170,7 +174,7 @@ 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 d)) <> " ")+ a (WhereExpF e d) = e <+> "where" <$> braces (" " <> nest 2 (pretty (ATS $ reverse d)) <> " ") a (TupleExF _ es) = prettyArgs 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)) <$> "}"