Reference

Contents

Reference#

class gam.ast.program.Repository(*, name: Literal['Repository'] = 'Repository', methods: List[FunctionDeclaration] = None, **extra_data: Any)[source]#

Represents a repository.

A Repository is a collection of methods that are used to interact with the database. It is used to perform CRUD operations on the database.

name: Literal['Repository']#
methods: List[FunctionDeclaration]#
class gam.ast.program.Controller(*, name: Literal['Controller'] = 'Controller', methods: List[FunctionDeclaration] = None, **extra_data: Any)[source]#

Represents a controller.

A Controller is a collection of methods that are used to handle the requests and responses. It is used to perform the business logic of the application.

name: Literal['Controller']#
methods: List[FunctionDeclaration]#
class gam.ast.program.Model(*, name: Literal['Model'] = 'Model', structs: List[StructDeclaration] = None, **extra_data: Any)[source]#

Represents a model.

A Model is a collection of structs that are used to represent the data in the application. It is used to store the data in the application.

name: Literal['Model']#
structs: List[StructDeclaration]#
class gam.ast.program.View(*, name: Literal['View'] = 'View', pages: List[ViewPage] = None, **extra_data: Any)[source]#

Represents a view.

A View is a collection of methods, models (structs) that are used to render the UI. It is used to display the data to the user.

name: Literal['View']#
pages: List[ViewPage]#
class gam.ast.program.Event(*, name: Literal['Event'] = 'Event', event_handlers: List[EventHandler] = None, **extra_data: Any)[source]#

Represents an event.

An Event is a collection of methods that are used to handle the events in the application. It is used to handle the events in the application, data flow like: User -> View -> Event -> EventHandler -> Controller -> Repository -> Database

name: Literal['Event']#
event_handlers: List[EventHandler]#
class gam.ast.program.Module(*, name: Literal['Module'] = 'Module', id: str, controller: Controller | None, event: Event | None, model: Model | None, view: View | None, repository: Repository | None, **extra_data: Any)[source]#

Represents a module.

A Module is a collection of components that are used to represent the application. It is used to store the application components.

name: Literal['Module']#
id: str#
controller: Controller | None#
event: Event | None#
model: Model | None#
view: View | None#
repository: Repository | None#
class gam.ast.program.Program(*, name: Literal['Program'] = 'Program', modules: List[Module] = None, view_index: ViewPage, statements: List[Statement] = None, entry_point: CallExpression, **extra_data: Any)[source]#

Represents a program

A Program is a collection of modules that are used to represent the application. It is used to store the application.

name: Literal['Program']#
modules: List[Module]#
view_index: ViewPage#
statements: List[Statement]#
entry_point: CallExpression#
class gam.ast.expr.BaseLiteral(*, name: Literal['Literal'] = 'Literal', **extra_data: Any)[source]#

Base class for all literal values in the AST.

name: Literal['Literal']#
class gam.ast.expr.IntegerLiteral(*, name: Literal['IntegerLiteral'] = 'IntegerLiteral', value: int, **extra_data: Any)[source]#

Represents an integer literal value in the AST.

name: Literal['IntegerLiteral']#
value: int#
class gam.ast.expr.FloatLiteral(*, name: Literal['FloatLiteral'] = 'FloatLiteral', value: float, **extra_data: Any)[source]#

Represents a floating-point literal value in the AST.

name: Literal['FloatLiteral']#
value: float#
class gam.ast.expr.StringLiteral(*, name: Literal['StringLiteral'] = 'StringLiteral', value: str, **extra_data: Any)[source]#

Represents a string literal value in the AST.

name: Literal['StringLiteral']#
value: str#
class gam.ast.expr.BooleanLiteral(*, name: Literal['BooleanLiteral'] = 'BooleanLiteral', value: bool, **extra_data: Any)[source]#

Represents a boolean literal value in the AST.

name: Literal['BooleanLiteral']#
value: bool#
class gam.ast.expr.DateTimeLiteral(*, name: Literal['DateTimeLiteral'] = 'DateTimeLiteral', value: datetime | None = None, **extra_data: Any)[source]#

Represents a datetime literal value in the AST.

name: Literal['DateTimeLiteral']#
value: datetime | None#
class gam.ast.expr.NullLiteral(*, name: Literal['NullLiteral'] = 'NullLiteral', **extra_data: Any)[source]#

Represents a null literal value in the AST.

name: Literal['NullLiteral']#
class gam.ast.expr.StructLiteral(*, name: Literal['Literal'] = 'Literal', **extra_data: Any)[source]#

Represents a struct instance creation in the AST.

name: Literal['StructLiteral']#
struct_type: Identifier#
fields: List[Property]#
class gam.ast.expr.ArrayLiteral(*, name: Literal['ArrayLiteral'] = 'ArrayLiteral', elements: List[Expression] = None, **extra_data: Any)[source]#

Represents an array literal value in the AST.

name: Literal['ArrayLiteral']#
elements: List[Expression]#
class gam.ast.expr.Identifier(*, name: Literal['Identifier'] = 'Identifier', uqn: str, **extra_data: Any)[source]#

Represents an identifier (variable name, function name, etc.) in the AST. Only use UQN for identifier.

name: Literal['Identifier']#
uqn: str#
class gam.ast.expr.BinaryExpression(*, name: Literal['BinaryExpression'] = 'BinaryExpression', left: Expression, operator: BinaryOperator, right: Expression, **extra_data: Any)[source]#

Represents a binary operation expression in the AST.

name: Literal['BinaryExpression']#
left: Expression#
operator: BinaryOperator#
right: Expression#
class gam.ast.expr.UnaryExpression(*, name: Literal['UnaryExpression'] = 'UnaryExpression', operator: UnaryOperator, operand: Expression, **extra_data: Any)[source]#

Represents a unary operation expression in the AST.

name: Literal['UnaryExpression']#
operator: UnaryOperator#
operand: Expression#
class gam.ast.expr.CallExpression(*, name: Literal['Expression'] = 'Expression', **extra_data: Any)[source]#

Represents a function or method call expression in the AST.

name: Literal['CallExpression']#
callee: Expression#
arguments: List[Expression]#
kwargs: List[Property]#
class gam.ast.expr.MemberExpression(*, name: Literal['MemberExpression'] = 'MemberExpression', object: Expression, property: Identifier | Expression, computed: bool = False, **extra_data: Any)[source]#

Represents a member access expression (object.property) in the AST.

name: Literal['MemberExpression']#
object: Expression#
property: Identifier | Expression#
computed: bool#
class gam.ast.expr.ArrayExpression(*, name: Literal['ArrayExpression'] = 'ArrayExpression', elements: List[Expression] = None, **extra_data: Any)[source]#

Represents an array literal expression in the AST.

name: Literal['ArrayExpression']#
elements: List[Expression]#
class gam.ast.expr.Property(*, name: Literal['Property'] = 'Property', key: Identifier | BaseLiteral, value: Expression, **extra_data: Any)[source]#

Represents a property in an object literal or struct initialization.

name: Literal['Property']#
key: Identifier | BaseLiteral#
value: Expression#
class gam.ast.expr.ObjectExpression(*, name: Literal['ObjectExpression'] = 'ObjectExpression', properties: List[Property] = None, **extra_data: Any)[source]#

Represents an object literal expression in the AST.

name: Literal['ObjectExpression']#
properties: List[Property]#
class gam.ast.ops.Operator(*, name: Literal['Operator'] = 'Operator', id: str, **extra_data: Any)[source]#

Base class for all operators

name: Literal['Operator']#
id: str#
class gam.ast.ops.BinaryOperator(*, name: Literal['BinaryOperator'] = 'BinaryOperator', id: str, **extra_data: Any)[source]#

Represents a binary operator

name: Literal['BinaryOperator']#
class gam.ast.ops.UnaryOperator(*, name: Literal['UnaryOperator'] = 'UnaryOperator', id: str, **extra_data: Any)[source]#

Represents a unary operator

name: Literal['UnaryOperator']#
class gam.ast.ops.ComparisonOperator(*, name: Literal['ComparisonOperator'] = 'ComparisonOperator', id: str, **extra_data: Any)[source]#

Represents a comparison operator

name: Literal['ComparisonOperator']#
class gam.ast.ops.AddOps(*, name: Literal['AddOps'] = 'AddOps', id: Literal['add'] = 'add', **extra_data: Any)[source]#

Represents an addition operator

name: Literal['AddOps']#
id: Literal['add']#
class gam.ast.ops.SubtractOps(*, name: Literal['SubtractOps'] = 'SubtractOps', id: Literal['subtract'] = 'subtract', **extra_data: Any)[source]#

Represents a subtraction operator

name: Literal['SubtractOps']#
id: Literal['subtract']#
class gam.ast.ops.MultiplyOps(*, name: Literal['MultiplyOps'] = 'MultiplyOps', id: Literal['multiply'] = 'multiply', **extra_data: Any)[source]#

Represents a multiplication operator

name: Literal['MultiplyOps']#
id: Literal['multiply']#
class gam.ast.ops.DivideOps(*, name: Literal['DivideOps'] = 'DivideOps', id: Literal['divide'] = 'divide', **extra_data: Any)[source]#

Represents a division operator

name: Literal['DivideOps']#
id: Literal['divide']#
class gam.ast.ops.EqualOps(*, name: Literal['EqualOps'] = 'EqualOps', id: Literal['equal'] = 'equal', **extra_data: Any)[source]#

Represents an equal operator

name: Literal['EqualOps']#
id: Literal['equal']#
class gam.ast.ops.NotEqualOps(*, name: Literal['NotEqualOps'] = 'NotEqualOps', id: Literal['not_equal'] = 'not_equal', **extra_data: Any)[source]#

Represents a not equal operator

name: Literal['NotEqualOps']#
id: Literal['not_equal']#
class gam.ast.ops.LessThanOps(*, name: Literal['LessThanOps'] = 'LessThanOps', id: Literal['less_than'] = 'less_than', **extra_data: Any)[source]#

Represents a less than operator

name: Literal['LessThanOps']#
id: Literal['less_than']#
class gam.ast.ops.LessThanEqualOps(*, name: Literal['LessThanEqualOps'] = 'LessThanEqualOps', id: Literal['less_than_equal'] = 'less_than_equal', **extra_data: Any)[source]#

Represents a less than or equal operator

name: Literal['LessThanEqualOps']#
id: Literal['less_than_equal']#
class gam.ast.ops.GreaterThanOps(*, name: Literal['GreaterThanOps'] = 'GreaterThanOps', id: Literal['greater_than'] = 'greater_than', **extra_data: Any)[source]#

Represents a greater than operator

name: Literal['GreaterThanOps']#
id: Literal['greater_than']#
class gam.ast.ops.GreaterThanEqualOps(*, name: Literal['GreaterThanEqualOps'] = 'GreaterThanEqualOps', id: Literal['greater_than_equal'] = 'greater_than_equal', **extra_data: Any)[source]#

Represents a greater than or equal operator

name: Literal['GreaterThanEqualOps']#
id: Literal['greater_than_equal']#
class gam.ast.ops.AndOps(*, name: Literal['AndOps'] = 'AndOps', id: Literal['and'] = 'and', **extra_data: Any)[source]#

Represents a and operator

name: Literal['AndOps']#
id: Literal['and']#
class gam.ast.ops.OrOps(*, name: Literal['OrOps'] = 'OrOps', id: Literal['or'] = 'or', **extra_data: Any)[source]#

Represents a or operator

name: Literal['OrOps']#
id: Literal['or']#
class gam.ast.ops.NotOps(*, name: Literal['NotOps'] = 'NotOps', id: Literal['not'] = 'not', **extra_data: Any)[source]#
name: Literal['NotOps']#
id: Literal['not']#
class gam.ast.stmt.ExpressionStatement(*, name: Literal['ExpressionStatement'] = 'ExpressionStatement', expression: Expression, **extra_data: Any)[source]#

Represents a statement that is an expression.

Example: `python x + y; `

name: Literal['ExpressionStatement']#
expression: Expression#
class gam.ast.stmt.BlockStatement(*, name: Literal['BlockStatement'] = 'BlockStatement', body: List[Statement] = None, **extra_data: Any)[source]#

Represents a block of statements enclosed in curly braces.

A block statement groups multiple statements together and can create a new scope. Example: ```python {

x = 1; y = 2; x + y;

}#

name: Literal['BlockStatement']#
body: List[Statement]#
class gam.ast.stmt.AssignmentStatement(*, name: Literal['AssignmentStatement'] = 'AssignmentStatement', left: Identifier | MemberExpression, right: Expression, **extra_data: Any)[source]#

Represents an assignment operation.

Example: `python x = 5; obj.prop = value; `

name: Literal['AssignmentStatement']#
left: Identifier | MemberExpression#
right: Expression#
class gam.ast.stmt.FunctionParameter(*, name: Literal['FunctionParameter'] = 'FunctionParameter', id: Identifier, type_annotation: TypeAnnotation | None = None, **extra_data: Any)[source]#

Represents a parameter in a function declaration.

Example: `python function add(x: number, y: number) { ... } # x and y are FunctionParameters `

name: Literal['FunctionParameter']#
id: Identifier#
type_annotation: TypeAnnotation | None#
class gam.ast.stmt.FunctionDeclaration(*, name: Literal['FunctionDeclaration'] = 'FunctionDeclaration', id: Identifier, description: str | None = None, params: List[FunctionParameter] = None, body: BlockStatement, return_type: TypeAnnotation | None = None, **extra_data: Any)[source]#

Represents a function declaration Support normally function declaration, also agrs with type hint, default values, and return type hint. Example: ```python def create_user(name: str, age: int) -> User:

return User(name=name, age=age)

# will be converted to: FunctionDeclaration(

id=Identifier(name=”create_user”), params=[

FunctionParameter(

id=Identifier(name=”name”), type_annotation=StringType()

), FunctionParameter(

id=Identifier(name=”age”), type_annotation=IntType()

)

], body=BlockStatement(

body=[
ReturnStatement(
argument=StructLiteral(

struct_type=Identifier(name=”User”), fields=[

Property(

key=Identifier(name=”name”), value=Identifier(name=”name”)

), Property(

key=Identifier(name=”age”), value=Identifier(name=”age”)

), Property(

key=Identifier(name=”is_admin”), value=Identifier(name=”is_admin”)

)

]

)

)

]

), return_type=StructType(struct_type=Identifier(name=”User”))

)#

name: Literal['FunctionDeclaration']#
id: Identifier#
description: str | None#
params: List[FunctionParameter]#
body: BlockStatement#
return_type: TypeAnnotation | None#
class gam.ast.stmt.ReturnStatement(*, name: Literal['ReturnStatement'] = 'ReturnStatement', argument: Expression, **extra_data: Any)[source]#

Represents a return statement that exits a function and returns a value.

Example: ```python return name # will be converted to: ReturnStatement(

argument=Identifier(name=”name”)

)#

name: Literal['ReturnStatement']#
argument: Expression#
class gam.ast.stmt.WhileStatement(*, name: Literal['WhileStatement'] = 'WhileStatement', test: Expression, body: BlockStatement, **extra_data: Any)[source]#

Represents a while loop that executes its body while a condition is true.

hello ```python while (i < 10):

i += 1

name: Literal['WhileStatement']#
test: Expression#
body: BlockStatement#
class gam.ast.stmt.IfStatement(*, name: Literal['Statement'] = 'Statement', **extra_data: Any)[source]#

Represents an if-else conditional statement with optional elif branches.

The IfStatement node represents a complete conditional control structure including: - A main if condition and its body - Optional elif branches (stored in elif_branches) - An optional else branch (stored in alternate)

Example:

while (i < 10):
    i += 1
if (i < 10):
    i += 1
elif (i == 10):
    i += 1

# will be converted to:

IfStatement(
    test=BinaryExpression(
        left=Identifier(name="i"),
        operator=LessThanOps(),
        right=IntegerLiteral(value=10)
    ),
    consequent=BlockStatement(
        body=[
            AssignmentStatement(
                left=Identifier(name="i"),
                right=BinaryExpression(
                    left=Identifier(name="i"),
                    operator=AddOps(),
                    right=IntegerLiteral(value=1)
                )
            )
        ]
    ),
    elif_branches=[
        ElifStatement(
            test=BinaryExpression(
                left=Identifier(name="i"),
                operator=EqualOps(),
                right=IntegerLiteral(value=10)
            ),
            consequent=BlockStatement(
                body=[
                    AssignmentStatement(
                        left=Identifier(name="i"),
                        right=BinaryExpression(
                            left=Identifier(name="i"),
                            operator=AddOps(),
                            right=IntegerLiteral(value=1)
                        )
                    )
                ]
            )
        )
    ]
)
name: Literal['IfStatement']#
test: Expression#
consequent: BlockStatement#
elif_branches: List[ElifStatement]#
alternate: BlockStatement | None#
class gam.ast.stmt.ElifStatement(*, name: Literal['ElifStatement'] = 'ElifStatement', test: Expression, consequent: BlockStatement, **extra_data: Any)[source]#

Represents an else-if branch in an if statement.

Example: ```python if (x > 0):

elif (x < 0):

# will be converted to: IfStatement(

test=BinaryExpression(

left=Identifier(name=”x”), operator=GreaterThanOps(), right=IntegerLiteral(value=0)

), consequent=BlockStatement(

body=[

]

), elif_branches=[

ElifStatement(
test=BinaryExpression(

left=Identifier(name=”x”), operator=LessThanOps(), right=IntegerLiteral(value=0)

), consequent=BlockStatement(

body=[

]

)

)

], alternate=BlockStatement(

body=[

]

)

)#

name: Literal['ElifStatement']#
test: Expression#
consequent: BlockStatement#
class gam.ast.stmt.BreakStatement(*, name: Literal['BreakStatement'] = 'BreakStatement', label: Identifier | None = None, **extra_data: Any)[source]#

Represents a break statement that exits a loop or switch.

Example: ```python while (i < 10):

if (i == 5):

break

# will be converted to: WhileStatement(

test=BinaryExpression(

left=Identifier(name=”i”), operator=LessThanOps(), right=IntegerLiteral(value=10)

), body=BlockStatement(

body=[
IfStatement(
test=BinaryExpression(

left=Identifier(name=”i”), operator=EqualOps(), right=IntegerLiteral(value=5)

), consequent=BlockStatement(

body=[

BreakStatement()

]

)

)

]

)

```

name: Literal['BreakStatement']#
label: Identifier | None#
class gam.ast.stmt.TryStatement(*, name: Literal['Statement'] = 'Statement', **extra_data: Any)[source]#

Represents a try-catch-finally block for exception handling.

Example: ```python try:

riskyOperation()

except ValueError as e:

handleError(e)

# will be converted to: TryStatement(

block=BlockStatement(
body=[
ExpressionStatement(
expression=CallExpression(

callee=Identifier(name=”riskyOperation”), arguments=[]

)

)

],

), handlers=[

CatchClause(

param=Identifier(name=”error”), exception_type=Identifier(name=”Error”), body=BlockStatement(

body=[
ExpressionStatement(
expression=CallExpression(

callee=Identifier(name=”handleError”), arguments=[Identifier(name=”e”)]

)

)

]

)

)

]

)#

name: Literal['TryStatement']#
block: BlockStatement#
handlers: List[CatchClause]#
finalizer: BlockStatement | None#
class gam.ast.stmt.CatchClause(*, name: Literal['CatchClause'] = 'CatchClause', param: Identifier | None = None, exception_type: Identifier | None = None, body: BlockStatement, **extra_data: Any)[source]#

Represents a catch block in a try-catch statement.

Example: ```python try:

riskyOperation()

except ValueError as e:

handleError(e)

# will be converted to: CatchClause(

param=Identifier(name=”error”), exception_type=Identifier(name=”Error”), body=BlockStatement(

body=[
ExpressionStatement(
expression=CallExpression(

callee=Identifier(name=”handleError”), arguments=[Identifier(name=”e”)]

)

)

]

)

)#

name: Literal['CatchClause']#
param: Identifier | None#
exception_type: Identifier | None#
body: BlockStatement#
class gam.ast.stmt.ThrowStatement(*, name: Literal['ThrowStatement'] = 'ThrowStatement', argument: Expression, **extra_data: Any)[source]#

Represents a throw statement that raises an exception.

Example: ```python raise Exception(“Something went wrong”)

# will be converted to: ThrowStatement(

argument=StringLiteral(value=”Something went wrong”)

)#

name: Literal['ThrowStatement']#
argument: Expression#
class gam.ast.stmt.StructDeclaration(*, name: Literal['Statement'] = 'Statement', **extra_data: Any)[source]#

Represents a struct/class declaration.

Example: ```python class Point:

x: int y: int

# will be converted to: StructDeclaration(

id=Identifier(name=”Point”), fields=[

StructField(

field_id=Identifier(name=”x”), type_annotation=NumberType(), default_value=None

), StructField(

field_id=Identifier(name=”y”), type_annotation=NumberType(), default_value=None

)

]

```

name: Literal['StructDeclaration']#
id: Identifier#
fields: List[StructField]#
class gam.ast.stmt.StructField(*, name: Literal['StructField'] = 'StructField', field_id: Identifier, type_annotation: TypeAnnotation | None = None, default_value: Expression | None = None, **extra_data: Any)[source]#

Represents a field in a struct/class declaration.

Example: ```python class Point:

x: int y: int

# will be converted to: StructDeclaration(

id=Identifier(name=”Point”), fields=[

StructField(

field_id=Identifier(name=”x”), type_annotation=NumberType(), default_value=None

), StructField(

field_id=Identifier(name=”y”), type_annotation=NumberType(), default_value=None

)

]

```

name: Literal['StructField']#
field_id: Identifier#
type_annotation: TypeAnnotation | None#
default_value: Expression | None#
class gam.ast.types.TypeAnnotation(*, name: Literal['TypeAnnotation'] = 'TypeAnnotation', type_name: str, generic_params: List[str] = None, **extra_data: Any)[source]#

Base class for all type annotations in the AST.

name: Literal['TypeAnnotation']#
type_name: str#
generic_params: List[str]#
class gam.ast.types.StringType(*, name: Literal['StringType'] = 'StringType', type_name: str = 'string', generic_params: List[str] = None, **extra_data: Any)[source]#

Represents a string type annotation in the AST.

name: Literal['StringType']#
type_name: str#
generic_params: List[str]#
class gam.ast.types.IntType(*, name: Literal['IntType'] = 'IntType', type_name: str = 'int', generic_params: List[str] = None, **extra_data: Any)[source]#

Represents an integer type annotation in the AST.

name: Literal['IntType']#
type_name: str#
generic_params: List[str]#
class gam.ast.types.BoolType(*, name: Literal['BoolType'] = 'BoolType', type_name: str = 'bool', generic_params: List[str] = None, **extra_data: Any)[source]#

Represents a boolean type annotation in the AST.

name: Literal['BoolType']#
type_name: str#
generic_params: List[str]#
class gam.ast.types.FloatType(*, name: Literal['FloatType'] = 'FloatType', type_name: str = 'float', generic_params: List[str] = None, **extra_data: Any)[source]#

Represents a floating-point type annotation in the AST.

name: Literal['FloatType']#
type_name: str#
generic_params: List[str]#
class gam.ast.types.NullType(*, name: Literal['NullType'] = 'NullType', type_name: str = 'null', generic_params: List[str] = None, **extra_data: Any)[source]#

Represents a null type annotation in the AST.

name: Literal['NullType']#
type_name: str#
generic_params: List[str]#
class gam.ast.types.DateTimeType(*, name: Literal['DateTimeType'] = 'DateTimeType', type_name: str = 'datetime', generic_params: List[str] = None, **extra_data: Any)[source]#

Represents a datetime type annotation in the AST.

name: Literal['DateTimeType']#
type_name: str#
generic_params: List[str]#
class gam.ast.types.ArrayType(*, name: Literal['ArrayType'] = 'ArrayType', type_name: str = 'array', generic_params: List[str] = None, element_type: TypeAnnotation, **extra_data: Any)[source]#

Represents an array type annotation in the AST.

name: Literal['ArrayType']#
type_name: str#
element_type: TypeAnnotation#
generic_params: List[str]#
class gam.ast.types.ObjectType(*, name: Literal['ObjectType'] = 'ObjectType', type_name: str = 'object', generic_params: List[str] = None, **extra_data: Any)[source]#

Represents an object type annotation in the AST.

name: Literal['ObjectType']#
type_name: str#
generic_params: List[str]#
class gam.ast.types.StructType(*, name: Literal['StructType'] = 'StructType', type_name: str = 'struct', generic_params: List[str] = None, struct_type: Identifier, **extra_data: Any)[source]#

Represents a struct type annotation in the AST.

name: Literal['StructType']#
type_name: str#
struct_type: Identifier#
generic_params: List[str]#
class gam.ast.types.OptionalType(*, name: Literal['OptionalType'] = 'OptionalType', type_name: str = 'optional', generic_params: List[str] = None, type_annotation: TypeAnnotation, **extra_data: Any)[source]#

Represents an optional type annotation in the AST.

name: Literal['OptionalType']#
type_name: str#
type_annotation: TypeAnnotation#
generic_params: List[str]#
class gam.ast.types.AnyType(*, name: Literal['AnyType'] = 'AnyType', type_name: str = 'any', generic_params: List[str] = None, **extra_data: Any)[source]#

Represents an any type annotation in the AST.

name: Literal['AnyType']#
type_name: str#
generic_params: List[str]#

GAM AST structure.

The main idea is to have a structure that is easy to understand and easy to parse. - Model holds the data.

e.g. User, Product, Order, etc.

  • Controller handles the business logic.

    e.g. UserController, ProductController, OrderController, etc.

  • Repository handles the data access.

    e.g. UserRepository, ProductRepository, OrderRepository, etc.

  • View handles the UI.

    e.g. UserView, ProductView, OrderView, etc.

  • Event handles the events.

    e.g. UserEvent, ProductEvent, OrderEvent, etc.

Program:
  • modules: List[Module]
    • repository: Repository
      • methods: List[FunctionDeclaration]

    • controller: Controller
      • methods: List[FunctionDeclaration]

    • model: Model
      • structs: List[StructDeclaration]

    • view: View
      • methods: List[FunctionDeclaration]

    • event: Event
      • methods: List[FunctionDeclaration]

  • entry_point: CallExpression (the entry point of the program)

class gam.ast.base_ast.ASTNode(*, name: Literal['ASTNode'] = 'ASTNode', **extra_data: Any)[source]#

Base class for all AST nodes

name: Literal['ASTNode']#
class Config[source]#
arbitrary_types_allowed = True#
extra = 'allow'#
class gam.ast.base_ast.Expression(*, name: Literal['Expression'] = 'Expression', **extra_data: Any)[source]#

Base class for all expressions

name: Literal['Expression']#
class gam.ast.base_ast.Statement(*, name: Literal['Statement'] = 'Statement', **extra_data: Any)[source]#

Base class for all statements

name: Literal['Statement']#
class gam.ast.program.Repository(*, name: Literal['Repository'] = 'Repository', methods: List[FunctionDeclaration] = None, **extra_data: Any)[source]#

Represents a repository.

A Repository is a collection of methods that are used to interact with the database. It is used to perform CRUD operations on the database.

name: Literal['Repository']#
methods: List[FunctionDeclaration]#
class gam.ast.program.Controller(*, name: Literal['Controller'] = 'Controller', methods: List[FunctionDeclaration] = None, **extra_data: Any)[source]#

Represents a controller.

A Controller is a collection of methods that are used to handle the requests and responses. It is used to perform the business logic of the application.

name: Literal['Controller']#
methods: List[FunctionDeclaration]#
class gam.ast.program.Model(*, name: Literal['Model'] = 'Model', structs: List[StructDeclaration] = None, **extra_data: Any)[source]#

Represents a model.

A Model is a collection of structs that are used to represent the data in the application. It is used to store the data in the application.

name: Literal['Model']#
structs: List[StructDeclaration]#
class gam.ast.program.View(*, name: Literal['View'] = 'View', pages: List[ViewPage] = None, **extra_data: Any)[source]#

Represents a view.

A View is a collection of methods, models (structs) that are used to render the UI. It is used to display the data to the user.

name: Literal['View']#
pages: List[ViewPage]#
class gam.ast.program.Event(*, name: Literal['Event'] = 'Event', event_handlers: List[EventHandler] = None, **extra_data: Any)[source]#

Represents an event.

An Event is a collection of methods that are used to handle the events in the application. It is used to handle the events in the application, data flow like: User -> View -> Event -> EventHandler -> Controller -> Repository -> Database

name: Literal['Event']#
event_handlers: List[EventHandler]#
class gam.ast.program.Module(*, name: Literal['Module'] = 'Module', id: str, controller: Controller | None, event: Event | None, model: Model | None, view: View | None, repository: Repository | None, **extra_data: Any)[source]#

Represents a module.

A Module is a collection of components that are used to represent the application. It is used to store the application components.

name: Literal['Module']#
id: str#
controller: Controller | None#
event: Event | None#
model: Model | None#
view: View | None#
repository: Repository | None#
class gam.ast.program.Program(*, name: Literal['Program'] = 'Program', modules: List[Module] = None, view_index: ViewPage, statements: List[Statement] = None, entry_point: CallExpression, **extra_data: Any)[source]#

Represents a program

A Program is a collection of modules that are used to represent the application. It is used to store the application.

name: Literal['Program']#
modules: List[Module]#
view_index: ViewPage#
statements: List[Statement]#
entry_point: CallExpression#
class gam.ast.event.EventHandler(*, name: Literal['EventHandler'] = 'EventHandler', event_type: Literal['click', 'input', 'change', 'submit'], handler_function: Identifier | FunctionDeclaration, args: List[Expression] | None = None, **extra_data: Any)[source]#

Represents an event handler that responds to specific events.

For example: ``` Button(

events=[
EventHandler(

event=Event(event_type=’click’), handler_function=Identifier(name=’handleClick’)

), EventHandler(

event=Event(event_type=’change’), handler_function=Identifier(name=’handleChange’)

),

]

)#

name: Literal['EventHandler']#
event_type: Literal['click', 'input', 'change', 'submit']#
handler_function: Identifier | FunctionDeclaration#
args: List[Expression] | None#
class gam.ast.view.ForLoop(*, name: Literal['ForLoop'] = 'ForLoop', iterable: Identifier, item: Identifier, key: Identifier = Identifier(name='Identifier', uqn='id'), **extra_data: Any)[source]#

Represents a for loop in the view.

name: Literal['ForLoop']#
iterable: Identifier#
item: Identifier#
key: Identifier#
class gam.ast.view.UIComponent(*, name: Literal['UIComponent'] = 'UIComponent', component_type: str, model: Identifier | None = None, events: List[EventHandler] = None, nested_components: List[UIComponent] = None, for_loop: ForLoop | None = None, **extra_data: Any)[source]#

Represents a UI component in the view. Each component is a UI element that can be rendered in the view.

name: Literal['UIComponent']#
component_type: str#
model: Identifier | None#
events: List[EventHandler]#
nested_components: List[UIComponent]#
for_loop: ForLoop | None#
class gam.ast.view.Text(*, name: Literal['Text'] = 'Text', component_type: Literal['text'] = 'text', model: Identifier | None = None, events: List[EventHandler] = None, nested_components: List[UIComponent] = None, for_loop: ForLoop | None = None, text: str, type: Literal['primary', 'secondary', 'success', 'danger', 'warning', 'info'] = 'primary', size: Literal['small', 'large'] | None = None, ellipsis: bool | None = False, **extra_data: Any)[source]#

Represents a text component.

name: Literal['Text']#
component_type: Literal['text']#
text: str#
type: Literal['primary', 'secondary', 'success', 'danger', 'warning', 'info']#
size: Literal['small', 'large'] | None#
ellipsis: bool | None#
class gam.ast.view.Button(*, name: Literal['Button'] = 'Button', component_type: Literal['button'] = 'button', model: Identifier | None = None, events: List[EventHandler] = None, nested_components: List[UIComponent] = None, for_loop: ForLoop | None = None, label: str, type: Literal['primary', 'secondary', 'success', 'danger', 'warning', 'info'] = 'primary', plain: bool | None = False, round: bool | None = False, circle: bool | None = False, disabled: bool | None = False, size: Literal['small', 'large'] | None = None, **extra_data: Any)[source]#

Represents a button component.

For example: ``` Button(

component_type=’button’, props=ComponentProps(properties=[

Property(name=’label’, value=’Click me’)

]), events=[

EventHandler(

event=Event(event_type=’click’), handler_function=Identifier(name=’handleClick’)

)

]

)

name: Literal['Button']#
component_type: Literal['button']#
label: str#
type: Literal['primary', 'secondary', 'success', 'danger', 'warning', 'info']#
plain: bool | None#
round: bool | None#
circle: bool | None#
disabled: bool | None#
size: Literal['small', 'large'] | None#
class gam.ast.view.Input(*, name: Literal['Input'] = 'Input', component_type: Literal['input'] = 'input', model: Identifier | None = None, events: List[EventHandler] = None, nested_components: List[UIComponent] = None, for_loop: ForLoop | None = None, placeholder: str | None = None, disabled: bool | None = False, size: Literal['small', 'large'] | None = None, type: Literal['text', 'password', 'email', 'number', 'textarea', 'url'] = 'text', clearable: bool | None = False, auto_resize: bool | None = False, **extra_data: Any)[source]#

Represents an input component.

name: Literal['Input']#
component_type: Literal['input']#
placeholder: str | None#
disabled: bool | None#
size: Literal['small', 'large'] | None#
type: Literal['text', 'password', 'email', 'number', 'textarea', 'url']#
clearable: bool | None#
auto_resize: bool | None#
class gam.ast.view.FormItem(*, name: Literal['FormItem'] = 'FormItem', component_type: Literal['form-item'] = 'form-item', model: Identifier | None = None, events: List[EventHandler] = None, nested_components: List[UIComponent] = None, for_loop: ForLoop | None = None, label: str, **extra_data: Any)[source]#

Represents a form item component.

Use this to group a list/one or more of input/select/checkbox/radio components.

name: Literal['FormItem']#
component_type: Literal['form-item']#
label: str#
class gam.ast.view.Card(*, name: Literal['Card'] = 'Card', component_type: Literal['card'] = 'card', model: Identifier | None = None, events: List[EventHandler] = None, nested_components: List[UIComponent] = None, for_loop: ForLoop | None = None, **extra_data: Any)[source]#

Represents a card component.

name: Literal['Card']#
component_type: Literal['card']#
class gam.ast.view.ViewComponent(*, name: Literal['ViewComponent'] = 'ViewComponent', component_type: Literal['view'] = 'view', model: Identifier | None = None, events: List[EventHandler] = None, nested_components: List[UIComponent] = None, for_loop: ForLoop | None = None, view_id: str, **extra_data: Any)[source]#

Represents a view component.

name: Literal['ViewComponent']#
component_type: Literal['view']#
view_id: str#
class gam.ast.view.ViewPage(*, name: Literal['ViewPage'] = 'ViewPage', id: str, title: str, description: str, components: List[UIComponent] = None, **extra_data: Any)[source]#

Represents a view page.

name: Literal['ViewPage']#
id: str#
title: str#
description: str#
components: List[UIComponent]#