mirror of
https://github.com/github/semantic.git
synced 2024-12-22 14:21:31 +03:00
Flatten out argument into expression
This commit is contained in:
parent
20e9cb33a9
commit
d78a0db999
@ -83,45 +83,46 @@ assignment =
|
|||||||
|
|
||||||
expression :: Assignment
|
expression :: Assignment
|
||||||
expression =
|
expression =
|
||||||
beginBlock
|
alias
|
||||||
<|> endBlock
|
|
||||||
<|> comment
|
|
||||||
<|> undef
|
|
||||||
<|> alias
|
|
||||||
<|> if'
|
|
||||||
<|> unless
|
|
||||||
<|> while'
|
|
||||||
<|> until'
|
|
||||||
<|> case'
|
|
||||||
<|> emptyStatement
|
|
||||||
<|> assignment'
|
<|> assignment'
|
||||||
<|> unary
|
<|> begin
|
||||||
|
<|> beginBlock
|
||||||
<|> binary
|
<|> binary
|
||||||
<|> literal
|
<|> block
|
||||||
|
<|> call
|
||||||
|
<|> case'
|
||||||
|
<|> class'
|
||||||
|
<|> comment
|
||||||
|
<|> conditional
|
||||||
|
<|> emptyStatement
|
||||||
|
<|> endBlock
|
||||||
|
<|> for
|
||||||
|
<|> heredoc
|
||||||
|
<|> identifier
|
||||||
|
<|> if'
|
||||||
<|> keyword
|
<|> keyword
|
||||||
<|> mk Return Statement.Return
|
<|> lambda
|
||||||
<|> mk Yield Statement.Yield
|
<|> literal
|
||||||
|
<|> method
|
||||||
|
<|> methodCall
|
||||||
<|> mk Break Statement.Break
|
<|> mk Break Statement.Break
|
||||||
<|> mk Next Statement.Continue
|
<|> mk Next Statement.Continue
|
||||||
<|> mk Redo Statement.Retry
|
<|> mk Redo Statement.Retry
|
||||||
<|> mk Retry Statement.Retry
|
<|> mk Retry Statement.Retry
|
||||||
<|> for
|
<|> mk Return Statement.Return
|
||||||
<|> class'
|
<|> mk Yield Statement.Yield
|
||||||
<|> singletonClass
|
|
||||||
<|> method
|
|
||||||
<|> singletonMethod
|
|
||||||
<|> lambda
|
|
||||||
<|> module'
|
<|> module'
|
||||||
<|> identifier
|
<|> pair
|
||||||
<|> scopeResolution
|
|
||||||
<|> conditional
|
|
||||||
<|> methodCall
|
|
||||||
<|> call
|
|
||||||
<|> subscript
|
|
||||||
<|> begin
|
|
||||||
<|> rescue
|
<|> rescue
|
||||||
<|> block
|
<|> scopeResolution
|
||||||
<|> heredoc
|
<|> singletonClass
|
||||||
|
<|> singletonMethod
|
||||||
|
<|> subscript
|
||||||
|
<|> unary
|
||||||
|
<|> undef
|
||||||
|
<|> unless
|
||||||
|
<|> until'
|
||||||
|
<|> while'
|
||||||
<|> parseError
|
<|> parseError
|
||||||
where mk s construct = makeTerm <$> symbol s <*> children ((construct .) . fromMaybe <$> emptyTerm <*> optional (symbol ArgumentList *> children expression))
|
where mk s construct = makeTerm <$> symbol s <*> children ((construct .) . fromMaybe <$> emptyTerm <*> optional (symbol ArgumentList *> children expression))
|
||||||
|
|
||||||
@ -139,6 +140,9 @@ identifier =
|
|||||||
<|> mk Self
|
<|> mk Self
|
||||||
<|> mk Super
|
<|> mk Super
|
||||||
<|> mk Setter
|
<|> mk Setter
|
||||||
|
<|> mk SplatArgument
|
||||||
|
<|> mk HashSplatArgument
|
||||||
|
<|> mk BlockArgument
|
||||||
<|> mk ReservedIdentifier
|
<|> mk ReservedIdentifier
|
||||||
<|> mk Uninterpreted
|
<|> mk Uninterpreted
|
||||||
where mk s = makeTerm <$> symbol s <*> (Syntax.Identifier <$> source)
|
where mk s = makeTerm <$> symbol s <*> (Syntax.Identifier <$> source)
|
||||||
@ -274,24 +278,15 @@ case' = makeTerm <$> symbol Case <*> children (Statement.Match <$> expression <*
|
|||||||
pattern = symbol Pattern *> children ((symbol SplatArgument *> children expression) <|> expression)
|
pattern = symbol Pattern *> children ((symbol SplatArgument *> children expression) <|> expression)
|
||||||
|
|
||||||
subscript :: Assignment
|
subscript :: Assignment
|
||||||
subscript = makeTerm <$> symbol ElementReference <*> children (Expression.Subscript <$> expression <*> many argument)
|
subscript = makeTerm <$> symbol ElementReference <*> children (Expression.Subscript <$> expression <*> many expression)
|
||||||
|
|
||||||
pair :: Assignment
|
pair :: Assignment
|
||||||
pair = makeTerm <$> symbol Pair <*> children (Literal.KeyValue <$> expression <*> expression)
|
pair = makeTerm <$> symbol Pair <*> children (Literal.KeyValue <$> expression <*> expression)
|
||||||
|
|
||||||
argument :: Assignment
|
|
||||||
argument =
|
|
||||||
mk SplatArgument
|
|
||||||
<|> mk HashSplatArgument
|
|
||||||
<|> mk BlockArgument
|
|
||||||
<|> pair
|
|
||||||
<|> expression
|
|
||||||
where mk s = makeTerm <$> symbol s <*> (Syntax.Identifier <$> source)
|
|
||||||
|
|
||||||
methodCall :: Assignment
|
methodCall :: Assignment
|
||||||
methodCall = makeTerm <$> symbol MethodCall <*> children (Expression.Call <$> expression <*> args <*> (block <|> emptyTerm))
|
methodCall = makeTerm <$> symbol MethodCall <*> children (Expression.Call <$> expression <*> args <*> (block <|> emptyTerm))
|
||||||
where
|
where
|
||||||
args = (symbol ArgumentList <|> symbol ArgumentListWithParens) *> children (many argument) <|> pure []
|
args = (symbol ArgumentList <|> symbol ArgumentListWithParens) *> children (many expression) <|> pure []
|
||||||
|
|
||||||
call :: Assignment
|
call :: Assignment
|
||||||
call = makeTerm <$> symbol Call <*> children (Expression.MemberAccess <$> expression <*> expression)
|
call = makeTerm <$> symbol Call <*> children (Expression.MemberAccess <$> expression <*> expression)
|
||||||
@ -333,7 +328,7 @@ assignment'
|
|||||||
expr =
|
expr =
|
||||||
makeTerm <$> symbol RestAssignment <*> (Syntax.Identifier <$> source)
|
makeTerm <$> symbol RestAssignment <*> (Syntax.Identifier <$> source)
|
||||||
<|> makeTerm <$> symbol DestructuredLeftAssignment <*> children (many expr)
|
<|> makeTerm <$> symbol DestructuredLeftAssignment <*> children (many expr)
|
||||||
<|> argument
|
<|> expression
|
||||||
|
|
||||||
unary :: Assignment
|
unary :: Assignment
|
||||||
unary = symbol Unary >>= \ location ->
|
unary = symbol Unary >>= \ location ->
|
||||||
|
Loading…
Reference in New Issue
Block a user