mirror of
https://github.com/github/semantic.git
synced 2024-12-23 14:54:16 +03:00
Merge pull request #1216 from github/parse-errors-as-maximal-symbol
Parse errors as maximal symbol
This commit is contained in:
commit
55cfa89ddf
@ -53,13 +53,13 @@ parseToAST language source = bracket ts_document_new ts_document_free $ \ docume
|
||||
|
||||
anaM toAST root
|
||||
|
||||
toAST :: (Bounded grammar, Enum grammar) => Node -> IO (Base (A.AST grammar) Node)
|
||||
toAST :: forall grammar . (Bounded grammar, Enum grammar) => Node -> IO (Base (A.AST grammar) Node)
|
||||
toAST node@Node{..} = do
|
||||
let count = fromIntegral nodeChildCount
|
||||
children <- allocaArray count $ \ childNodesPtr -> do
|
||||
_ <- with nodeTSNode (\ nodePtr -> ts_node_copy_child_nodes nullPtr nodePtr childNodesPtr (fromIntegral count))
|
||||
peekArray count childNodesPtr
|
||||
pure $! A.Node (toEnum (fromIntegral nodeSymbol)) (nodeRange node) (nodeSpan node) :< children
|
||||
pure $! A.Node (toEnum (min (fromIntegral nodeSymbol) (fromEnum (maxBound :: grammar)))) (nodeRange node) (nodeSpan node) :< children
|
||||
|
||||
anaM :: (Corecursive t, Monad m, Traversable (Base t)) => (a -> m (Base t a)) -> a -> m t
|
||||
anaM g = a where a = pure . embed <=< traverse a <=< g
|
||||
|
2
vendor/haskell-tree-sitter
vendored
2
vendor/haskell-tree-sitter
vendored
@ -1 +1 @@
|
||||
Subproject commit 17c44abac3f72acc26615cb3299d2924671326c7
|
||||
Subproject commit 5607136d25485b82159412948e7933f548381a12
|
Loading…
Reference in New Issue
Block a user