mirror of
https://github.com/github/semantic.git
synced 2024-12-30 10:27:45 +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
|
import TreeSitter
|
||||||
|
|
||||||
data Parser term where
|
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)
|
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)
|
CParser :: Parser (SyntaxTerm Text DefaultFields)
|
||||||
GoParser :: 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 term -> Source -> IO term
|
||||||
runParser parser = case parser of
|
runParser parser = case parser of
|
||||||
|
ASTParser language -> parseToAST language
|
||||||
ALaCarteParser language assignment -> \ source -> do
|
ALaCarteParser language assignment -> \ source -> do
|
||||||
ast <- parseToAST language source
|
ast <- parseToAST language source
|
||||||
let Result errors term = assign assignment source ast
|
let Result errors term = assign assignment source ast
|
||||||
|
Loading…
Reference in New Issue
Block a user