mirror of
https://github.com/github/semantic.git
synced 2024-12-30 10:27:45 +03:00
Remove need for Binary and Unary - just use operator instead.
This commit is contained in:
parent
97c17a1b5c
commit
048ac119ed
@ -258,8 +258,6 @@ toTermName source term = case unwrap term of
|
||||
S.Rescue args _ -> intercalate ", " $ toTermName' <$> args
|
||||
S.Break expr -> toTermName' expr
|
||||
S.Continue expr -> toTermName' expr
|
||||
S.Binary clauses -> termNameFromChildren term clauses
|
||||
S.Unary clauses -> termNameFromChildren term clauses
|
||||
where toTermName' = toTermName source
|
||||
termNameFromChildren term children = termNameFromRange (unionRangesFrom (range term) (range <$> children))
|
||||
termNameFromSource term = termNameFromRange (range term)
|
||||
|
@ -40,15 +40,10 @@ termConstructor source sourceSpan name range children allChildren
|
||||
condition <- withRecord (setCategory (extract expr) Negate) (S.Negate expr)
|
||||
withDefaultInfo $ S.While condition rest
|
||||
_ -> withDefaultInfo $ S.Error children
|
||||
| name == "binary" = case children of
|
||||
| name `elem` ["binary", "unary"] = case children of
|
||||
[ _, _ ] -> do
|
||||
allChildren' <- allChildren
|
||||
withDefaultInfo $ S.Binary allChildren'
|
||||
_ -> withDefaultInfo $ S.Error children
|
||||
| name == "unary" = case children of
|
||||
[ _ ] -> do
|
||||
allChildren' <- allChildren
|
||||
withDefaultInfo $ S.Unary allChildren'
|
||||
withDefaultInfo $ S.Operator allChildren'
|
||||
_ -> withDefaultInfo $ S.Error children
|
||||
| otherwise = withDefaultInfo $ case (name, children) of
|
||||
("argument_pair", [ k, v ] ) -> S.Pair k v
|
||||
|
@ -145,6 +145,4 @@ syntaxToTermField syntax = case syntax of
|
||||
S.TypeConversion a b -> childrenFields [a, b]
|
||||
S.Break expr -> [ "expression" .= expr ]
|
||||
S.Continue expr -> [ "expression" .= expr ]
|
||||
S.Binary expressions -> [ "expressions" .= expressions ]
|
||||
S.Unary expr -> [ "expression" .= expr ]
|
||||
where childrenFields c = [ "children" .= c ]
|
||||
|
@ -89,10 +89,6 @@ data Syntax a f
|
||||
| TypeConversion f f
|
||||
| Break f
|
||||
| Continue f
|
||||
-- | A binary statement has two terms separated by an unamed operator production.
|
||||
| Binary [f]
|
||||
-- | A unary statement has one term prefixed by an unamed operator production.
|
||||
| Unary [f]
|
||||
deriving (Eq, Foldable, Functor, Generic, Generic1, Mergeable, Ord, Show, Traversable, ToJSON)
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user