diff --git a/src/Parser.hs b/src/Parser.hs index 90e20e4a9..3413cac5b 100644 --- a/src/Parser.hs +++ b/src/Parser.hs @@ -24,6 +24,16 @@ data Parser term where TypeScriptParser :: Parser (SyntaxTerm Text DefaultFields) LineByLineParser :: Parser (SyntaxTerm Text DefaultFields) +-- | Return a parser for a given langauge or the lineByLineParser parser. +parserForLanguage :: Maybe Language -> Parser (SyntaxTerm Text DefaultFields) +parserForLanguage Nothing = LineByLineParser +parserForLanguage (Just language) = case language of + C -> CParser + TypeScript -> TypeScriptParser + Markdown -> MarkdownParser + Ruby -> RubyParser + Language.Go -> GoParser + runParser :: Parser term -> SourceBlob -> IO term runParser parser = case parser of CParser -> treeSitterParser C tree_sitter_c diff --git a/src/Semantic.hs b/src/Semantic.hs index 915c07bc7..c693e436f 100644 --- a/src/Semantic.hs +++ b/src/Semantic.hs @@ -14,7 +14,6 @@ import Data.Record import Diff import Info import Interpreter -import Language import Patch import Parser import Prologue @@ -69,16 +68,6 @@ parseBlobs renderer blobs = do parseBlob :: SourceBlob -> IO (Term (Syntax Text) (Record DefaultFields)) parseBlob blob@SourceBlob{..} = runParser (parserForLanguage blobLanguage) blob --- | Return a parser for a given langauge or the lineByLineParser parser. -parserForLanguage :: Maybe Language -> Parser (SyntaxTerm Text DefaultFields) -parserForLanguage Nothing = LineByLineParser -parserForLanguage (Just language) = case language of - C -> CParser - TypeScript -> TypeScriptParser - Markdown -> MarkdownParser - Ruby -> RubyParser - Language.Go -> GoParser - -- Internal