1
1
mirror of https://github.com/github/semantic.git synced 2024-12-21 13:51:44 +03:00

Go back to original Syntax.Empty

This commit is contained in:
Timothy Clem 2017-07-12 08:18:03 -07:00
parent 2c5b12f8de
commit f87a5039a7
3 changed files with 6 additions and 6 deletions

View File

@ -36,7 +36,7 @@ instance Show1 Identifier where liftShowsPrec = genericLiftShowsPrec
-- | Empty syntax, with essentially no-op semantics.
--
-- This can be used to represent an implicit no-op, e.g. the alternative in an 'if' statement without an 'else'.
data Empty a = Empty (Maybe ByteString)
data Empty a = Empty
deriving (Eq, Foldable, Functor, GAlign, Generic1, Show, Traversable)
instance Eq1 Empty where liftEq _ _ _ = True

View File

@ -203,8 +203,8 @@ functionDefinition = (symbol FunctionDefinition >>= \ loc -> children (makeFunc
<|> (symbol AsyncFunctionDefinition >>= \ loc -> children (makeAsyncFunctionDeclaration loc <$> async' <*> identifier <*> (symbol Parameters *> children (many expression)) <*> (optional (symbol Type *> children expression)) <*> (makeTerm <$> location <*> many declaration)))
<|> (symbol Lambda >>= \ loc -> children (makeFunctionDeclaration loc <$> (makeTerm <$> symbol AnonLambda <*> (Syntax.Identifier <$> source)) <*> ((symbol LambdaParameters *> children (many expression)) <|> (pure [])) <*> (optional (symbol Type *> children expression)) <*> (makeTerm <$> location <*> many declaration)))
where
makeFunctionDeclaration loc functionName' functionParameters ty functionBody = makeTerm loc $ Type.Annotation (makeTerm loc $ Declaration.Function functionName' functionParameters functionBody) (maybe (makeTerm loc (Syntax.Empty Nothing)) identity ty)
makeAsyncFunctionDeclaration loc async' functionName' functionParameters ty functionBody = makeTerm loc $ Type.Annotation (makeTerm loc $ Type.Annotation (makeTerm loc $ Declaration.Function functionName' functionParameters functionBody) (maybe (makeTerm loc (Syntax.Empty Nothing)) identity ty)) async'
makeFunctionDeclaration loc functionName' functionParameters ty functionBody = makeTerm loc $ Type.Annotation (makeTerm loc $ Declaration.Function functionName' functionParameters functionBody) (maybe (makeTerm loc Syntax.Empty) identity ty)
makeAsyncFunctionDeclaration loc async' functionName' functionParameters ty functionBody = makeTerm loc $ Type.Annotation (makeTerm loc $ Type.Annotation (makeTerm loc $ Declaration.Function functionName' functionParameters functionBody) (maybe (makeTerm loc Syntax.Empty) identity ty)) async'
async' :: Assignment
async' = makeTerm <$> symbol AnonAsync <*> (Syntax.Identifier <$> source)
@ -449,7 +449,7 @@ makeTerm :: (HasCallStack, f :< fs) => a -> f (Term.Term (Union fs) a) -> Term.T
makeTerm a f = cofree (a :< inj f)
emptyTerm :: Assignment
emptyTerm = makeTerm <$> location <*> pure (Syntax.Empty Nothing)
emptyTerm = makeTerm <$> location <*> pure Syntax.Empty
handleError :: Assignment -> Assignment
handleError = flip catchError $ \ error -> case errorCause error of

View File

@ -386,7 +386,7 @@ conditional :: Assignment
conditional = makeTerm <$> symbol Conditional <*> children (Statement.If <$> statement <*> statement <*> statement)
emptyStatement :: Assignment
emptyStatement = makeTerm <$> symbol EmptyStatement <*> (Syntax.Empty <$> (Just <$> source))
emptyStatement = makeTerm <$> symbol EmptyStatement <*> pure Syntax.Empty
-- Helper functions
@ -395,7 +395,7 @@ makeTerm :: (f :< fs, HasCallStack) => a -> f (Term.Term (Union fs) a) -> Term.T
makeTerm a f = cofree $ a :< inj f
emptyTerm :: Assignment
emptyTerm = makeTerm <$> location <*> pure (Syntax.Empty Nothing)
emptyTerm = makeTerm <$> location <*> pure Syntax.Empty
invert :: (Expression.Boolean :< fs, HasCallStack) => Assignment.Assignment ast grammar (Term.Term (Union fs) (Record Location)) -> Assignment.Assignment ast grammar (Term.Term (Union fs) (Record Location))
invert term = makeTerm <$> location <*> fmap Expression.Not term