1
1
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:
Rob Rix 2017-05-19 13:31:47 -04:00
parent 2224df586d
commit 2239d4240c

View File

@ -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