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

Compute the expected symbols as the first set of the current assignment.

This commit is contained in:
Rob Rix 2017-08-04 14:12:55 -04:00
parent 38b9821c1d
commit c4a30e9fe6

View File

@ -300,8 +300,7 @@ runAssignment toNode source = (\ assignment state -> disamb Left (Right . minimu
Source -> None (makeError node)
state@State{..} = if not (null expectedSymbols) && all ((== Regular) . symbolType) expectedSymbols then dropAnonymous initialState else initialState
expectedSymbols | Choose choices _ <- assignment = (toEnum :: Int -> grammar) <$> IntMap.keys choices
| otherwise = []
expectedSymbols = firstSet (assignment `Then` return)
makeError :: HasCallStack => Maybe (Base ast ast) -> Error grammar
makeError node = maybe (Error statePos expectedSymbols Nothing) (nodeError expectedSymbols . toNode) node