1
1
mirror of https://github.com/github/semantic.git synced 2024-12-30 02:14:20 +03:00

Flow alternative choices over multiple lines

This commit is contained in:
Rick Winfrey 2017-05-31 11:17:16 -07:00
parent 375e1d6a01
commit 359e28d2dd

View File

@ -61,11 +61,9 @@ instance Show1 Redirect where liftShowsPrec = genericLiftShowsPrec
assignment :: HasCallStack => Assignment (Node Grammar) (Term Syntax Location)
assignment = makeTerm <$> symbol Module <*> children (many declaration)
declaration :: HasCallStack => Assignment (Node Grammar) (Term Syntax Location)
declaration = comment <|> literal <|> statement <|> import' <|> importFrom
statement :: HasCallStack => Assignment (Node Grammar) (Term Syntax Location)
statement = expressionStatement
<|> ifStatement
@ -77,14 +75,21 @@ statement = expressionStatement
<|> assertStatement
<|> globalStatement
tuple :: HasCallStack => Assignment (Node Grammar) (Term Syntax Location)
tuple = makeTerm <$> symbol Tuple <*> children (Literal.Tuple <$> (many expression))
expressionStatement :: HasCallStack => Assignment (Node Grammar) (Term Syntax Location)
expressionStatement = symbol ExpressionStatement *> children expression
expression :: HasCallStack => Assignment (Node Grammar) (Term Syntax Location)
expression = statement <|> unaryOperator <|> binaryOperator <|> booleanOperator <|> tuple <|> literal <|> memberAccess <|> subscript
expression = statement
<|> unaryOperator
<|> binaryOperator
<|> booleanOperator
<|> tuple
<|> literal
<|> memberAccess
<|> subscript
tuple :: HasCallStack => Assignment (Node Grammar) (Term Syntax Location)
tuple = makeTerm <$> symbol Tuple <*> children (Literal.Tuple <$> (many expression))
-- TODO: Consider flattening single element lists
expressionList :: HasCallStack => Assignment (Node Grammar) (Term Syntax Location)