mirror of
https://github.com/github/semantic.git
synced 2024-12-21 05:41:54 +03:00
Go back to original Syntax.Empty
This commit is contained in:
parent
2c5b12f8de
commit
f87a5039a7
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user