mirror of
https://github.com/github/semantic.git
synced 2024-12-27 17:05:33 +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 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
|
||||
|
||||
|
@ -55,6 +55,7 @@ type Syntax' =
|
||||
, Statement.Assignment
|
||||
, Statement.Break
|
||||
, Statement.Continue
|
||||
, Statement.Evaluate
|
||||
, Statement.If
|
||||
, Statement.NoOp
|
||||
, Statement.Return
|
||||
@ -97,6 +98,7 @@ statement = assertStatement
|
||||
<|> breakStatement
|
||||
<|> continueStatement
|
||||
<|> deleteStatement
|
||||
<|> execStatement
|
||||
<|> expressionStatement
|
||||
<|> globalStatement
|
||||
<|> ifStatement
|
||||
@ -302,6 +304,9 @@ ifStatement = makeTerm <$> symbol IfStatement <*> children (Statement.If <$> exp
|
||||
optionalElse = fromMaybe <$> emptyTerm <*> optional elseClause
|
||||
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 = makeTerm <$> symbol PassStatement <*> (Statement.NoOp <$> (makeTerm <$> location <*> (Syntax.Identifier <$> source)))
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user