1
1
mirror of https://github.com/github/semantic.git synced 2024-12-21 22:01:46 +03:00

mkNot helper function

This commit is contained in:
Timothy Clem 2017-06-19 11:07:40 -06:00
parent e2c2bedde2
commit f58d69c70b

View File

@ -217,21 +217,21 @@ unary = symbol Unary >>= \ location ->
binary :: Assignment binary :: Assignment
binary = symbol Binary >>= \ loc -> children $ statement >>= \ lexpression -> go loc lexpression binary = symbol Binary >>= \ loc -> children $ statement >>= \ lexpression -> go loc lexpression
where where
go loc lexpression = go loc lexpression
mk AnonAnd Expression.And = mk AnonAnd Expression.And
<|> mk AnonAmpersandAmpersand Expression.And <|> mk AnonAmpersandAmpersand Expression.And
<|> mk AnonOr Expression.Or <|> mk AnonOr Expression.Or
<|> mk AnonPipePipe Expression.Or <|> mk AnonPipePipe Expression.Or
<|> mk AnonLAngleLAngle Expression.LShift <|> mk AnonLAngleLAngle Expression.LShift
<|> mk AnonRAngleRAngle Expression.RShift <|> mk AnonRAngleRAngle Expression.RShift
<|> mk AnonEqualEqual Expression.Equal <|> mk AnonEqualEqual Expression.Equal
<|> makeTerm loc <$ symbol AnonBangEqual <*> (Expression.Not <$> (makeTerm <$> location <*> (Expression.Equal lexpression <$> statement))) <|> mkNot AnonBangEqual Expression.Equal
-- TODO: Distinguish `===` from `==` ? -- TODO: Distinguish `===` from `==` ?
<|> mk AnonEqualEqualEqual Expression.Equal <|> mk AnonEqualEqualEqual Expression.Equal
<|> mk AnonLAngleEqualRAngle Expression.Comparison <|> mk AnonLAngleEqualRAngle Expression.Comparison
-- TODO: Distinuish `=~` and `!~` ? -- TODO: Distinuish `=~` and `!~` ?
<|> mk AnonEqualTilde Expression.Equal <|> mk AnonEqualTilde Expression.Equal
<|> makeTerm loc <$ symbol AnonBangTilde <*> (Expression.Not <$> (makeTerm <$> location <*> (Expression.Equal lexpression <$> statement))) <|> mkNot AnonBangTilde Expression.Equal
<|> mk AnonLAngle Expression.LessThan <|> mk AnonLAngle Expression.LessThan
<|> mk AnonLAngleEqual Expression.LessThanEqual <|> mk AnonLAngleEqual Expression.LessThanEqual
<|> mk AnonRAngle Expression.GreaterThan <|> mk AnonRAngle Expression.GreaterThan
@ -246,6 +246,7 @@ binary = symbol Binary >>= \ loc -> children $ statement >>= \ lexpression -> go
<|> mk AnonPercent Expression.Modulo <|> mk AnonPercent Expression.Modulo
<|> mk AnonStarStar Expression.Power <|> mk AnonStarStar Expression.Power
where mk s constr = makeTerm loc <$> (symbol s *> (constr lexpression <$> statement)) where mk s constr = makeTerm loc <$> (symbol s *> (constr lexpression <$> statement))
mkNot s constr = makeTerm loc <$ symbol s <*> (Expression.Not <$> (makeTerm <$> location <*> (constr lexpression <$> statement)))
conditional :: Assignment conditional :: Assignment
conditional = makeTerm <$> symbol Conditional <*> children (Statement.If <$> statement <*> statement <*> statement) conditional = makeTerm <$> symbol Conditional <*> children (Statement.If <$> statement <*> statement <*> statement)