mirror of
https://github.com/github/semantic.git
synced 2024-12-29 01:42:43 +03:00
Assign exec statements
This commit is contained in:
parent
7cb37aad74
commit
833b02b94a
@ -30,6 +30,12 @@ newtype Pattern a = Pattern a
|
|||||||
instance Eq1 Pattern where liftEq = genericLiftEq
|
instance Eq1 Pattern where liftEq = genericLiftEq
|
||||||
instance Show1 Pattern where liftShowsPrec = genericLiftShowsPrec
|
instance Show1 Pattern where liftShowsPrec = genericLiftShowsPrec
|
||||||
|
|
||||||
|
-- | Evaluate (e.g. exec in Python, or eval in Ruby)
|
||||||
|
data Evaluate a = Evaluate { evaluateExpression :: !a, evaluateContext :: !(Maybe [a]) }
|
||||||
|
deriving (Eq, Foldable, Functor, GAlign, Generic1, Show, Traversable)
|
||||||
|
|
||||||
|
instance Eq1 Evaluate where liftEq = genericLiftEq
|
||||||
|
instance Show1 Evaluate where liftShowsPrec = genericLiftShowsPrec
|
||||||
|
|
||||||
-- Assignment
|
-- Assignment
|
||||||
|
|
||||||
|
@ -55,6 +55,7 @@ type Syntax' =
|
|||||||
, Statement.Assignment
|
, Statement.Assignment
|
||||||
, Statement.Break
|
, Statement.Break
|
||||||
, Statement.Continue
|
, Statement.Continue
|
||||||
|
, Statement.Evaluate
|
||||||
, Statement.If
|
, Statement.If
|
||||||
, Statement.NoOp
|
, Statement.NoOp
|
||||||
, Statement.Return
|
, Statement.Return
|
||||||
@ -97,6 +98,7 @@ statement = assertStatement
|
|||||||
<|> breakStatement
|
<|> breakStatement
|
||||||
<|> continueStatement
|
<|> continueStatement
|
||||||
<|> deleteStatement
|
<|> deleteStatement
|
||||||
|
<|> execStatement
|
||||||
<|> expressionStatement
|
<|> expressionStatement
|
||||||
<|> globalStatement
|
<|> globalStatement
|
||||||
<|> ifStatement
|
<|> ifStatement
|
||||||
@ -302,6 +304,9 @@ ifStatement = makeTerm <$> symbol IfStatement <*> children (Statement.If <$> exp
|
|||||||
optionalElse = fromMaybe <$> emptyTerm <*> optional elseClause
|
optionalElse = fromMaybe <$> emptyTerm <*> optional elseClause
|
||||||
makeElif (loc, makeIf) rest = makeTerm loc (makeIf rest)
|
makeElif (loc, makeIf) rest = makeTerm loc (makeIf rest)
|
||||||
|
|
||||||
|
execStatement :: HasCallStack => Assignment (Node Grammar) (Term Syntax Location)
|
||||||
|
execStatement = makeTerm <$> symbol ExecStatement <*> children (Statement.Evaluate <$> string <*> (optional (many expression)))
|
||||||
|
|
||||||
passStatement :: HasCallStack => Assignment (Node Grammar) (Term Syntax Location)
|
passStatement :: HasCallStack => Assignment (Node Grammar) (Term Syntax Location)
|
||||||
passStatement = makeTerm <$> symbol PassStatement <*> (Statement.NoOp <$> (makeTerm <$> location <*> (Syntax.Identifier <$> source)))
|
passStatement = makeTerm <$> symbol PassStatement <*> (Statement.NoOp <$> (makeTerm <$> location <*> (Syntax.Identifier <$> source)))
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user