mirror of
https://github.com/github/semantic.git
synced 2024-12-03 00:16:52 +03:00
Move parserForLanguage into the Parser module.
This commit is contained in:
parent
4958387ee4
commit
748ea87c85
@ -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
|
||||
|
@ -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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user