1
1
mirror of https://github.com/github/semantic.git synced 2025-01-02 20:41:38 +03:00

ruby: define locals as they are encountered

This commit is contained in:
Charlie Somerville 2018-03-20 17:14:38 +11:00
parent ba99be7345
commit 8dfaae81e1

View File

@ -379,8 +379,17 @@ assignment' = makeTerm <$> symbol Assignment <*> children (Statement.As
rhs = makeTerm <$> symbol RightAssignmentList <*> children (many expr) <|> expr
expr = makeTerm <$> symbol RestAssignment <*> (Syntax.Identifier . name <$> source)
<|> makeTerm <$> symbol DestructuredLeftAssignment <*> children (many expr)
<|> lhsIdent
<|> expression
lhsIdent :: Assignment
lhsIdent = do
sym <- symbol Identifier <|> symbol Identifier'
locals <- getRubyLocals
ident <- source
putRubyLocals (ident : locals)
pure $ makeTerm sym $ Syntax.Identifier $ name ident
unary :: Assignment
unary = symbol Unary >>= \ location ->
makeTerm location . Expression.Complement <$> children ( symbol AnonTilde *> expression )