1
1
mirror of https://github.com/github/semantic.git synced 2025-01-04 13:34:31 +03:00

Merge branch 'master' into bump-haskell-tree-sitter

This commit is contained in:
Rick Winfrey 2018-05-23 13:10:41 -07:00 committed by GitHub
commit bd3001a359
20 changed files with 73 additions and 61 deletions

View File

@ -29,6 +29,7 @@ data Comparison a
| GreaterThan !a !a
| GreaterThanEqual !a !a
| Equal !a !a
| StrictEqual !a !a
| Comparison !a !a
deriving (Diffable, Eq, Foldable, Functor, GAlign, Generic1, Hashable1, Mergeable, Ord, Show, Traversable, FreeVariables1, Declarations1)
@ -45,7 +46,10 @@ instance Evaluatable Comparison where
(LessThanEqual a b) -> liftComparison (Concrete (<=)) a b
(GreaterThan a b) -> liftComparison (Concrete (>)) a b
(GreaterThanEqual a b) -> liftComparison (Concrete (>=)) a b
-- TODO: in PHP and JavaScript, the equals operator performs type coercion.
-- We need some mechanism to customize this behavior per-language.
(Equal a b) -> liftComparison (Concrete (==)) a b
(StrictEqual a b) -> liftComparison (Concrete (==)) a b
(Comparison a b) -> liftComparison Generalized a b
-- | Binary arithmetic operators.

View File

@ -234,30 +234,32 @@ augmentedAssignmentExpression = makeTerm' <$> symbol AugmentedAssignmentExpressi
binaryExpression :: Assignment
binaryExpression = makeTerm' <$> symbol BinaryExpression <*> children (infixTerm expression (term (expression <|> classTypeDesignator))
[ (inject .) . Expression.And <$ symbol AnonAnd
, (inject .) . Expression.Or <$ symbol AnonOr
, (inject .) . Expression.XOr <$ symbol AnonXor
, (inject .) . Expression.Or <$ symbol AnonPipePipe
, (inject .) . Expression.And <$ symbol AnonAmpersandAmpersand
, (inject .) . Expression.BOr <$ symbol AnonPipe
, (inject .) . Expression.BXOr <$ symbol AnonCaret
, (inject .) . Expression.BAnd <$ symbol AnonAmpersand
, (inject .) . Expression.Or <$ symbol AnonQuestionQuestion -- Not sure if this is right.
, (inject .) . Expression.Equal <$ (symbol AnonEqualEqual <|> symbol AnonEqualEqualEqual)
, (inject .) . invert Expression.Equal <$ (symbol AnonBangEqual <|> symbol AnonLAngleRAngle <|> symbol AnonBangEqualEqual)
, (inject .) . Expression.LessThan <$ symbol AnonLAngle
, (inject .) . Expression.GreaterThan <$ symbol AnonRAngle
, (inject .) . Expression.LessThanEqual <$ symbol AnonLAngleEqual
, (inject .) . Expression.GreaterThanEqual <$ symbol AnonRAngleEqual
, (inject .) . Expression.Comparison <$ symbol AnonLAngleEqualRAngle
, (inject .) . Expression.LShift <$ symbol AnonLAngleLAngle
, (inject .) . Expression.RShift <$ symbol AnonRAngleRAngle
, (inject .) . Expression.Plus <$ symbol AnonPlus
, (inject .) . Expression.Minus <$ symbol AnonMinus
, (inject .) . Expression.Times <$ (symbol AnonStar <|> symbol AnonDot)
, (inject .) . Expression.DividedBy <$ symbol AnonSlash
, (inject .) . Expression.Modulo <$ symbol AnonPercent
, (inject .) . Expression.InstanceOf <$ symbol AnonInstanceof
[ (inject .) . Expression.And <$ symbol AnonAnd
, (inject .) . Expression.Or <$ symbol AnonOr
, (inject .) . Expression.XOr <$ symbol AnonXor
, (inject .) . Expression.Or <$ symbol AnonPipePipe
, (inject .) . Expression.And <$ symbol AnonAmpersandAmpersand
, (inject .) . Expression.BOr <$ symbol AnonPipe
, (inject .) . Expression.BXOr <$ symbol AnonCaret
, (inject .) . Expression.BAnd <$ symbol AnonAmpersand
, (inject .) . Expression.Or <$ symbol AnonQuestionQuestion -- Not sure if this is right.
, (inject .) . Expression.Equal <$ symbol AnonEqualEqual
, (inject .) . Expression.StrictEqual <$ symbol AnonEqualEqualEqual
, (inject .) . invert Expression.Equal <$ (symbol AnonBangEqual <|> symbol AnonLAngleRAngle <|> symbol AnonBangEqualEqual)
, (inject .) . invert Expression.StrictEqual <$ symbol AnonBangEqualEqual
, (inject .) . Expression.LessThan <$ symbol AnonLAngle
, (inject .) . Expression.GreaterThan <$ symbol AnonRAngle
, (inject .) . Expression.LessThanEqual <$ symbol AnonLAngleEqual
, (inject .) . Expression.GreaterThanEqual <$ symbol AnonRAngleEqual
, (inject .) . Expression.Comparison <$ symbol AnonLAngleEqualRAngle
, (inject .) . Expression.LShift <$ symbol AnonLAngleLAngle
, (inject .) . Expression.RShift <$ symbol AnonRAngleRAngle
, (inject .) . Expression.Plus <$ symbol AnonPlus
, (inject .) . Expression.Minus <$ symbol AnonMinus
, (inject .) . Expression.Times <$ (symbol AnonStar <|> symbol AnonDot)
, (inject .) . Expression.DividedBy <$ symbol AnonSlash
, (inject .) . Expression.Modulo <$ symbol AnonPercent
, (inject .) . Expression.InstanceOf <$ symbol AnonInstanceof
]) where invert cons a b = Expression.Not (makeTerm1 (cons a b))
conditionalExpression :: Assignment

View File

@ -455,6 +455,10 @@ binary = makeTerm' <$> symbol Binary <*> children (infixTerm expression expressi
, (inject .) . Ruby.Syntax.LowOr <$ symbol AnonOr
, (inject .) . Expression.BOr <$ symbol AnonPipe
, (inject .) . Expression.BXOr <$ symbol AnonCaret
-- TODO: AnonEqualEqualEqual corresponds to Ruby's "case equality"
-- function, which (unless overridden) is true if b is an instance
-- of or inherits from a. We need a custom equality operator
-- for this situation.
, (inject .) . Expression.Equal <$ (symbol AnonEqualEqual <|> symbol AnonEqualEqualEqual)
, (inject .) . invert Expression.Equal <$ symbol AnonBangEqual
, (inject .) . Expression.LShift <$ symbol AnonLAngleLAngle

View File

@ -832,27 +832,29 @@ tryStatement = makeTry <$> symbol TryStatement <*> children ((,,) <$> term state
binaryExpression :: Assignment
binaryExpression = makeTerm' <$> symbol BinaryExpression <*> children (infixTerm expression (term expression)
[ (inject .) . Expression.Plus <$ symbol AnonPlus
, (inject .) . Expression.Minus <$ symbol AnonMinus
, (inject .) . Expression.Times <$ symbol AnonStar
, (inject .) . Expression.DividedBy <$ symbol AnonSlash
, (inject .) . Expression.Modulo <$ symbol AnonPercent
, (inject .) . Expression.Member <$ symbol AnonIn
, (inject .) . Expression.And <$ symbol AnonAmpersandAmpersand
, (inject .) . Expression.BAnd <$ symbol AnonAmpersand
, (inject .) . Expression.Or <$ symbol AnonPipePipe
, (inject .) . Expression.BOr <$ symbol AnonPipe
, (inject .) . Expression.BXOr <$ symbol AnonCaret
, (inject .) . Expression.InstanceOf <$ symbol AnonInstanceof
, (inject .) . Expression.Equal <$ (symbol AnonEqualEqual <|> symbol AnonEqualEqualEqual)
, (inject .) . invert Expression.Equal <$ (symbol AnonBangEqual <|> symbol AnonBangEqualEqual)
, (inject .) . Expression.LShift <$ symbol AnonLAngleLAngle
, (inject .) . Expression.RShift <$ symbol AnonRAngleRAngle
, (inject .) . Expression.UnsignedRShift <$ symbol AnonRAngleRAngleRAngle
, (inject .) . Expression.LessThan <$ symbol AnonLAngle
, (inject .) . Expression.GreaterThan <$ symbol AnonRAngle
, (inject .) . Expression.LessThanEqual <$ symbol AnonLAngleEqual
, (inject .) . Expression.GreaterThanEqual <$ symbol AnonRAngleEqual
[ (inject .) . Expression.Plus <$ symbol AnonPlus
, (inject .) . Expression.Minus <$ symbol AnonMinus
, (inject .) . Expression.Times <$ symbol AnonStar
, (inject .) . Expression.DividedBy <$ symbol AnonSlash
, (inject .) . Expression.Modulo <$ symbol AnonPercent
, (inject .) . Expression.Member <$ symbol AnonIn
, (inject .) . Expression.And <$ symbol AnonAmpersandAmpersand
, (inject .) . Expression.BAnd <$ symbol AnonAmpersand
, (inject .) . Expression.Or <$ symbol AnonPipePipe
, (inject .) . Expression.BOr <$ symbol AnonPipe
, (inject .) . Expression.BXOr <$ symbol AnonCaret
, (inject .) . Expression.InstanceOf <$ symbol AnonInstanceof
, (inject .) . Expression.Equal <$ symbol AnonEqualEqual
, (inject .) . Expression.StrictEqual <$ symbol AnonEqualEqualEqual
, (inject .) . invert Expression.Equal <$ symbol AnonBangEqual
, (inject .) . invert Expression.StrictEqual <$ symbol AnonBangEqualEqual
, (inject .) . Expression.LShift <$ symbol AnonLAngleLAngle
, (inject .) . Expression.RShift <$ symbol AnonRAngleRAngle
, (inject .) . Expression.UnsignedRShift <$ symbol AnonRAngleRAngleRAngle
, (inject .) . Expression.LessThan <$ symbol AnonLAngle
, (inject .) . Expression.GreaterThan <$ symbol AnonRAngle
, (inject .) . Expression.LessThanEqual <$ symbol AnonLAngleEqual
, (inject .) . Expression.GreaterThanEqual <$ symbol AnonRAngleEqual
])
where invert cons a b = Expression.Not (makeTerm1 (cons a b))

View File

@ -10,7 +10,7 @@
(Identifier))
(
(If
(Equal
(StrictEqual
(Identifier)
(Float))
(

View File

@ -10,7 +10,7 @@
(Identifier))
(
(If
(Equal
(StrictEqual
(Identifier)
(Float))
(

View File

@ -10,7 +10,7 @@
(Identifier))
(
(If
(Equal
(StrictEqual
(Identifier)
(Float))
(

View File

@ -10,7 +10,7 @@
(Identifier))
(
(If
(Equal
(StrictEqual
(Identifier)
(Float))
(

View File

@ -10,7 +10,7 @@
(Identifier))
(
(If
(Equal
(StrictEqual
(Identifier)
(Float))
(

View File

@ -10,7 +10,7 @@
(Identifier))
(
(If
(Equal
(StrictEqual
(Identifier)
(Float))
(

View File

@ -10,7 +10,7 @@
(Identifier))
(
(If
(Equal
(StrictEqual
(Identifier)
(Float))
(

View File

@ -10,7 +10,7 @@
(Identifier))
(
(If
(Equal
(StrictEqual
(Identifier)
(Float))
(

View File

@ -10,7 +10,7 @@
(Identifier))
(
(If
(Equal
(StrictEqual
(Identifier)
(Float))
(

View File

@ -10,7 +10,7 @@
(Identifier))
(
(If
(Equal
(StrictEqual
(Identifier)
(Float))
(

View File

@ -10,7 +10,7 @@
(Identifier))
(
(If
(Equal
(StrictEqual
(Identifier)
(Float))
(

View File

@ -10,7 +10,7 @@
(Identifier))
(
(If
(Equal
(StrictEqual
(Identifier)
(Float))
(

View File

@ -10,7 +10,7 @@
(Identifier))
(
(If
(Equal
(StrictEqual
(Identifier)
(Float))
(

View File

@ -10,7 +10,7 @@
(Identifier))
(
(If
(Equal
(StrictEqual
(Identifier)
(Float))
(

View File

@ -10,7 +10,7 @@
(Identifier))
(
(If
(Equal
(StrictEqual
(Identifier)
(Float))
(

View File

@ -10,7 +10,7 @@
(Identifier))
(
(If
(Equal
(StrictEqual
(Identifier)
(Float))
(