1
1
mirror of https://github.com/github/semantic.git synced 2024-12-23 23:11:50 +03:00

Merge pull request #1216 from github/parse-errors-as-maximal-symbol

Parse errors as maximal symbol
This commit is contained in:
Josh Vera 2017-07-14 15:10:18 -04:00 committed by GitHub
commit 55cfa89ddf
2 changed files with 3 additions and 3 deletions

View File

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

@ -1 +1 @@
Subproject commit 17c44abac3f72acc26615cb3299d2924671326c7
Subproject commit 5607136d25485b82159412948e7933f548381a12