1
1
mirror of https://github.com/github/semantic.git synced 2024-12-21 22:01:46 +03:00

alternate with End in putRubyLocals

This commit is contained in:
Charlie Somerville 2018-04-04 19:07:03 +10:00
parent ccca1e5857
commit 237ffea294
2 changed files with 6 additions and 4 deletions

View File

@ -147,8 +147,10 @@ location = tracing Location `Then` return
getRubyLocals :: HasCallStack => Assignment ast grammar [ByteString]
getRubyLocals = tracing GetRubyLocals `Then` return
putRubyLocals :: HasCallStack => [ByteString] -> Assignment ast grammar ()
putRubyLocals l = tracing (PutRubyLocals l) `Then` return
putRubyLocals :: (HasCallStack, Enum grammar, Eq1 ast, Ix grammar) => [ByteString] -> Assignment ast grammar ()
putRubyLocals l = mk (PutRubyLocals l) <|> mk End
where
mk a = tracing a `Then` return
-- | Zero-width production of the current node.
currentNode :: HasCallStack => Assignment ast grammar (TermF ast (Node grammar) ())

View File

@ -147,14 +147,14 @@ expressions = makeTerm'' <$> location <*> many expression
parenthesizedExpressions :: Assignment
parenthesizedExpressions = makeTerm'' <$> symbol ParenthesizedStatements <*> children (Syntax.Paren <$> expressions)
withExtendedScope :: Assignment.Assignment ast grammar a -> Assignment.Assignment ast grammar a
withExtendedScope :: (Enum grammar, Ix grammar, Eq1 ast) => Assignment.Assignment ast grammar a -> Assignment.Assignment ast grammar a
withExtendedScope inner = do
locals <- getRubyLocals
result <- inner
putRubyLocals locals
pure result
withNewScope :: Assignment.Assignment ast grammar a -> Assignment.Assignment ast grammar a
withNewScope :: (Enum grammar, Ix grammar, Eq1 ast) => Assignment.Assignment ast grammar a -> Assignment.Assignment ast grammar a
withNewScope inner = withExtendedScope $ do
putRubyLocals []
inner