1
1
mirror of https://github.com/github/semantic.git synced 2024-12-23 14:54:16 +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.Else
, Statement.Pattern , Statement.Pattern
, Statement.Match , Statement.Match
, Syntax.LabeledStatement
, [] ] , [] ]
type Term = Term.Term (Data.Union.Union Syntax) (Record Location) type Term = Term.Term (Data.Union.Union Syntax) (Record Location)
@ -144,8 +145,8 @@ statement = handleError everything
where where
everything = choice [ everything = choice [
compoundStatement compoundStatement
-- , namedLabelStatement , namedLabelStatement
-- , expressionStatement , expressionStatement
, selectionStatement , selectionStatement
, jumpStatement , jumpStatement
, tryStatement , tryStatement
@ -474,6 +475,11 @@ castExpression = makeTerm <$> symbol CastExpression <*> children (flip Expressio
castType :: Assignment castType :: Assignment
castType = makeTerm <$> symbol CastType <*> (Syntax.CastType <$> source) 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 :: Assignment
selectionStatement = ifStatement <|> switchStatement selectionStatement = ifStatement <|> switchStatement

View File

@ -375,3 +375,10 @@ newtype Declare a = Declare a
instance Eq1 Declare where liftEq = genericLiftEq instance Eq1 Declare where liftEq = genericLiftEq
instance Ord1 Declare where liftCompare = genericLiftCompare instance Ord1 Declare where liftCompare = genericLiftCompare
instance Show1 Declare where liftShowsPrec = genericLiftShowsPrec 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