AST

interface AST

This interface makes Python's ast nodes accessible to Kotlin. It does not contain any complex logic but rather aims at making all Python ast properties accessible to Kotlin (under the same name as in Python).

Python's AST object are mapped as close as possible to the original. Exceptions:

  • identifier fields are mapped as Kotlin Strings

  • Python's int is mapped to Int

  • Constants are mapped as Any (thus Jep's conversion to Java makes the translation)

Types

Link copied to clipboard
class Add(var pyObject: PyObject) : Python.AST.BaseOperator
Link copied to clipboard
class alias(var pyObject: PyObject) : Python.AST.AST, Python.AST.WithLocation
Link copied to clipboard
class And(var pyObject: PyObject) : Python.AST.BaseBoolOp
Link copied to clipboard
class AnnAssign(var pyObject: PyObject) : Python.AST.BaseStmt
Link copied to clipboard
class arg(var pyObject: PyObject) : Python.AST.AST, Python.AST.WithLocation
Link copied to clipboard
class arguments(var pyObject: PyObject) : Python.AST.AST
Link copied to clipboard
class Assert(var pyObject: PyObject) : Python.AST.BaseStmt
Link copied to clipboard
class Assign(var pyObject: PyObject) : Python.AST.BaseStmt
Link copied to clipboard
abstract class AST(var pyObject: PyObject) : Python.BaseObject

Represents a ast.AST node as returned by Python's ast parser.

Link copied to clipboard
Link copied to clipboard

Several classes are duplicated in the python AST for async and non-async variants. This interface is a common interface for those AST classes.

Link copied to clipboard
Link copied to clipboard
class Attribute(var pyObject: PyObject) : Python.AST.BaseExpr
Link copied to clipboard
class AugAssign(var pyObject: PyObject) : Python.AST.BaseStmt
Link copied to clipboard
class Await(var pyObject: PyObject) : Python.AST.BaseExpr
Link copied to clipboard
sealed class BaseBoolOp : Python.AST.AST
Link copied to clipboard
sealed class BaseCmpOp : Python.AST.AST
Link copied to clipboard

Represents ast.expr expressions. Note: do not confuse with

Link copied to clipboard
Link copied to clipboard
abstract class BaseMod(var pyObject: PyObject) : Python.AST.AST

Note: We currently only support Modules.

Link copied to clipboard
Link copied to clipboard
abstract class BasePattern(var pyObject: PyObject) : Python.AST.AST, Python.AST.WithLocation
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
class BinOp(var pyObject: PyObject) : Python.AST.BaseExpr
Link copied to clipboard
class BitAnd(var pyObject: PyObject) : Python.AST.BaseOperator
Link copied to clipboard
class BitOr(var pyObject: PyObject) : Python.AST.BaseOperator
Link copied to clipboard
class BitXor(var pyObject: PyObject) : Python.AST.BaseOperator
Link copied to clipboard
class BoolOp(var pyObject: PyObject) : Python.AST.BaseExpr
Link copied to clipboard
class Break(var pyObject: PyObject) : Python.AST.BaseStmt
Link copied to clipboard
class Call(var pyObject: PyObject) : Python.AST.BaseExpr
Link copied to clipboard
class ClassDef(var pyObject: PyObject) : Python.AST.BaseStmt
Link copied to clipboard
class Compare(var pyObject: PyObject) : Python.AST.BaseExpr
Link copied to clipboard
class comprehension(var pyObject: PyObject) : Python.AST.AST
Link copied to clipboard
class Constant(var pyObject: PyObject) : Python.AST.BaseExpr
Link copied to clipboard
class Continue(var pyObject: PyObject) : Python.AST.BaseStmt
Link copied to clipboard
class Del(var pyObject: PyObject) : Python.AST.BaseExprContext
Link copied to clipboard
class Delete(var pyObject: PyObject) : Python.AST.BaseStmt
Link copied to clipboard
class Dict(var pyObject: PyObject) : Python.AST.BaseExpr
Link copied to clipboard
class DictComp(var pyObject: PyObject) : Python.AST.BaseExpr
Link copied to clipboard
class Div(var pyObject: PyObject) : Python.AST.BaseOperator
Link copied to clipboard
class Eq(var pyObject: PyObject) : Python.AST.BaseCmpOp
Link copied to clipboard
class ExceptHandler(var pyObject: PyObject) : Python.AST.BaseExcepthandler

ast.ExceptHandler = class ExceptHandler(excepthandler) | ExceptHandler(expr? type, identifier? name, stmt* body)

Link copied to clipboard
class Expr(var pyObject: PyObject) : Python.AST.BaseStmt

Represents ast.Expr expressions. Note: do not confuse with

Link copied to clipboard
class FloorDiv(var pyObject: PyObject) : Python.AST.BaseOperator
Link copied to clipboard
class For(var pyObject: PyObject) : Python.AST.BaseStmt, Python.AST.NormalOrAsyncFor
Link copied to clipboard
class FormattedValue(var pyObject: PyObject) : Python.AST.BaseExpr
Link copied to clipboard
Link copied to clipboard
class GeneratorExp(var pyObject: PyObject) : Python.AST.BaseExpr
Link copied to clipboard
class Global(var pyObject: PyObject) : Python.AST.BaseStmt
Link copied to clipboard
class Gt(var pyObject: PyObject) : Python.AST.BaseCmpOp
Link copied to clipboard
class GtE(var pyObject: PyObject) : Python.AST.BaseCmpOp
Link copied to clipboard
class If(var pyObject: PyObject) : Python.AST.BaseStmt
Link copied to clipboard
class IfExp(var pyObject: PyObject) : Python.AST.BaseExpr
Link copied to clipboard
class Import(var pyObject: PyObject) : Python.AST.BaseStmt
Link copied to clipboard
class ImportFrom(var pyObject: PyObject) : Python.AST.BaseStmt
Link copied to clipboard
class In(var pyObject: PyObject) : Python.AST.BaseCmpOp
Link copied to clipboard
class Invert(var pyObject: PyObject) : Python.AST.BaseUnaryOp
Link copied to clipboard
class Is(var pyObject: PyObject) : Python.AST.BaseCmpOp
Link copied to clipboard

This interface denotes that this is an "async" node.

Link copied to clipboard
class IsNot(var pyObject: PyObject) : Python.AST.BaseCmpOp
Link copied to clipboard
class JoinedStr(var pyObject: PyObject) : Python.AST.BaseExpr
Link copied to clipboard
class keyword(var pyObject: PyObject) : Python.AST.AST, Python.AST.WithLocation
Link copied to clipboard
class Lambda(var pyObject: PyObject) : Python.AST.BaseExpr
Link copied to clipboard
class List(var pyObject: PyObject) : Python.AST.BaseExpr
Link copied to clipboard
class ListComp(var pyObject: PyObject) : Python.AST.BaseExpr
Link copied to clipboard
class Load(var pyObject: PyObject) : Python.AST.BaseExprContext
Link copied to clipboard
class LShift(var pyObject: PyObject) : Python.AST.BaseOperator
Link copied to clipboard
class Lt(var pyObject: PyObject) : Python.AST.BaseCmpOp
Link copied to clipboard
class LtE(var pyObject: PyObject) : Python.AST.BaseCmpOp
Link copied to clipboard
class Match(var pyObject: PyObject) : Python.AST.BaseStmt
Link copied to clipboard
class match_case(var pyObject: PyObject) : Python.AST.AST
Link copied to clipboard
class MatchAs(var pyObject: PyObject) : Python.AST.BasePattern
Link copied to clipboard
class MatchClass(var pyObject: PyObject) : Python.AST.BasePattern
Link copied to clipboard
class MatchMapping(var pyObject: PyObject) : Python.AST.BasePattern
Link copied to clipboard
class MatchOr(var pyObject: PyObject) : Python.AST.BasePattern
Link copied to clipboard
class MatchSequence(var pyObject: PyObject) : Python.AST.BasePattern
Link copied to clipboard
class MatchSingleton(var pyObject: PyObject) : Python.AST.BasePattern
Link copied to clipboard
class MatchStar(var pyObject: PyObject) : Python.AST.BasePattern
Link copied to clipboard
class MatchValue(var pyObject: PyObject) : Python.AST.BasePattern
Link copied to clipboard
class MatMult(var pyObject: PyObject) : Python.AST.BaseOperator
Link copied to clipboard
class Mod(var pyObject: PyObject) : Python.AST.BaseOperator
Link copied to clipboard
class Module(var pyObject: PyObject) : Python.AST.AST
Link copied to clipboard
class Mult(var pyObject: PyObject) : Python.AST.BaseOperator
Link copied to clipboard
class Name(var pyObject: PyObject) : Python.AST.BaseExpr
Link copied to clipboard
class NamedExpr(var pyObject: PyObject) : Python.AST.BaseExpr
Link copied to clipboard
class Nonlocal(var pyObject: PyObject) : Python.AST.BaseStmt
Link copied to clipboard

ast.For and ast.AsyncFor are not related according to the Python syntax. However, they are so similar, that we make use of this interface to avoid a lot of duplicate code.

Link copied to clipboard

ast.FunctionDef and ast.AsyncFunctionDef are not related according to the Python syntax. However, they are so similar, that we make use of this interface to avoid a lot of duplicate code.

Link copied to clipboard

ast.With and ast.AsyncWith are not related according to the Python syntax. However, they are so similar, that we make use of this interface to avoid a lot of duplicate code.

Link copied to clipboard
class Not(var pyObject: PyObject) : Python.AST.BaseUnaryOp
Link copied to clipboard
class NotEq(var pyObject: PyObject) : Python.AST.BaseCmpOp
Link copied to clipboard
class NotIn(var pyObject: PyObject) : Python.AST.BaseCmpOp
Link copied to clipboard
class Or(var pyObject: PyObject) : Python.AST.BaseBoolOp
Link copied to clipboard
class Pass(var pyObject: PyObject) : Python.AST.BaseStmt
Link copied to clipboard
class Pow(var pyObject: PyObject) : Python.AST.BaseOperator
Link copied to clipboard
class Raise(var pyObject: PyObject) : Python.AST.BaseStmt
Link copied to clipboard
class Return(var pyObject: PyObject) : Python.AST.BaseStmt
Link copied to clipboard
class RShift(var pyObject: PyObject) : Python.AST.BaseOperator
Link copied to clipboard
class Set(var pyObject: PyObject) : Python.AST.BaseExpr
Link copied to clipboard
class SetComp(var pyObject: PyObject) : Python.AST.BaseExpr
Link copied to clipboard
class Slice(var pyObject: PyObject) : Python.AST.BaseExpr
Link copied to clipboard
class Starred(var pyObject: PyObject) : Python.AST.BaseExpr
Link copied to clipboard
class Store(var pyObject: PyObject) : Python.AST.BaseExprContext
Link copied to clipboard
class Sub(var pyObject: PyObject) : Python.AST.BaseOperator
Link copied to clipboard
class Subscript(var pyObject: PyObject) : Python.AST.BaseExpr
Link copied to clipboard
class Try(var pyObject: PyObject) : Python.AST.BaseStmt
Link copied to clipboard
class TryStar(var pyObject: PyObject) : Python.AST.BaseStmt
Link copied to clipboard
class Tuple(var pyObject: PyObject) : Python.AST.BaseExpr
Link copied to clipboard
class type_ignore(var pyObject: PyObject) : Python.AST.AST

TODO

Link copied to clipboard
class UAdd(var pyObject: PyObject) : Python.AST.BaseUnaryOp
Link copied to clipboard
class UnaryOp(var pyObject: PyObject) : Python.AST.BaseExpr
Link copied to clipboard
class USub(var pyObject: PyObject) : Python.AST.BaseUnaryOp
Link copied to clipboard
class While(var pyObject: PyObject) : Python.AST.BaseStmt
Link copied to clipboard
class With(var pyObject: PyObject) : Python.AST.BaseStmt, Python.AST.NormalOrAsyncWith
Link copied to clipboard
class withitem(var pyObject: PyObject) : Python.AST.AST
Link copied to clipboard
interface WithLocation

Some nodes, such as ast.stmt AST.BaseStmt and ast.expr AST.BaseExpr nodes have extra location properties as implemented here.

Link copied to clipboard
class Yield(var pyObject: PyObject) : Python.AST.BaseExpr
Link copied to clipboard
class YieldFrom(var pyObject: PyObject) : Python.AST.BaseExpr