module Compiler.Lexer.Comments where import Common import Control.Applicative import Control.Monad import Data.Text as T import Parser import Test.Common newtype Comment = Comment Text deriving (Show, Eq) commentPrefix :: Text commentPrefix = "-- " instance HasParser Comment where parser = do void $ pText commentPrefix c <- many (nameParser "comment_char" $ pAny (\c -> c /= '\n')) (void $ pChar '\n') <|> eof incLine 1 pure $ Comment (pack c) instance ToSource Comment where toSourcePretty i (Comment c) = indent i <> commentPrefix <> c <> "\n" instance HasGen Comment where getGen = (Comment . T.append "comment_prefix") <$> (text (linear 0 50) (enum 'a' 'z'))