From 2239d4240cb8754b4874292aeb38a9c2f9d0991b Mon Sep 17 00:00:00 2001 From: Rob Rix Date: Fri, 19 May 2017 13:31:47 -0400 Subject: [PATCH] Define an AST parser. --- src/Parser.hs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Parser.hs b/src/Parser.hs index 3b4a6ac5e..62cad43c1 100644 --- a/src/Parser.hs +++ b/src/Parser.hs @@ -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