mirror of
https://github.com/github/semantic.git
synced 2025-01-05 05:58:34 +03:00
ruby: define locals as they are encountered
This commit is contained in:
parent
ba99be7345
commit
8dfaae81e1
@ -379,8 +379,17 @@ assignment' = makeTerm <$> symbol Assignment <*> children (Statement.As
|
|||||||
rhs = makeTerm <$> symbol RightAssignmentList <*> children (many expr) <|> expr
|
rhs = makeTerm <$> symbol RightAssignmentList <*> children (many expr) <|> expr
|
||||||
expr = makeTerm <$> symbol RestAssignment <*> (Syntax.Identifier . name <$> source)
|
expr = makeTerm <$> symbol RestAssignment <*> (Syntax.Identifier . name <$> source)
|
||||||
<|> makeTerm <$> symbol DestructuredLeftAssignment <*> children (many expr)
|
<|> makeTerm <$> symbol DestructuredLeftAssignment <*> children (many expr)
|
||||||
|
<|> lhsIdent
|
||||||
<|> expression
|
<|> 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 :: Assignment
|
||||||
unary = symbol Unary >>= \ location ->
|
unary = symbol Unary >>= \ location ->
|
||||||
makeTerm location . Expression.Complement <$> children ( symbol AnonTilde *> expression )
|
makeTerm location . Expression.Complement <$> children ( symbol AnonTilde *> expression )
|
||||||
|
Loading…
Reference in New Issue
Block a user