mirror of
https://github.com/github/semantic.git
synced 2024-12-29 18:06:14 +03:00
Show all errors in assigned terms.
This commit is contained in:
parent
5a37e17a6c
commit
a4cfd49e5c
@ -30,7 +30,7 @@ data Parser term where
|
||||
-- | A parser producing 'AST' using a 'TS.Language'.
|
||||
ASTParser :: (Bounded grammar, Enum grammar) => Ptr TS.Language -> Parser (AST grammar)
|
||||
-- | A parser producing an à la carte term given an 'AST'-producing parser and an 'Assignment' onto 'Term's in some syntax type. Assignment errors will result in a top-level 'Syntax.Error' node.
|
||||
AssignmentParser :: (Bounded grammar, Enum grammar, Eq grammar, Show grammar, Symbol grammar, InUnion fs (Syntax.Error (Error grammar)))
|
||||
AssignmentParser :: (Bounded grammar, Enum grammar, Eq grammar, Show grammar, Symbol grammar, InUnion fs (Syntax.Error (Error grammar)), Functor (Union fs))
|
||||
=> Parser (AST grammar) -- ^ A parser producing 'AST'.
|
||||
-> Assignment (Node grammar) (Term (Union fs) Location) -- ^ An assignment from 'AST' onto 'Term's.
|
||||
-> Parser (Term (Union fs) Location) -- ^ A parser of 'Term's.
|
||||
@ -65,7 +65,11 @@ runParser parser = case parser of
|
||||
ast <- runParser parser source
|
||||
let Result err term = assign assignment source ast
|
||||
traverse_ (putStr . ($ "") . showError source) err
|
||||
pure (fromMaybe (cofree ((totalRange source :. totalSpan source :. Nil) :< inj (Syntax.Error (fromMaybe (Error (SourcePos 0 0) (UnexpectedEndOfInput [])) err)))) term)
|
||||
case term of
|
||||
Just term -> do
|
||||
traverse_ (putStr . ($ "") . showError source) (termErrors term `asTypeOf` toList err)
|
||||
pure term
|
||||
Nothing -> pure $! cofree ((totalRange source :. totalSpan source :. Nil) :< inj (Syntax.Error (fromMaybe (Error (SourcePos 0 0) (UnexpectedEndOfInput [])) err)))
|
||||
TreeSitterParser language tslanguage -> treeSitterParser language tslanguage
|
||||
MarkdownParser -> cmarkParser
|
||||
LineByLineParser -> lineByLineParser
|
||||
|
Loading…
Reference in New Issue
Block a user