mirror of
https://github.com/github/semantic.git
synced 2024-12-21 05:41:54 +03:00
Define an AST parser.
This commit is contained in:
parent
2224df586d
commit
2239d4240c
@ -23,6 +23,7 @@ import Text.Parser.TreeSitter.TypeScript
|
||||
import TreeSitter
|
||||
|
||||
data Parser term where
|
||||
ASTParser :: (Bounded grammar, Enum grammar) => Ptr TS.Language -> Parser (AST grammar)
|
||||
ALaCarteParser :: (InUnion fs (Syntax.Error [Error grammar]), Bounded grammar, Enum grammar, Eq grammar, Symbol grammar) => Ptr TS.Language -> Assignment (Node grammar) (Term (Union fs) Location) -> Parser (Term (Union fs) Location)
|
||||
CParser :: Parser (SyntaxTerm Text DefaultFields)
|
||||
GoParser :: Parser (SyntaxTerm Text DefaultFields)
|
||||
@ -43,6 +44,7 @@ parserForLanguage (Just language) = case language of
|
||||
|
||||
runParser :: Parser term -> Source -> IO term
|
||||
runParser parser = case parser of
|
||||
ASTParser language -> parseToAST language
|
||||
ALaCarteParser language assignment -> \ source -> do
|
||||
ast <- parseToAST language source
|
||||
let Result errors term = assign assignment source ast
|
||||
|
Loading…
Reference in New Issue
Block a user