1
1
mirror of https://github.com/github/semantic.git synced 2024-12-23 06:41:45 +03:00

Add labeled statement and expression statement

This commit is contained in:
joshvera 2018-01-11 17:25:06 -05:00
parent 58524f75bc
commit c4f4ea464d
2 changed files with 15 additions and 2 deletions

View File

@ -117,6 +117,7 @@ type Syntax = '[
, Statement.Else
, Statement.Pattern
, Statement.Match
, Syntax.LabeledStatement
, [] ]
type Term = Term.Term (Data.Union.Union Syntax) (Record Location)
@ -144,8 +145,8 @@ statement = handleError everything
where
everything = choice [
compoundStatement
-- , namedLabelStatement
-- , expressionStatement
, namedLabelStatement
, expressionStatement
, selectionStatement
, jumpStatement
, tryStatement
@ -474,6 +475,11 @@ castExpression = makeTerm <$> symbol CastExpression <*> children (flip Expressio
castType :: Assignment
castType = makeTerm <$> symbol CastType <*> (Syntax.CastType <$> source)
expressionStatement :: Assignment
expressionStatement = symbol ExpressionStatement *> children (term expression)
namedLabelStatement :: Assignment
namedLabelStatement = makeTerm <$> symbol NamedLabelStatement <*> children (Syntax.LabeledStatement <$> name)
selectionStatement :: Assignment
selectionStatement = ifStatement <|> switchStatement

View File

@ -375,3 +375,10 @@ newtype Declare a = Declare a
instance Eq1 Declare where liftEq = genericLiftEq
instance Ord1 Declare where liftCompare = genericLiftCompare
instance Show1 Declare where liftShowsPrec = genericLiftShowsPrec
data LabeledStatement a = LabeledStatement { _labeledStatementIdentifier :: a }
deriving (Diffable, Eq, Foldable, Functor, GAlign, Generic1, Mergeable, Ord, Show, Traversable)
instance Eq1 LabeledStatement where liftEq = genericLiftEq
instance Ord1 LabeledStatement where liftCompare = genericLiftCompare
instance Show1 LabeledStatement where liftShowsPrec = genericLiftShowsPrec