Repository: CrossGL/crosstl
Pull request #280 (2025-06-09 18:02:48)

Mojo Support V0


Patch:
diff --git a/crosstl/_crosstl.py b/crosstl/_crosstl.py
index dfb0cca..ca54fcd 100644
--- a/crosstl/_crosstl.py
+++ b/crosstl/_crosstl.py
@@ -6,6 +6,7 @@ from .translator.codegen import (
     directx_codegen,
     metal_codegen,
     SPIRV_codegen,
+    mojo_codegen,
 )
 from .translator.ast import ASTNode
 import argparse
@@ -71,6 +72,11 @@ def translate(
 
         lexer = VulkanLexer(shader_code)
         parser = VulkanParser(lexer.tokenize())
+    elif file_path.endswith(".mojo"):
+        from .backend.Mojo import MojoLexer, MojoParser
+
+        lexer = MojoLexer(shader_code)
+        parser = MojoParser(lexer.tokenize())
     else:
         raise ValueError(f"Unsupported shader file type: {file_path}")
 
@@ -85,6 +91,8 @@ def translate(
             codegen = GLSL_codegen.GLSLCodeGen()
         elif backend == "vulkan":
             codegen = SPIRV_codegen.VulkanSPIRVCodeGen()
+        elif backend == "mojo":
+            codegen = mojo_codegen.MojoCodeGen()
         else:
             raise ValueError(f"Unsupported backend for CrossGL file: {backend}")
     else:
@@ -107,6 +115,10 @@ def translate(
                 from .backend.slang.SlangCrossGLCodeGen import SlangToCrossGLConverter
 
                 codegen = SlangToCrossGLConverter()
+            elif file_path.endswith(".mojo"):
+                from .backend.Mojo.MojoCrossGLCodeGen import MojoToCrossGLConverter
+
+                codegen = MojoToCrossGLConverter()
             else:
                 raise ValueError(f"Reverse translation not supported for: {file_path}")
         else:
@@ -138,7 +150,7 @@ def main():
         "--backend",
         "-b",
         default="cgl",
-        help="Target backend (metal, directx, opengl, vulkan, cgl)",
+        help="Target backend (metal, directx, opengl, vulkan, mojo, cgl)",
     )
     parser.add_argument("--output", "-o", help="Output file path")
     parser.add_argument(
@@ -161,6 +173,7 @@ def main():
                 "directx": ".hlsl",
                 "opengl": ".glsl",
                 "vulkan": ".spirv",
+                "mojo": ".mojo",
                 "cgl": ".cgl",
             }
             output_path = base + ext_map.get(args.backend, ".out")
diff --git a/crosstl/backend/Mojo/MojoAst.py b/crosstl/backend/Mojo/MojoAst.py
index 112cb78..46547c0 100644
--- a/crosstl/backend/Mojo/MojoAst.py
+++ b/crosstl/backend/Mojo/MojoAst.py
@@ -43,13 +43,14 @@ class FunctionNode(MojoASTNode):
 
 
 class VariableDeclarationNode(MojoASTNode):
-    def __init__(self, var_type, name, initial_value=None):
+    def __init__(self, var_type, name, initial_value=None, vtype=None):
         self.var_type = var_type
         self.name = name
         self.initial_value = initial_value
+        self.vtype = vtype
 
     def __repr__(self):
-        return f"VariableDeclarationNode(var_type={self.var_type}, name={self.name}, initial_value={self.initial_value})"
+        return f"VariableDeclarationNode(var_type={self.var_type}, name={self.name}, initial_value={self.initial_value}, vtype={self.vtype})"
 
 
 class ArrayAccessNode(MojoASTNode):
@@ -120,6 +121,15 @@ class WhileNode(MojoASTNode):
         return f"WhileNode(condition={self.condition}, body={self.body})"
 
 
+class DoWhileNode(MojoASTNode):
+    def __init__(self, condition, body):
+        self.condition = condition
+        self.body = body
+
+    def __repr__(self):
+        return f"DoWhileNode(condition={self.condition}, body={self.body})"
+
+
 class ReturnNode(MojoASTNode):
     def __init__(self, value):
         self.value = value
@@ -247,3 +257,53 @@ class SwitchNode(MojoASTNode):
 
     def __repr__(self):
         return f"SwitchNode(expression={self.expression}, cases={self.cases})"
+
+
+class CaseNode(MojoASTNode):
+    def __init__(self, value, body):
+        self.value = value
+        self.body = body
+
+    def __repr__(self):
+        return f"CaseNode(value={self.value}, body={self.body})"
+
+
+class PragmaNode(MojoASTNode):
+    def __init__(self, directive, value):
+        self.directive = directive
+        self.value = value
+
+    def __repr__(self):
+        return f"PragmaNode(directive={self.directive}, value={self.value})"
+
+
+class IncludeNode(MojoASTNode):
+    def __init__(self, path):
+        self.path = path
+
+    def __repr__(self):
+        return f"IncludeNode(path={self.path})"
+
+
+class BreakNode(MojoASTNode):
+    def __init__(self):
+        pass
+
+    def __repr__(self):
+        return "BreakNode()"
+
+
+class ContinueNode(MojoASTNode):
+    def __init__(self):
+        pass
+
+    def __repr__(self):
+        return "ContinueNode()"
+
+
+class PassNode(MojoASTNode):
+    def __init__(self):
+        pass
+
+    def __repr__(self):
+        return "PassNode()"
diff --git a/crosstl/backend/Mojo/MojoCrossGLCodeGen.py b/crosstl/backend/Mojo/MojoCrossGLCodeGen.py
new file mode 100644
index 0000000..e33dde0
--- /dev/null
+++ b/crosstl/backend/Mojo/MojoCrossGLCodeGen.py
@@ -0,0 +1,463 @@
+from .MojoAst import *
+from .MojoParser import *
+from .MojoLexer import *
+
+
+class MojoToCrossGLConverter:
+    def __init__(self):
+        self.type_map = {
+            # Scalar Types
+            "void": "void",
+            "Int": "int",
+            "Int8": "int8_t",
+            "Int16": "int16_t",
+            "Int32": "int",
+            "Int64": "int64_t",
+            "UInt": "uint",
+            "UInt8": "uint8_t",
+            "UInt16": "uint16_t",
+            "UInt32": "uint",
+            "UInt64": "uint64_t",
+            "Float": "float",
+            "Float16": "half",
+            "Float32": "float",
+            "Float64": "double",
+            "Bool": "bool",
+            # Vector Types (Mojo SIMD types)
+            "SIMD[DType.float32, 2]": "vec2",
+            "SIMD[DType.float32, 3]": "vec3",
+            "SIMD[DType.float32, 4]": "vec4",
+            "SIMD[DType.int32, 2]": "ivec2",
+            "SIMD[DType.int32, 3]": "ivec3",
+            "SIMD[DType.int32, 4]": "ivec4",
+            "SIMD[DType.uint32, 2]": "uvec2",
+            "SIMD[DType.uint32, 3]": "uvec3",
+            "SIMD[DType.uint32, 4]": "uvec4",
+            "SIMD[DType.bool, 2]": "bvec2",
+            "SIMD[DType.bool, 3]": "bvec3",
+            "SIMD[DType.bool, 4]": "bvec4",
+            # Matrix Types
+            "Matrix[DType.float32, 2, 2]": "mat2",
+            "Matrix[DType.float32, 3, 3]": "mat3",
+            "Matrix[DType.float32, 4, 4]": "mat4",
+            "Matrix[DType.float16, 2, 2]": "half2x2",
+            "Matrix[DType.float16, 3, 3]": "half3x3",
+            "Matrix[DType.float16, 4, 4]": "half4x4",
+            # Texture Types (hypothetical Mojo texture types)
+            "Texture2D": "sampler2D",
+            "TextureCube": "samplerCube",
+            "Texture3D": "sampler3D",
+            # Common simplified aliases
+            "float2": "vec2",
+            "float3": "vec3",
+            "float4": "vec4",
+            "int2": "ivec2",
+            "int3": "ivec3",
+            "int4": "ivec4",
+            "uint2": "uvec2",
+            "uint3": "uvec3",
+            "uint4": "uvec4",
+            "bool2": "bvec2",
+            "bool3": "bvec3",
+            "bool4": "bvec4",
+            "mat2": "mat2",
+            "mat3": "mat3",
+            "mat4": "mat4",
+        }
+
+        self.semantic_map = {
+            # Vertex attributes
+            "position": "Position",
+            "normal": "Normal",
+            "tangent": "Tangent",
+            "binormal": "Binormal",
+            "texcoord": "TexCoord",
+            "texcoord0": "TexCoord0",
+            "texcoord1": "TexCoord1",
+            "texcoord2": "TexCoord2",
+            "texcoord3": "TexCoord3",
+            "color": "Color",
+            "color0": "Color0",
+            "color1": "Color1",
+            "color2": "Color2",
+            "color3": "Color3",
+            # Built-in variables
+            "vertex_id": "gl_VertexID",
+            "instance_id": "gl_InstanceID",
+            "gl_position": "gl_Position",
+            "gl_fragcolor": "gl_FragColor",
+            "gl_fragdepth": "gl_FragDepth",
+            "gl_frontfacing": "gl_IsFrontFace",
+            "gl_pointcoord": "gl_PointCoord",
+            "gl_primitiveId": "gl_PrimitiveID",
+        }
+
+        self.function_map = {
+            # Math functions
+            "math.sqrt": "sqrt",
+            "math.pow": "pow",
+            "math.sin": "sin",
+            "math.cos": "cos",
+            "math.tan": "tan",
+            "math.abs": "abs",
+            "math.floor": "floor",
+            "math.ceil": "ceil",
+            "math.min": "min",
+            "math.max": "max",
+            "math.clamp": "clamp",
+            # SIMD functions
+            "simd.dot": "dot",
+            "simd.cross": "cross",
+            "simd.normalize": "normalize",
+            "simd.length": "length",
+            "simd.reflect": "reflect",
+            "simd.refract": "refract",
+        }
+
+    def generate(self, ast):
+        code = "shader main {\n"
+
+        # Generate imports as comments
+        if hasattr(ast, "functions") and ast.functions:
+            imports = [f for f in ast.functions if isinstance(f, ImportNode)]
+            if imports:
+                code += "    // Imports\n"
+                for imp in imports:
+                    code += f"    // import {imp.module_name}"
+                    if imp.alias:
+                        code += f" as {imp.alias}"
+                    code += "\n"
+                code += "\n"
+
+        # Generate struct definitions
+        if hasattr(ast, "functions"):
+            structs = [f for f in ast.functions if isinstance(f, StructNode)]
+            for struct_node in structs:
+                code += f"    // Structs\n"
+                code += f"    struct {struct_node.name} {{\n"
+                for member in struct_node.members:
+                    semantic = (
+                        self.map_semantic(member.attributes)
+                        if hasattr(member, "attributes")
+                        else ""
+                    )
+                    code += f"        {self.map_type(member.vtype)} {member.name}{semantic};\n"
+                code += "    }\n\n"
+
+        # Generate constant buffers
+        if hasattr(ast, "functions"):
+            cbuffers = [f for f in ast.functions if isinstance(f, ConstantBufferNode)]
+            if cbuffers:
+                code += "    // Constant Buffers\n"
+                for cbuffer in cbuffers:
+                    code += f"    cbuffer {cbuffer.name} {{\n"
+                    for member in cbuffer.members:
+                        code += (
+                            f"        {self.map_type(member.vtype)} {member.name};\n"
+                        )
+                    code += "    }\n\n"
+
+        # Generate functions
+        if hasattr(ast, "functions"):
+            functions = [f for f in ast.functions if isinstance(f, FunctionNode)]
+            for func in functions:
+                if (
+                    func.qualifier == "vertex"
+                    or self.has_vertex_attribute(func)
+                    or "vertex" in func.name
+                ):
+                    code += "    // Vertex Shader\n"
+                    code += "    vertex {\n"
+                    code += self.generate_function(func, indent=2)
+                    code += "    }\n\n"
+                elif (
+                    func.qualifier == "fragment"
+                    or self.has_fragment_attribute(func)
+                    or "fragment" in func.name
+                ):
+                    code += "    // Fragment Shader\n"
+                    code += "    fragment {\n"
+                    code += self.generate_function(func, indent=2)
+                    code += "    }\n\n"
+                elif (
+                    func.qualifier == "compute"
+                    or self.has_compute_attribute(func)
+                    or "compute" in func.name
+                ):
+                    code += "    // Compute Shader\n"
+                    code += "    compute {\n"
+                    code += self.generate_function(func, indent=2)
+                    code += "    }\n\n"
+                else:
+                    code += self.generate_function(func, indent=1)
+
+        code += "}\n"
+        return code
+
+    def has_vertex_attribute(self, func):
+        """Check if function has vertex-related attributes"""
+        if not hasattr(func, "attributes") or not func.attributes:
+            return False
+        for attr in func.attributes:
+            if hasattr(attr, "name") and attr.name in ["vertex", "vertex_main"]:
+                return True
+        return False
+
+    def has_fragment_attribute(self, func):
+        """Check if function has fragment-related attributes"""
+        if not hasattr(func, "attributes") or not func.attributes:
+            return False
+        for attr in func.attributes:
+            if hasattr(attr, "name") and attr.name in ["fragment", "fragment_main"]:
+                return True
+        return False
+
+    def has_compute_attribute(self, func):
+        """Check if function has compute-related attributes"""
+        if not hasattr(func, "attributes") or not func.attributes:
+            return False
+        for attr in func.attributes:
+            if hasattr(attr, "name") and attr.name in ["compute", "compute_main"]:
+                return True
+        return False
+
+    def generate_function(self, func, indent=1):
+        code = ""
+        indent_str = "    " * indent
+
+        # Generate function parameters
+        params = []
+        if hasattr(func, "params") and func.params:
+            for p in func.params:
+                param_str = f"{self.map_type(p.vtype)} {p.name}"
+                if hasattr(p, "attributes") and p.attributes:
+                    semantic = self.map_semantic(p.attributes)
+                    if semantic:
+                        param_str += f" {semantic}"
+                params.append(param_str)
+
+        params_str = ", ".join(params) if params else ""
+        return_type = self.map_type(func.return_type) if func.return_type else "void"
+
+        # Generate function attributes
+        func_attributes = ""
+        if hasattr(func, "attributes") and func.attributes:
+            func_attributes = self.map_semantic(func.attributes)
+
+        code += (
+            f"{indent_str}{return_type} {func.name}({params_str}){func_attributes} {{\n"
+        )
+
+        # Generate function body
+        if hasattr(func, "body") and func.body:
+            code += self.generate_function_body(func.body, indent + 1)
+
+        code += f"{indent_str}}}\n\n"
+        return code
+
+    def generate_function_body(self, body, indent=0):
+        code = ""
+        indent_str = "    " * indent
+
+        for stmt in body:
+            code += indent_str
+            if isinstance(stmt, VariableDeclarationNode):
+                code += self.generate_variable_declaration(stmt) + ";\n"
+            elif isinstance(stmt, VariableNode):
+                if hasattr(stmt, "vtype") and stmt.vtype:
+                    code += f"{self.map_type(stmt.vtype)} {stmt.name};\n"
+                else:
+                    code += f"{stmt.name};\n"
+            elif isinstance(stmt, AssignmentNode):
+                code += self.generate_assignment(stmt) + ";\n"
+            elif isinstance(stmt, ReturnNode):
+                code += f"return {self.generate_expression(stmt.value)};\n"
+            elif isinstance(stmt, BinaryOpNode):
+                code += f"{self.generate_expression(stmt)};\n"
+            elif isinstance(stmt, ForNode):
+                code += self.generate_for_loop(stmt, indent)
+            elif isinstance(stmt, WhileNode):
+                code += self.generate_while_loop(stmt, indent)
+            elif isinstance(stmt, IfNode):
+                code += self.generate_if_statement(stmt, indent)
+            elif isinstance(stmt, SwitchNode):
+                code += self.generate_switch_statement(stmt, indent)
+            elif isinstance(stmt, FunctionCallNode):
+                code += f"{self.generate_expression(stmt)};\n"
+            elif isinstance(stmt, str):
+                code += f"{stmt};\n"
+            else:
+                # For any unhandled statement type
+                code += f"// Unhandled statement type: {type(stmt).__name__}\n"
+
+        return code
+
+    def generate_variable_declaration(self, node):
+        var_type = "var" if node.var_type == "var" else "let"
+        if hasattr(node, "initial_value") and node.initial_value:
+            return f"{var_type} {node.name} = {self.generate_expression(node.initial_value)}"
+        else:
+            return f"{var_type} {node.name}"
+
+    def generate_assignment(self, node):
+        left = self.generate_expression(node.left)
+        right = self.generate_expression(node.right)
+        op = node.operator if hasattr(node, "operator") else "="
+        return f"{left} {op} {right}"
+
+    def generate_for_loop(self, node, indent):
+        indent_str = "    " * indent
+        init = self.generate_expression(node.init) if node.init else ""
+        condition = (
+            self.generate_expression(node.condition) if node.condition else "true"
+        )
+        update = self.generate_expression(node.update) if node.update else ""
+
+        code = f"for ({init}; {condition}; {update}) {{\n"
+        if hasattr(node, "body") and node.body:
+            code += self.generate_function_body(node.body, indent + 1)
+        code += indent_str + "}\n"
+        return code
+
+    def generate_while_loop(self, node, indent):
+        indent_str = "    " * indent
+        condition = (
+            self.generate_expression(node.condition) if node.condition else "true"
+        )
+
+        code = f"while ({condition}) {{\n"
+        if hasattr(node, "body") and node.body:
+            code += self.generate_function_body(node.body, indent + 1)
+        code += indent_str + "}\n"
+        return code
+
+    def generate_if_statement(self, node, indent):
+        indent_str = "    " * indent
+        condition = self.generate_expression(node.condition)
+
+        code = f"if ({condition}) {{\n"
+        if hasattr(node, "if_body") and node.if_body:
+            code += self.generate_function_body(node.if_body, indent + 1)
+        code += indent_str + "}"
+
+        if hasattr(node, "else_body") and node.else_body:
+            # Check if else_body is a list
+            if isinstance(node.else_body, list):
+                if len(node.else_body) == 1 and isinstance(node.else_body[0], IfNode):
+                    # This is an elif statement
+                    code += " else "
+                    code += self.generate_if_statement(node.else_body[0], indent)
+                else:
+                    # Regular else with multiple statements
+                    code += " else {\n"
+                    code += self.generate_function_body(node.else_body, indent + 1)
+                    code += indent_str + "}"
+            elif isinstance(node.else_body, IfNode):
+                # Direct IfNode for elif
+                code += " else "
+                code += self.generate_if_statement(node.else_body, indent)
+            else:
+                # Regular else body
+                code += " else {\n"
+                code += self.generate_function_body([node.else_body], indent + 1)
+                code += indent_str + "}"
+
+        code += "\n"
+        return code
+
+    def generate_switch_statement(self, node, indent):
+        indent_str = "    " * indent
+        expression = self.generate_expression(node.expression)
+
+        code = f"switch ({expression}) {{\n"
+
+        # Generate case statements
+        if hasattr(node, "cases") and node.cases:
+            for case in node.cases:
+                if hasattr(case, "condition") and case.condition is not None:
+                    case_value = self.generate_expression(case.condition)
+                    code += indent_str + f"    case {case_value}:\n"
+                else:
+                    code += indent_str + "    default:\n"
+
+                if hasattr(case, "body") and case.body:
+                    code += self.generate_function_body(case.body, indent + 2)
+                code += indent_str + "        break;\n"
+
+        code += indent_str + "}\n"
+        return code
+
+    def generate_expression(self, expr):
+        if expr is None:
+            return ""
+        elif isinstance(expr, str):
+            return expr
+        elif isinstance(expr, (int, float, bool)):
+            return str(expr)
+        elif isinstance(expr, VariableNode):
+            if hasattr(expr, "vtype") and expr.vtype:
+                # If this is a type declaration, format it properly
+                return f"{self.map_type(expr.vtype)} {expr.name}"
+            else:
+                # Just a variable reference
+                return expr.name
+        elif isinstance(expr, VariableDeclarationNode):
+            return self.generate_variable_declaration(expr)
+        elif isinstance(expr, AssignmentNode):
+            return self.generate_assignment(expr)
+        elif isinstance(expr, BinaryOpNode):
+            left = self.generate_expression(expr.left)
+            right = self.generate_expression(expr.right)
+            op = expr.op if hasattr(expr, "op") else "+"
+            return f"({left} {op} {right})"
+        elif isinstance(expr, UnaryOpNode):
+            operand = self.generate_expression(expr.operand)
+            op = expr.op if hasattr(expr, "op") else "+"
+            return f"({op}{operand})"
+        elif isinstance(expr, FunctionCallNode):
+            args = []
+            if hasattr(expr, "args") and expr.args:
+                args = [self.generate_expression(arg) for arg in expr.args]
+            args_str = ", ".join(args)
+            func_name = self.map_function(expr.name)
+            return f"{func_name}({args_str})"
+        elif isinstance(expr, MemberAccessNode):
+            obj = self.generate_expression(expr.object)
+            return f"{obj}.{expr.member}"
+        elif isinstance(expr, TernaryOpNode):
+            condition = self.generate_expression(expr.condition)
+            true_expr = self.generate_expression(expr.true_expr)
+            false_expr = self.generate_expression(expr.false_expr)
+            return f"({condition} ? {true_expr} : {false_expr})"
+        elif isinstance(expr, VectorConstructorNode):
+            args = []
+            if hasattr(expr, "args") and expr.args:
+                args = [self.generate_expression(arg) for arg in expr.args]
+            args_str = ", ".join(args)
+            type_name = self.map_type(expr.type_name)
+            return f"{type_name}({args_str})"
+        elif isinstance(expr, ArrayAccessNode):
+            array = self.generate_expression(expr.array)
+            index = self.generate_expression(expr.index)
+            return f"{array}[{index}]"
+        else:
+            # For any unhandled expression type
+            return f"/* Unhandled expression: {type(expr).__name__} */"
+
+    def map_type(self, mojo_type):
+        if mojo_type is None:
+            return "void"
+        return self.type_map.get(mojo_type, mojo_type)
+
+    def map_semantic(self, attributes):
+        if not attributes:
+            return ""
+
+        for attr in attributes:
+            if hasattr(attr, "name"):
+                semantic = self.semantic_map.get(attr.name, attr.name)
+                return f"@ {semantic}"
+        return ""
+
+    def map_function(self, func_name):
+        return self.function_map.get(func_name, func_name)
diff --git a/crosstl/backend/Mojo/MojoLexer.py b/crosstl/backend/Mojo/MojoLexer.py
index 2d69251..2be7b5f 100644
--- a/crosstl/backend/Mojo/MojoLexer.py
+++ b/crosstl/backend/Mojo/MojoLexer.py
@@ -15,17 +15,31 @@ TOKENS = tuple(
         ("FN", r"\bfn\b"),
         ("RETURN", r"\breturn\b"),
         ("IF", r"\bif\b"),
+        ("ELIF", r"\belif\b"),
         ("ELSE", r"\belse\b"),
         ("FOR", r"\bfor\b"),
         ("WHILE", r"\bwhile\b"),
+        ("SWITCH", r"\bswitch\b"),
+        ("CASE", r"\bcase\b"),
+        ("DEFAULT", r"\bdefault\b"),
+        ("BREAK", r"\bbreak\b"),
+        ("CONTINUE", r"\bcontinue\b"),
         ("IMPORT", r"\bimport\b"),
+        ("AS", r"\bas\b"),
+        ("IN", r"\bin\b"),
+        ("PASS", r"\bpass\b"),
         ("DEF", r"\bdef\b"),
+        ("CLASS", r"\bclass\b"),
+        ("CONSTANT", r"\bconstant\b"),
         ("INT", r"\bInt\b"),
         ("FLOAT", r"\bFloat\b"),
         ("BOOL", r"\bBool\b"),
         ("STRING", r"\bString\b"),
         ("IDENTIFIER", r"[a-zA-Z_][a-zA-Z0-9_]*"),
-        ("NUMBER", r"\d+(\.\d+)?"),
+        (
+            "NUMBER",
+            r"0[xX][0-9a-fA-F]+|0[bB][01]+|0[oO][0-7]+|\d+(\.\d+)?([eE][+-]?\d+)?",
+        ),
         ("LBRACE", r"\{"),
         ("RBRACE", r"\}"),
         ("LPAREN", r"\("),
@@ -36,6 +50,11 @@ TOKENS = tuple(
         ("STRING_LITERAL", r'"[^"]*"'),
         ("COMMA", r","),
         ("COLON", r":"),
+        ("QUESTION", r"\?"),
+        ("ASSIGN_SHIFT_LEFT", r"<<="),
+        ("ASSIGN_SHIFT_RIGHT", r">>="),
+        ("SHIFT_LEFT", r"<<"),
+        ("SHIFT_RIGHT", r">>"),
         ("LESS_EQUAL", r"<="),
         ("GREATER_EQUAL", r">="),
         ("LESS_THAN", r"<"),
@@ -46,16 +65,25 @@ TOKENS = tuple(
         ("MINUS_EQUALS", r"-="),
         ("MULTIPLY_EQUALS", r"\*="),
         ("DIVIDE_EQUALS", r"/="),
+        ("ASSIGN_XOR", r"\^="),
+        ("ASSIGN_OR", r"\|="),
+        ("ASSIGN_AND", r"\&="),
+        ("ASSIGN_MOD", r"%="),
         ("PLUS", r"\+"),
         ("MINUS", r"-"),
         ("MULTIPLY", r"\*"),
         ("DIVIDE", r"/"),
         ("AND", r"&&"),
         ("OR", r"\|\|"),
+        ("BITWISE_AND", r"&"),
+        ("BITWISE_OR", r"\|"),
+        ("BITWISE_XOR", r"\^"),
         ("DOT", r"\."),
         ("EQUALS", r"="),
         ("WHITESPACE", r"\s+"),
         ("MOD", r"%"),
+        ("AT", r"@"),
+        ("ATTRIBUTE", r"\[\[[^\]]*\]\]"),
     ]
 )
 
@@ -68,11 +96,22 @@ KEYWORDS = {
     "fn": "FN",
     "return": "RETURN",
     "if": "IF",
+    "elif": "ELIF",
     "else": "ELSE",
     "for": "FOR",
     "while": "WHILE",
+    "switch": "SWITCH",
+    "case": "CASE",
+    "default": "DEFAULT",
+    "break": "BREAK",
+    "continue": "CONTINUE",
     "import": "IMPORT",
+    "as": "AS",
+    "in": "IN",
+    "pass": "PASS",
     "def": "DEF",
+    "class": "CLASS",
+    "constant": "CONSTANT",
     "Int": "INT",
     "Float": "FLOAT",
     "Bool": "BOOL",
diff --git a/crosstl/backend/Mojo/MojoParser.py b/crosstl/backend/Mojo/MojoParser.py
index 4daa727..1e7daa0 100644
--- a/crosstl/backend/Mojo/MojoParser.py
+++ b/crosstl/backend/Mojo/MojoParser.py
@@ -172,6 +172,10 @@ class MojoParser:
         post_attributes = self.parse_attributes()
         attributes.extend(post_attributes)
 
+        # Consume the colon that starts the function body in Mojo syntax
+        if self.current_token[0] == "COLON":
+            self.eat("COLON")
+
         body = self.parse_block()
 
         return FunctionNode(qualifier, return_type, name, params, body, attributes)
@@ -237,21 +241,28 @@ class MojoParser:
         return attributes
 
     def parse_block(self):
-        if self.current_token[0] == "COLON":
-            self.eat("COLON")
-        elif self.current_token[0] == "LBRACE":
+        if self.current_token[0] == "LBRACE":
             self.eat("LBRACE")
+            statements = []
+            while self.current_token[0] != "RBRACE" and self.current_token[0] != "EOF":
+                statements.append(self.parse_statement())
+            if self.current_token[0] == "RBRACE":
+                self.eat("RBRACE")
+            return statements
         else:
-            raise SyntaxError(f"Expected COLON or LBRACE, got {self.current_token[0]}")
-
-        statements = []
-        while self.current_token[0] != "RBRACE" and self.current_token[0] != "EOF":
-            statements.append(self.parse_statement())
-
-        if self.current_token[0] == "RBRACE":
-            self.eat("RBRACE")
-
-        return statements
+            # Handle Mojo/Python-style blocks (statements follow after colon)
+            statements = []
+            # Parse statements until we hit a dedent or EOF
+            while (
+                self.current_token[0] != "EOF"
+                and self.current_token[0] not in ["ELSE", "ELIF", "CASE", "DEFAULT"]
+                and self.pos < len(self.tokens) - 1
+            ):
+                statements.append(self.parse_statement())
+                # Break if we're at the end or hit something that looks like end of block
+                if self.current_token[0] in ["EOF", "FN", "STRUCT", "CLASS"]:
+                    break
+            return statements
 
     def parse_statement(self):
         if self.current_token[0] in [
@@ -275,6 +286,21 @@ class MojoParser:
             return self.parse_while_statement()
         elif self.current_token[0] == "RETURN":
             return self.parse_return_statement()
+        elif self.current_token[0] == "BREAK":
+            self.eat("BREAK")
+            if self.current_token[0] == "SEMICOLON":
+                self.eat("SEMICOLON")
+            return BreakNode()
+        elif self.current_token[0] == "CONTINUE":
+            self.eat("CONTINUE")
+            if self.current_token[0] == "SEMICOLON":
+                self.eat("SEMICOLON")
+            return ContinueNode()
+        elif self.current_token[0] == "PASS":
+            self.eat("PASS")
+            if self.current_token[0] == "SEMICOLON":
+                self.eat("SEMICOLON")
+            return PassNode()
         elif self.current_token[0] == "SWITCH":
             return self.parse_switch_statement()
         elif self.current_token[0] == "STRUCT":
@@ -289,10 +315,11 @@ class MojoParser:
             name = self.current_token[1]
             self.eat("IDENTIFIER")
 
+            vtype = None
             if self.current_token[0] == "COLON":
                 self.eat("COLON")
-                self.current_token[1]
-                self.eat(self.current_token[0])
+                # Parse the type, which might be a generic type with square brackets
+                vtype = self.parse_type()
 
             initial_value = None
             if self.current_token[0] == "EQUALS":
@@ -303,54 +330,112 @@ class MojoParser:
             if self.current_token[0] == "SEMICOLON":
                 self.eat("SEMICOLON")
 
-            return VariableDeclarationNode(var_type, name, initial_value)
+            return VariableDeclarationNode(var_type, name, initial_value, vtype)
         else:
             return self.parse_assignment()
 
     def parse_if_statement(self):
         self.eat("IF")
-        self.eat("LPAREN")
         condition = self.parse_expression()
-        self.eat("RPAREN")
+        self.eat("COLON")
         if_body = self.parse_block()
+
+        # Handle elif and else statements properly
         else_body = None
+        while self.current_token[0] == "ELIF":
+            self.eat("ELIF")
+            elif_condition = self.parse_expression()
+            self.eat("COLON")
+            elif_body = self.parse_block()
+            # Create nested if for elif
+            elif_node = IfNode(elif_condition, elif_body, None)
+            if else_body is None:
+                else_body = [elif_node]
+            else:
+                # Find the deepest else and add the elif there
+                current = else_body[0]
+                while isinstance(current, IfNode) and current.else_body:
+                    current = current.else_body[0]
+                current.else_body = [elif_node]
+
         if self.current_token[0] == "ELSE":
             self.eat("ELSE")
-            else_body = self.parse_block()
+            self.eat("COLON")
+            final_else_body = self.parse_block()
+            if else_body is None:
+                else_body = final_else_body
+            else:
+                # Find the deepest else and add the final else there
+                current = else_body[0]
+                while isinstance(current, IfNode) and current.else_body:
+                    current = current.else_body[0]
+                current.else_body = final_else_body
+
         return IfNode(condition, if_body, else_body)
 
     def parse_for_statement(self):
         self.eat("FOR")
-        self.eat("LPAREN")
 
-        init = self.parse_variable_declaration_or_assignment()
-        self.eat("SEMICOLON")
-        condition = self.parse_expression()
-        self.eat("SEMICOLON")
-        update = self.parse_expression()
-        self.eat("RPAREN")
-        body = self.parse_block()
+        # Check if this is a C-style for loop (with semicolons) or Python-style
+        # Save current position to look ahead
+        saved_pos = self.pos
+        saved_token = self.current_token
+
+        # Try to parse as C-style for loop first
+        try:
+            init = self.parse_variable_declaration_or_assignment()
+            # The variable declaration may have already consumed the semicolon
+            # So we need to check if we're at the condition part
+            if self.current_token[0] == "SEMICOLON":
+                self.eat("SEMICOLON")
+
+            # Now parse the condition
+            condition = self.parse_expression()
+            self.eat("SEMICOLON")
+            update = self.parse_expression()
+            self.eat("COLON")
+            body = self.parse_block()
+            return ForNode(init, condition, update, body)
+
+        except Exception:
+            # Restore position if C-style parsing failed
+            self.pos = saved_pos
+            self.current_token = saved_token
+
+        # Try Python-style for loop: for item in iterable:
+        if self.current_token[0] == "IDENTIFIER":
+            var_name = self.current_token[1]
+            self.eat("IDENTIFIER")
+            if self.current_token[0] == "IN":
+                self.eat("IN")
+                iterable = self.parse_expression()
+                self.eat("COLON")
+                body = self.parse_block()
+                # Create a Python-style for loop node
+                return ForNode(VariableNode("", var_name), iterable, None, body)
 
-        return ForNode(init, condition, update, body)
+        # If neither worked, error out
+        raise SyntaxError(
+            f"Invalid for loop syntax. Expected C-style 'for init; condition; update:' or Python-style 'for var in iterable:'"
+        )
 
     def parse_while_statement(self):
         self.eat("WHILE")
-        self.eat("LPAREN")
         condition = self.parse_expression()
-        self.eat("RPAREN")
+        self.eat("COLON")
         body = self.parse_block()
         return WhileNode(condition, body)
 
     def parse_switch_statement(self):
         self.eat("SWITCH")
-        self.eat("LPAREN")
         expression = self.parse_expression()
-        self.eat("RPAREN")
-        self.eat("LBRACE")
+        self.eat("COLON")
         cases = []
-        while self.current_token[0] != "RBRACE":
+        while self.current_token[0] != "EOF" and self.current_token[0] in [
+            "CASE",
+            "DEFAULT",
+        ]:
             cases.append(self.parse_switch_case())
-        self.eat("RBRACE")
         return SwitchNode(expression, cases)
 
     def parse_switch_case(self):
@@ -381,7 +466,9 @@ class MojoParser:
 
     def parse_expression_statement(self):
         expr = self.parse_expression()
-        self.eat("SEMICOLON")
+        # Semicolons are optional in Mojo/Python-style syntax
+        if self.current_token[0] == "SEMICOLON":
+            self.eat("SEMICOLON")
         return expr
 
     def parse_expression(self):
@@ -395,6 +482,12 @@ class MojoParser:
             "MINUS_EQUALS",
             "MULTIPLY_EQUALS",
             "DIVIDE_EQUALS",
+            "ASSIGN_XOR",
+            "ASSIGN_OR",
+            "ASSIGN_AND",
+            "ASSIGN_SHIFT_LEFT",
+            "ASSIGN_SHIFT_RIGHT",
+            "ASSIGN_MOD",
         ]:
             op = self.current_token[1]
             self.eat(self.current_token[0])
@@ -418,10 +511,37 @@ class MojoParser:
         return left
 
     def parse_logical_and(self):
-        left = self.parse_equality()
+        left = self.parse_bitwise_or()
         while self.current_token[0] == "AND":
             op = self.current_token[1]
             self.eat("AND")
+            right = self.parse_bitwise_or()
+            left = BinaryOpNode(left, op, right)
+        return left
+
+    def parse_bitwise_or(self):
+        left = self.parse_bitwise_xor()
+        while self.current_token[0] == "BITWISE_OR":
+            op = self.current_token[1]
+            self.eat("BITWISE_OR")
+            right = self.parse_bitwise_xor()
+            left = BinaryOpNode(left, op, right)
+        return left
+
+    def parse_bitwise_xor(self):
+        left = self.parse_bitwise_and()
+        while self.current_token[0] == "BITWISE_XOR":
+            op = self.current_token[1]
+            self.eat("BITWISE_XOR")
+            right = self.parse_bitwise_and()
+            left = BinaryOpNode(left, op, right)
+        return left
+
+    def parse_bitwise_and(self):
+        left = self.parse_equality()
+        while self.current_token[0] == "BITWISE_AND":
+            op = self.current_token[1]
+            self.eat("BITWISE_AND")
             right = self.parse_equality()
             left = BinaryOpNode(left, op, right)
         return left
@@ -436,13 +556,22 @@ class MojoParser:
         return left
 
     def parse_relational(self):
-        left = self.parse_additive()
+        left = self.parse_shift()
         while self.current_token[0] in [
             "LESS_THAN",
             "GREATER_THAN",
             "LESS_EQUAL",
             "GREATER_EQUAL",
         ]:
+            op = self.current_token[1]
+            self.eat(self.current_token[0])
+            right = self.parse_shift()
+            left = BinaryOpNode(left, op, right)
+        return left
+
+    def parse_shift(self):
+        left = self.parse_additive()
+        while self.current_token[0] in ["SHIFT_LEFT", "SHIFT_RIGHT"]:
             op = self.current_token[1]
             self.eat(self.current_token[0])
             right = self.parse_additive()
@@ -476,45 +605,40 @@ class MojoParser:
         return self.parse_primary()
 
     def parse_primary(self):
-        if self.current_token[0] in [
-            "IDENTIFIER",
-            "NUMBER",
-            "INT",
-            "FLOAT",
-            "BOOL",
-            "STRING",
-        ]:
-            if self.current_token[0] in ["INT", "FLOAT", "BOOL", "STRING"]:
-                type_name = self.current_token[1]
-                self.eat(self.current_token[0])
-                if self.current_token[0] == "IDENTIFIER":
-                    var_name = self.current_token[1]
-                    self.eat("IDENTIFIER")
-                    if self.current_token[0] == "COLON":
-                        self.eat("COLON")
-                        type_annotation = self.current_token[1]
-                        self.eat(self.current_token[0])
-                        return VariableNode(type_annotation, var_name)
-                    return VariableNode(type_name, var_name)
-                elif self.current_token[0] == "LPAREN":
-                    return self.parse_function_call_or_identifier()
-            elif self.current_token[0] == "NUMBER":
-                value = self.current_token[1]
-                self.eat("NUMBER")
-                return value
-
+        if self.current_token[0] == "IDENTIFIER":
             return self.parse_function_call_or_identifier()
-
+        elif self.current_token[0] == "NUMBER":
+            value = self.current_token[1]
+            self.eat("NUMBER")
+            return value
+        elif self.current_token[0] == "STRING_LITERAL":
+            value = self.current_token[1]
+            self.eat("STRING_LITERAL")
+            return value
+        elif self.current_token[0] in ["INT", "FLOAT", "BOOL", "STRING"]:
+            type_name = self.current_token[1]
+            self.eat(self.current_token[0])
+            if self.current_token[0] == "IDENTIFIER":
+                var_name = self.current_token[1]
+                self.eat("IDENTIFIER")
+                if self.current_token[0] == "COLON":
+                    self.eat("COLON")
+                    type_annotation = self.current_token[1]
+                    self.eat(self.current_token[0])
+                    return VariableNode(type_annotation, var_name)
+                return VariableNode(type_name, var_name)
+            elif self.current_token[0] == "LPAREN":
+                # Handle vector constructors like float4(...)
+                return self.parse_vector_constructor(type_name)
+            return type_name
         elif self.current_token[0] == "LPAREN":
             self.eat("LPAREN")
             expr = self.parse_expression()
             self.eat("RPAREN")
             return expr
-
         # Handle top-level keywords
         elif self.current_token[0] in ["FN", "STRUCT", "CLASS", "LET", "VAR"]:
             raise SyntaxError(f"Unexpected top-level keyword: {self.current_token[0]}")
-
         else:
             raise SyntaxError(
                 f"Unexpected token in expression: {self.current_token[0]}"
@@ -539,6 +663,8 @@ class MojoParser:
                 return self.parse_function_call(name)
             elif self.current_token[0] == "DOT":
                 return self.parse_member_access(name)
+            elif self.current_token[0] == "LBRACKET":
+                return self.parse_array_access(name)
             elif self.current_token[0] == "COLON":
                 self.eat("COLON")
                 type_annotation = self.current_token[1]
@@ -600,3 +726,49 @@ class MojoParser:
                     self.eat("COMMA")
             self.eat("RPAREN")
         return DecoratorNode(name, args)
+
+    def parse_array_access(self, name):
+        self.eat("LBRACKET")
+        index = self.parse_expression()
+        self.eat("RBRACKET")
+        return ArrayAccessNode(name, index)
+
+    def parse_type(self):
+        """Parse a type, which might be a generic type with square brackets"""
+        type_name = ""
+
+        # Handle basic type name
+        if self.current_token[0] in ["IDENTIFIER", "INT", "FLOAT", "BOOL", "STRING"]:
+            type_name = self.current_token[1]
+            self.eat(self.current_token[0])
+
+            # Handle generic types with square brackets like StaticTuple[Float32, 4]
+            if self.current_token[0] == "LBRACKET":
+                type_name += "["
+                self.eat("LBRACKET")
+
+                # Parse type parameters
+                while self.current_token[0] != "RBRACKET":
+                    if self.current_token[0] == "IDENTIFIER":
+                        type_name += self.current_token[1]
+                        self.eat("IDENTIFIER")
+                    elif self.current_token[0] == "NUMBER":
+                        type_name += self.current_token[1]
+                        self.eat("NUMBER")
+                    elif self.current_token[0] == "COMMA":
+                        type_name += ", "
+                        self.eat("COMMA")
+                    elif self.current_token[0] in ["INT", "FLOAT", "BOOL", "STRING"]:
+                        type_name += self.current_token[1]
+                        self.eat(self.current_token[0])
+                    else:
+                        # Handle nested generic types or other complex type constructs
+                        type_name += self.current_token[1]
+                        self.eat(self.current_token[0])
+
+                type_name += "]"
+                self.eat("RBRACKET")
+
+            return type_name
+        else:
+            raise SyntaxError(f"Expected type name, got {self.current_token[0]}")
diff --git a/crosstl/backend/Mojo/__init__.py b/crosstl/backend/Mojo/__init__.py
index 1e7d61b..89eb68d 100644
--- a/crosstl/backend/Mojo/__init__.py
+++ b/crosstl/backend/Mojo/__init__.py
@@ -1,3 +1,4 @@
 from .MojoAst import *
 from .MojoLexer import *
 from .MojoParser import *
+from .MojoCrossGLCodeGen import MojoToCrossGLConverter
diff --git a/crosstl/formatter.py b/crosstl/formatter.py
index f2396d5..a6b7abc 100644
--- a/crosstl/formatter.py
+++ b/crosstl/formatter.py
@@ -16,6 +16,7 @@ class ShaderLanguage(Enum):
     GLSL = "glsl"
     METAL = "metal"
     SPIRV = "spirv"
+    MOJO = "mojo"
     UNKNOWN = "unknown"
 
 
@@ -310,6 +311,7 @@ def format_shader_code(code, backend, output_path=None):
         "directx": ShaderLanguage.HLSL,
         "opengl": ShaderLanguage.GLSL,
         "vulkan": ShaderLanguage.SPIRV,
+        "mojo": ShaderLanguage.MOJO,
     }
 
     language = language_map.get(backend.lower())
diff --git a/crosstl/translator/codegen/mojo_codegen.py b/crosstl/translator/codegen/mojo_codegen.py
index 8af3a4b..5c1816e 100644
--- a/crosstl/translator/codegen/mojo_codegen.py
+++ b/crosstl/translator/codegen/mojo_codegen.py
@@ -21,173 +21,479 @@ from .array_utils import parse_array_type, format_array_type, get_array_size_fro
 
 class MojoCodeGen:
     def __init__(self):
-        self.indent_level = 0
-        self.indent_str = "    "
+        self.current_shader = None
+        self.type_mapping = {
+            # Scalar Types
+            "void": "None",
+            "int": "Int32",
+            "short": "Int16",
+            "long": "Int64",
+            "uint": "UInt32",
+            "ushort": "UInt16",
+            "ulong": "UInt64",
+            "float": "Float32",
+            "double": "Float64",
+            "half": "Float16",
+            "bool": "Bool",
+            # Vector Types
+            "vec2": "SIMD[DType.float32, 2]",
+            "vec3": "SIMD[DType.float32, 3]",
+            "vec4": "SIMD[DType.float32, 4]",
+            "ivec2": "SIMD[DType.int32, 2]",
+            "ivec3": "SIMD[DType.int32, 3]",
+            "ivec4": "SIMD[DType.int32, 4]",
+            "uvec2": "SIMD[DType.uint32, 2]",
+            "uvec3": "SIMD[DType.uint32, 3]",
+            "uvec4": "SIMD[DType.uint32, 4]",
+            "bvec2": "SIMD[DType.bool, 2]",
+            "bvec3": "SIMD[DType.bool, 3]",
+            "bvec4": "SIMD[DType.bool, 4]",
+            # Matrix Types
+            "mat2": "Matrix[DType.float32, 2, 2]",
+            "mat3": "Matrix[DType.float32, 3, 3]",
+            "mat4": "Matrix[DType.float32, 4, 4]",
+            # Texture Types (Mojo equivalents)
+            "sampler2D": "Texture2D",
+            "samplerCube": "TextureCube",
+            "sampler": "Sampler",
+        }
 
-    def indent(self):
-        return self.indent_str * self.indent_level
+        self.semantic_map = {
+            # Vertex attributes
+            "gl_VertexID": "vertex_id",
+            "gl_InstanceID": "instance_id",
+            "gl_Position": "position",
+            "gl_PointSize": "point_size",
+            "gl_ClipDistance": "clip_distance",
+            # Fragment attributes
+            "gl_FragColor": "color(0)",
+            "gl_FragColor0": "color(0)",
+            "gl_FragColor1": "color(1)",
+            "gl_FragColor2": "color(2)",
+            "gl_FragColor3": "color(3)",
+            "gl_FragDepth": "depth(any)",
+            "gl_FragCoord": "position",
+            "gl_FrontFacing": "front_facing",
+            "gl_PointCoord": "point_coord",
+            # Standard vertex semantics
+            "POSITION": "position",
+            "NORMAL": "normal",
+            "TANGENT": "tangent",
+            "BINORMAL": "binormal",
+            "TEXCOORD": "texcoord",
+            "TEXCOORD0": "texcoord0",
+            "TEXCOORD1": "texcoord1",
+            "TEXCOORD2": "texcoord2",
+            "TEXCOORD3": "texcoord3",
+            "COLOR": "color",
+            "COLOR0": "color0",
+            "COLOR1": "color1",
+        }
+
+        # Function mapping for common shader functions
+        self.function_map = {
+            "texture": "sample",
+            "normalize": "normalize",
+            "dot": "dot_product",
+            "cross": "cross_product",
+            "length": "magnitude",
+            "reflect": "reflect",
+            "refract": "refract",
+            "sin": "sin",
+            "cos": "cos",
+            "tan": "tan",
+            "sqrt": "sqrt",
+            "pow": "power",
+            "abs": "abs",
+            "min": "min",
+            "max": "max",
+            "clamp": "clamp",
+            "mix": "lerp",
+            "smoothstep": "smoothstep",
+            "step": "step",
+        }
 
     def generate(self, ast):
-        if isinstance(ast, list):
-            result = ""
-            for node in ast:
-                result += self.generate(node) + "\n"
-            return result
-        elif isinstance(ast, ShaderNode):
-            return self.generate_shader(ast)
-        elif isinstance(ast, StructNode):
-            return self.generate_struct(ast)
-        else:
-            # Return empty string for unhandled node types
-            return ""
-
-    def generate_shader(self, node):
-        result = ""
-
-        # Generate struct definitions
-        for struct in node.structs:
-            result += self.generate_struct(struct) + "\n\n"
-
-        # Generate vertex and fragment shaders
-        for function in node.functions:
-            if function.qualifier == "vertex":
-                result += "# Vertex Shader\n"
-                result += self.generate_function(function) + "\n\n"
-            elif function.qualifier == "fragment":
-                result += "# Fragment Shader\n"
-                result += self.generate_function(function) + "\n\n"
+        code = "# Generated Mojo Shader Code\n"
+        code += "from math import *\n"
+        code += "from simd import *\n"
+        code += "from gpu import *\n\n"
+
+        # Generate structs
+        for node in ast.structs:
+            if isinstance(node, StructNode):
+                code += self.generate_struct(node)
+
+        # Generate global variables
+        for node in ast.global_variables:
+            if isinstance(node, ArrayNode):
+                code += self.generate_array_declaration(node)
+            else:
+                code += f"var {node.name}: {self.map_type(node.vtype)}\n"
+
+        # Generate cbuffers as structs
+        if ast.cbuffers:
+            code += "# Constant Buffers\n"
+            code += self.generate_cbuffers(ast)
+
+        # Generate functions
+        for func in ast.functions:
+            if func.qualifier == "vertex":
+                code += "# Vertex Shader\n"
+                code += self.generate_function(func, shader_type="vertex")
+            elif func.qualifier == "fragment":
+                code += "# Fragment Shader\n"
+                code += self.generate_function(func, shader_type="fragment")
+            elif func.qualifier == "compute":
+                code += "# Compute Shader\n"
+                code += self.generate_function(func, shader_type="compute")
             else:
-                result += self.generate_function(function) + "\n\n"
+                code += self.generate_function(func)
 
-        return result
+        return code
 
     def generate_struct(self, node):
-        result = f"struct {node.name}:\n"
-        self.indent_level += 1
+        code = f"@value\nstruct {node.name}:\n"
 
         # Generate struct members
         for member in node.members:
-            semantic = f" # {member.semantic}" if member.semantic else ""
-            result += f"{self.indent()}{member.name}: {self.convert_type(member.vtype)}{semantic}\n"
-
-        self.indent_level -= 1
-        return result
-
-    def generate_function(self, node):
-        ret_type = self.convert_type(node.return_type)
-
-        # Handle parameters which are VariableNode objects
-        params_str = ""
-        if node.params:
-            if isinstance(node.params[0], VariableNode):
-                # Handle list of VariableNode objects
-                params_str = ", ".join(
-                    [
-                        f"{param.name}: {self.convert_type(param.vtype)}"
-                        for param in node.params
-                    ]
-                )
+            if isinstance(member, ArrayNode):
+                if member.size:
+                    code += f"    var {member.name}: StaticTuple[{self.map_type(member.element_type)}, {member.size}]\n"
+                else:
+                    code += f"    var {member.name}: DynamicVector[{self.map_type(member.element_type)}]\n"
             else:
-                # Handle tuples of (type, name)
-                params_str = ", ".join(
-                    [
-                        f"{param_name}: {self.convert_type(param_type)}"
-                        for param_type, param_name in node.params
-                    ]
+                semantic = (
+                    f"  # {self.map_semantic(member.semantic)}"
+                    if member.semantic
+                    else ""
                 )
+                code += (
+                    f"    var {member.name}: {self.map_type(member.vtype)}{semantic}\n"
+                )
+
+        code += "\n"
+        return code
+
+    def generate_cbuffers(self, ast):
+        code = ""
+        for node in ast.cbuffers:
+            if isinstance(node, StructNode):
+                code += f"@value\nstruct {node.name}:\n"
+                for member in node.members:
+                    if isinstance(member, ArrayNode):
+                        if member.size:
+                            code += f"    var {member.name}: StaticTuple[{self.map_type(member.element_type)}, {member.size}]\n"
+                        else:
+                            code += f"    var {member.name}: DynamicVector[{self.map_type(member.element_type)}]\n"
+                    else:
+                        code += (
+                            f"    var {member.name}: {self.map_type(member.vtype)}\n"
+                        )
+                code += "\n"
+            elif hasattr(node, "name") and hasattr(node, "members"):  # CbufferNode
+                code += f"@value\nstruct {node.name}:\n"
+                for member in node.members:
+                    if isinstance(member, ArrayNode):
+                        if member.size:
+                            code += f"    var {member.name}: StaticTuple[{self.map_type(member.element_type)}, {member.size}]\n"
+                        else:
+                            code += f"    var {member.name}: DynamicVector[{self.map_type(member.element_type)}]\n"
+                    else:
+                        code += (
+                            f"    var {member.name}: {self.map_type(member.vtype)}\n"
+                        )
+                code += "\n"
+        return code
+
+    def generate_function(self, func, indent=0, shader_type=None):
+        code = ""
+        "    " * indent
+
+        # Generate function parameters
+        params = []
+        for p in func.params:
+            param_semantic = (
+                f"  # {self.map_semantic(p.semantic)}" if p.semantic else ""
+            )
+            params.append(f"{p.name}: {self.map_type(p.vtype)}{param_semantic}")
 
-        result = f"fn {node.name}({params_str}) -> {ret_type}:\n"
-        self.indent_level += 1
+        params_str = ", ".join(params) if params else ""
+        return_type = self.map_type(func.return_type) if func.return_type else "None"
+
+        # Add shader type decorators for Mojo GPU programming
+        if shader_type == "vertex":
+            code += f"@vertex_shader\n"
+        elif shader_type == "fragment":
+            code += f"@fragment_shader\n"
+        elif shader_type == "compute":
+            code += f"@compute_shader\n"
+
+        code += f"fn {func.name}({params_str}) -> {return_type}:\n"
 
         # Generate function body
-        for stmt in node.body:
-            result += self.indent() + self.generate_statement(stmt) + "\n"
-
-        self.indent_level -= 1
-        return result
-
-    def generate_statement(self, node):
-        if isinstance(node, ReturnNode):
-            return f"return {self.generate_expression(node.value)}"
-        elif isinstance(node, AssignmentNode):
-            return self.generate_assignment(node)
-        elif isinstance(node, VariableNode):
-            return f"var {node.name}: {self.convert_type(node.vtype)}"
-        elif isinstance(node, IfNode):
-            return self.generate_if(node)
-        elif isinstance(node, ForNode):
-            return self.generate_for(node)
+        if func.body:
+            for stmt in func.body:
+                code += self.generate_statement(stmt, indent + 1)
+        else:
+            code += "    pass\n"
+
+        code += "\n"
+        return code
+
+    def generate_statement(self, stmt, indent=0):
+        indent_str = "    " * indent
+
+        if isinstance(stmt, VariableNode):
+            # Handle variable declarations
+            if hasattr(stmt, "vtype") and stmt.vtype:
+                # Check if this is actually an array declaration disguised as a variable
+                vtype_str = str(stmt.vtype)
+                if (
+                    "ArrayAccessNode" in vtype_str
+                    and "array=" in vtype_str
+                    and "index=" in vtype_str
+                ):
+                    # This is likely an array declaration
+                    import re
+
+                    array_match = re.search(r"array=(\w+).*?index=(\w+)", vtype_str)
+                    if array_match:
+                        array_match.group(1)
+                        size = array_match.group(2)
+                        base_type = "Float32"  # Default, could be improved
+                        return f"{indent_str}var {stmt.name}: StaticTuple[{base_type}, {size}]\n"
+
+                # Regular variable declaration
+                return f"{indent_str}var {stmt.name}: {self.map_type(stmt.vtype)}\n"
+            else:
+                return f"{indent_str}var {stmt.name}\n"
+        elif isinstance(stmt, ArrayNode):
+            return self.generate_array_declaration(stmt, indent)
+        elif isinstance(stmt, AssignmentNode):
+            return f"{indent_str}{self.generate_assignment(stmt)}\n"
+        elif isinstance(stmt, IfNode):
+            return self.generate_if(stmt, indent)
+        elif isinstance(stmt, ForNode):
+            return self.generate_for(stmt, indent)
+        elif isinstance(stmt, ReturnNode):
+            if isinstance(stmt.value, list):
+                # Multiple return values
+                values = ", ".join(self.generate_expression(val) for val in stmt.value)
+                return f"{indent_str}return {values}\n"
+            else:
+                return f"{indent_str}return {self.generate_expression(stmt.value)}\n"
+        elif isinstance(stmt, ArrayAccessNode):
+            # ArrayAccessNode should not appear as a statement by itself - it's likely a misclassified array declaration
+            # Try to handle it gracefully
+            return f"{indent_str}# Unhandled ArrayAccessNode: {stmt}\n"
         else:
-            return self.generate_expression(node)
+            # Handle expressions that may be used as statements
+            expr_result = self.generate_expression(stmt)
+            if expr_result.strip():
+                return f"{indent_str}{expr_result}\n"
+            else:
+                return f"{indent_str}# Unhandled statement: {type(stmt).__name__}\n"
+
+    def generate_array_declaration(self, node, indent=0):
+        indent_str = "    " * indent
+        element_type = self.map_type(node.element_type)
+        size = get_array_size_from_node(node)
+
+        if size is None:
+            return f"{indent_str}var {node.name}: DynamicVector[{element_type}]\n"
+        else:
+            return f"{indent_str}var {node.name}: StaticTuple[{element_type}, {size}]\n"
 
     def generate_assignment(self, node):
         left = self.generate_expression(node.left)
         right = self.generate_expression(node.right)
-        return f"{left} {node.operator} {right}"
-
-    def generate_expression(self, node):
-        if isinstance(node, VariableNode):
-            return node.name
-        elif isinstance(node, MemberAccessNode):
-            obj = self.generate_expression(node.object)
-            return f"{obj}.{node.member}"
-        elif isinstance(node, BinaryOpNode):
-            left = self.generate_expression(node.left)
-            right = self.generate_expression(node.right)
-            return f"{left} {node.op} {right}"
-        elif isinstance(node, FunctionCallNode):
-            args = ", ".join([self.generate_expression(arg) for arg in node.args])
-            return f"{node.name}({args})"
-        elif isinstance(node, UnaryOpNode):
-            operand = self.generate_expression(node.operand)
-            return f"{node.op}{operand}"
-        elif isinstance(node, str):
-            return node
-        else:
-            return str(node)
+        op = self.map_operator(node.operator)
+        return f"{left} {op} {right}"
 
-    def generate_if(self, node):
+    def generate_if(self, node, indent):
+        indent_str = "    " * indent
         condition = self.generate_expression(node.if_condition)
-        result = f"if {condition}:\n"
+        code = f"{indent_str}if {condition}:\n"
 
-        self.indent_level += 1
+        # Generate if body
         for stmt in node.if_body:
-            result += self.indent() + self.generate_statement(stmt) + "\n"
-        self.indent_level -= 1
+            code += self.generate_statement(stmt, indent + 1)
 
+        # Generate else if conditions
+        if hasattr(node, "else_if_conditions") and node.else_if_conditions:
+            for else_if_condition, else_if_body in zip(
+                node.else_if_conditions, node.else_if_bodies
+            ):
+                condition = self.generate_expression(else_if_condition)
+                code += f"{indent_str}elif {condition}:\n"
+                for stmt in else_if_body:
+                    code += self.generate_statement(stmt, indent + 1)
+
+        # Generate else body
         if node.else_body:
-            result += self.indent() + "else:\n"
-            self.indent_level += 1
+            code += f"{indent_str}else:\n"
             for stmt in node.else_body:
-                result += self.indent() + self.generate_statement(stmt) + "\n"
-            self.indent_level -= 1
+                code += self.generate_statement(stmt, indent + 1)
+
+        return code
 
-        return result.rstrip()
+    def generate_for(self, node, indent):
+        indent_str = "    " * indent
 
-    def generate_for(self, node):
-        init = self.generate_statement(node.init)
+        # Extract init, condition, and update
+        init = self.generate_statement(node.init, 0).strip()
         condition = self.generate_expression(node.condition)
-        update = self.generate_statement(node.update)
+        update = self.generate_expression(node.update)
 
-        result = f"for {init}; {condition}; {update}:\n"
+        # In Mojo, we'll use a while loop for C-style for loops
+        code = f"{indent_str}{init}\n"
+        code += f"{indent_str}while {condition}:\n"
 
-        self.indent_level += 1
+        # Generate loop body
         for stmt in node.body:
-            result += self.indent() + self.generate_statement(stmt) + "\n"
-        self.indent_level -= 1
+            code += self.generate_statement(stmt, indent + 1)
 
-        return result.rstrip()
+        # Add update at the end of the loop
+        code += f"{indent_str}    {update}\n"
 
-    def convert_type(self, type_name):
-        # Map CrossGL types to Mojo types
-        type_map = {
-            "vec2": "Vec2",
-            "vec3": "Vec3",
-            "vec4": "Vec4",
-            "float": "Float32",
-            "int": "Int32",
-            "bool": "Bool",
-            "void": "None",
+        return code
+
+    def generate_expression(self, expr):
+        if isinstance(expr, str):
+            return expr
+        elif isinstance(expr, (int, float, bool)):
+            return str(expr)
+        elif isinstance(expr, VariableNode):
+            if hasattr(expr, "vtype") and expr.vtype and expr.name:
+                return f"{expr.name}"
+            elif hasattr(expr, "name"):
+                return expr.name
+            else:
+                return str(expr)
+        elif isinstance(expr, BinaryOpNode):
+            left = self.generate_expression(expr.left)
+            right = self.generate_expression(expr.right)
+            op = self.map_operator(expr.op)
+            return f"({left} {op} {right})"
+        elif isinstance(expr, AssignmentNode):
+            return self.generate_assignment(expr)
+        elif isinstance(expr, UnaryOpNode):
+            operand = self.generate_expression(expr.operand)
+            op = self.map_operator(expr.op)
+            return f"({op}{operand})"
+        elif isinstance(expr, ArrayAccessNode):
+            # Handle array access properly
+            if hasattr(expr, "array") and hasattr(expr, "index"):
+                array = self.generate_expression(expr.array)
+                index = self.generate_expression(expr.index)
+                return f"{array}[{index}]"
+            else:
+                # Fallback for malformed ArrayAccessNode
+                return str(expr)
+        elif isinstance(expr, FunctionCallNode):
+            # Map function names to Mojo equivalents
+            func_name = self.function_map.get(expr.name, expr.name)
+
+            # Handle vector constructors
+            if expr.name in [
+                "vec2",
+                "vec3",
+                "vec4",
+                "ivec2",
+                "ivec3",
+                "ivec4",
+                "uvec2",
+                "uvec3",
+                "uvec4",
+            ]:
+                mojo_type = self.map_type(expr.name)
+                args = ", ".join(self.generate_expression(arg) for arg in expr.args)
+                return f"{mojo_type}({args})"
+
+            # Handle standard function calls
+            args = ", ".join(self.generate_expression(arg) for arg in expr.args)
+            return f"{func_name}({args})"
+        elif isinstance(expr, MemberAccessNode):
+            obj = self.generate_expression(expr.object)
+            return f"{obj}.{expr.member}"
+        elif isinstance(expr, TernaryOpNode):
+            condition = self.generate_expression(expr.condition)
+            true_expr = self.generate_expression(expr.true_expr)
+            false_expr = self.generate_expression(expr.false_expr)
+            return f"({true_expr} if {condition} else {false_expr})"
+        else:
+            # For unknown expression types, handle special cases
+            expr_str = str(expr)
+            # Check if this looks like an array declaration being misinterpreted
+            if (
+                "ArrayAccessNode" in expr_str
+                and "array=" in expr_str
+                and "index=" in expr_str
+            ):
+                # Try to extract array name and size for array declarations
+                import re
+
+                array_match = re.search(r"array=(\w+).*?index=(\w+)", expr_str)
+                if array_match:
+                    array_name = array_match.group(1)
+                    array_match.group(2)
+                    return f"{array_name}"  # Just return the array name for now
+            return expr_str
+
+    def map_type(self, vtype):
+        if vtype:
+            # Handle array types
+            if "[" in vtype and "]" in vtype:
+                base_type, size = parse_array_type(vtype)
+                base_mapped = self.type_mapping.get(base_type, base_type)
+                if size:
+                    return f"StaticTuple[{base_mapped}, {size}]"
+                else:
+                    return f"DynamicVector[{base_mapped}]"
+
+            # Use regular type mapping
+            return self.type_mapping.get(vtype, vtype)
+        return vtype
+
+    def map_operator(self, op):
+        op_map = {
+            "PLUS": "+",
+            "MINUS": "-",
+            "MULTIPLY": "*",
+            "DIVIDE": "/",
+            "BITWISE_XOR": "^",
+            "BITWISE_OR": "|",
+            "BITWISE_AND": "&",
+            "LESS_THAN": "<",
+            "GREATER_THAN": ">",
+            "ASSIGN_ADD": "+=",
+            "ASSIGN_SUB": "-=",
+            "ASSIGN_MUL": "*=",
+            "ASSIGN_DIV": "/=",
+            "ASSIGN_MOD": "%=",
+            "ASSIGN_XOR": "^=",
+            "ASSIGN_OR": "|=",
+            "ASSIGN_AND": "&=",
+            "LESS_EQUAL": "<=",
+            "GREATER_EQUAL": ">=",
+            "EQUAL": "==",
+            "NOT_EQUAL": "!=",
+            "AND": "and",
+            "OR": "or",
+            "EQUALS": "=",
+            "ASSIGN_SHIFT_LEFT": "<<=",
+            "ASSIGN_SHIFT_RIGHT": ">>=",
+            "LOGICAL_AND": "and",
+            "LOGICAL_OR": "or",
+            "BITWISE_SHIFT_RIGHT": ">>",
+            "BITWISE_SHIFT_LEFT": "<<",
+            "MOD": "%",
+            "NOT": "not",
         }
+        return op_map.get(op, op)
 
-        return type_map.get(type_name, type_name)
+    def map_semantic(self, semantic):
+        if semantic:
+            return self.semantic_map.get(semantic, semantic)
+        return ""
diff --git a/examples/output/ComplexShader.mojo b/examples/output/ComplexShader.mojo
new file mode 100644
index 0000000..b84033b
--- /dev/null
+++ b/examples/output/ComplexShader.mojo
@@ -0,0 +1,143 @@
+# Generated Mojo Shader Code
+from math import *
+from simd import *
+from gpu import *
+
+@value
+struct Material:
+    var albedo: SIMD[DType.float32, 3]
+    var roughness: Float32
+    var metallic: Float32
+    var emissive: SIMD[DType.float32, 3]
+    var opacity: Float32
+    var hasNormalMap: Bool
+    var albedoMap: Texture2D
+    var normalMap: Texture2D
+    var metallicRoughnessMap: Texture2D
+
+@value
+struct Light:
+    var position: SIMD[DType.float32, 3]
+    var color: SIMD[DType.float32, 3]
+    var intensity: Float32
+    var radius: Float32
+    var castShadows: Bool
+    var viewProjection: Matrix[DType.float32, 4, 4]
+
+@value
+struct Scene:
+    var materials: StaticTuple[Material, 4]
+    var lights: StaticTuple[Light, 8]
+    var ambientLight: SIMD[DType.float32, 3]
+    var time: Float32
+    var elapsedTime: Float32
+    var activeLightCount: Int32
+    var viewMatrix: Matrix[DType.float32, 4, 4]
+    var projectionMatrix: Matrix[DType.float32, 4, 4]
+
+@value
+struct VertexInput:
+    var position: SIMD[DType.float32, 3]
+    var normal: SIMD[DType.float32, 3]
+    var tangent: SIMD[DType.float32, 3]
+    var bitangent: SIMD[DType.float32, 3]
+    var texCoord0: SIMD[DType.float32, 2]
+    var texCoord1: SIMD[DType.float32, 2]
+    var color: SIMD[DType.float32, 4]
+    var materialIndex: Int32
+
+@value
+struct VertexOutput:
+    var worldPosition: SIMD[DType.float32, 3]
+    var worldNormal: SIMD[DType.float32, 3]
+    var worldTangent: SIMD[DType.float32, 3]
+    var worldBitangent: SIMD[DType.float32, 3]
+    var texCoord0: SIMD[DType.float32, 2]
+    var texCoord1: SIMD[DType.float32, 2]
+    var color: SIMD[DType.float32, 4]
+    var TBN: Matrix[DType.float32, 3, 3]
+    var materialIndex: Int32
+    var clipPosition: SIMD[DType.float32, 4]
+
+@value
+struct FragmentOutput:
+    var color: SIMD[DType.float32, 4]
+    var normalBuffer: SIMD[DType.float32, 4]
+    var positionBuffer: SIMD[DType.float32, 4]
+    var depth: Float32
+
+@value
+struct GlobalUniforms:
+    var scene: Scene
+    var cameraPosition: SIMD[DType.float32, 3]
+    var globalRoughness: Float32
+    var screenSize: SIMD[DType.float32, 2]
+    var nearPlane: Float32
+    var farPlane: Float32
+    var frameCount: Int32
+    var noiseValues: DynamicVector[Float32]
+
+var PI: Float32
+var EPSILON: Float32
+var MAX_ITERATIONS: Int32
+var a2: Float32
+var num: Float32
+var denom: Float32
+fn geometrySchlickGGX(NdotV: Float32, roughness: Float32) -> Float32:
+    (r = (roughness + 1.0))
+    (k = ((r * r) / 8.0))
+    (num = NdotV)
+    (denom = ((NdotV * (1.0 - k)) + k))
+    return (num / max(denom, EPSILON))
+
+fn geometrySmith(N: SIMD[DType.float32, 3], V: SIMD[DType.float32, 3], L: SIMD[DType.float32, 3], roughness: Float32) -> Float32:
+    (NdotV = max(dot_product(N, V), 0.0))
+    (ggx2 = geometrySchlickGGX(NdotV, roughness))
+    return (ggx1 * ggx2)
+
+fn fresnelSchlick(cosTheta: Float32, F0: SIMD[DType.float32, 3]) -> SIMD[DType.float32, 3]:
+    return (F0 + ((1.0 - F0) * power(max((1.0 - cosTheta), 0.0), 5.0)))
+
+fn noise3D(p: SIMD[DType.float32, 3]) -> Float32:
+    (i = floor(p))
+    (u = (((f * f) * f) * ((f * ((f * 6.0) - 15.0)) + 10.0)))
+    (n000 = fract((sin(dot_product(i, SIMD[DType.float32, 3](13.534, 43.5234, 243.32))) * 4453.0)))
+    (n010 = fract((sin(dot_product((i + SIMD[DType.float32, 3](0.0, 1.0, 0.0)), SIMD[DType.float32, 3](13.534, 43.5234, 243.32))) * 4453.0)))
+    (n100 = fract((sin(dot_product((i + SIMD[DType.float32, 3](1.0, 0.0, 0.0)), SIMD[DType.float32, 3](13.534, 43.5234, 243.32))) * 4453.0)))
+    (n110 = fract((sin(dot_product((i + SIMD[DType.float32, 3](1.0, 1.0, 0.0)), SIMD[DType.float32, 3](13.534, 43.5234, 243.32))) * 4453.0)))
+    (n00 = lerp(n000, n001, u.z))
+    (n10 = lerp(n100, n101, u.z))
+    (n0 = lerp(n00, n01, u.y))
+    return lerp(n0, n1, u.x)
+
+fn fbm(p: SIMD[DType.float32, 3], octaves: Int32, lacunarity: Float32, gain: Float32) -> Float32:
+    (sum = 0.0)
+    (amplitude = 1.0)
+    (frequency = 1.0)
+    (i = 0)
+    while (i < octaves):
+        if (i >= MAX_ITERATIONS):
+            var break
+        (sum += (amplitude * noise3D((p * frequency))))
+        (frequency *= lacunarity)
+        i++
+    return sum
+
+fn samplePlanarProjection(tex: Texture2D, worldPos: SIMD[DType.float32, 3], normal: SIMD[DType.float32, 3]) -> SIMD[DType.float32, 4]:
+    (absNormal = abs(normal))
+    (useY = ((!useX) && (absNormal.y >= absNormal.z)))
+    var uv: SIMD[DType.float32, 2]
+    if useX:
+        (uv = ((worldPos.zy * 0.5) + 0.5))
+        if (normal.x < 0.0):
+            (MemberAccessNode(object=uv, member=x) = (1.0 - uv.x))
+    elif useY:
+        (uv = ((worldPos.xz * 0.5) + 0.5))
+        if (normal.y < 0.0):
+            (MemberAccessNode(object=uv, member=y) = (1.0 - uv.y))
+    else:
+        (uv = ((worldPos.xy * 0.5) + 0.5))
+        if (normal.z < 0.0):
+            (MemberAccessNode(object=uv, member=x) = (1.0 - uv.x))
+    return sample(tex, uv)
+
diff --git a/examples/output/PerlinNoise.mojo b/examples/output/PerlinNoise.mojo
new file mode 100644
index 0000000..d7f5ca4
--- /dev/null
+++ b/examples/output/PerlinNoise.mojo
@@ -0,0 +1,38 @@
+# Generated Mojo Shader Code
+from math import *
+from simd import *
+from gpu import *
+
+@value
+struct VertexInput:
+    var position: SIMD[DType.float32, 3]
+
+@value
+struct VertexOutput:
+    var uv: SIMD[DType.float32, 2]
+    var position: SIMD[DType.float32, 4]
+
+@value
+struct FragmentInput:
+    var uv: SIMD[DType.float32, 2]
+
+@value
+struct FragmentOutput:
+    var color: SIMD[DType.float32, 4]
+
+# Vertex Shader
+@vertex_shader
+fn main(input: VertexInput) -> VertexOutput:
+    var output
+    (MemberAccessNode(object=output, member=uv) = (input.position.xy * 10.0))
+    (MemberAccessNode(object=output, member=position) = SIMD[DType.float32, 4](input.position, 1.0))
+    return output
+
+# Fragment Shader
+@fragment_shader
+fn main(input: FragmentInput) -> FragmentOutput:
+    var output
+    (noise = perlinNoise(input.uv))
+    (color = SIMD[DType.float32, 3]((height / 10.0), (1.0 - (height / 10.0)), 0.0))
+    return output
+
diff --git a/examples/output/SimpleShader.mojo b/examples/output/SimpleShader.mojo
new file mode 100644
index 0000000..50c9fc0
--- /dev/null
+++ b/examples/output/SimpleShader.mojo
@@ -0,0 +1,41 @@
+# Generated Mojo Shader Code
+from math import *
+from simd import *
+from gpu import *
+
+@value
+struct VertexInput:
+    var position: SIMD[DType.float32, 3]
+    var texCoord: SIMD[DType.float32, 2]
+
+@value
+struct VertexOutput:
+    var uv: SIMD[DType.float32, 2]
+    var position: SIMD[DType.float32, 4]
+
+@value
+struct FragmentInput:
+    var uv: SIMD[DType.float32, 2]
+
+@value
+struct FragmentOutput:
+    var color: SIMD[DType.float32, 4]
+
+# Vertex Shader
+@vertex_shader
+fn main(input: VertexInput) -> VertexOutput:
+    var output
+    (MemberAccessNode(object=output, member=uv) = input.texCoord)
+    (MemberAccessNode(object=output, member=position) = SIMD[DType.float32, 4](input.position, 1.0))
+    return output
+
+# Fragment Shader
+@fragment_shader
+fn main(input: FragmentInput) -> FragmentOutput:
+    var output
+    (r = input.uv.x)
+    (g = input.uv.y)
+    (b = 0.5)
+    (MemberAccessNode(object=output, member=color) = SIMD[DType.float32, 4](r, g, b, 1.0))
+    return output
+


Test patch:
diff --git a/.github/workflows/examples-test.yml b/.github/workflows/examples-test.yml
index 7ad3a51..a25fd75 100644
--- a/.github/workflows/examples-test.yml
+++ b/.github/workflows/examples-test.yml
@@ -44,24 +44,28 @@ jobs:
           python -c "import crosstl; crosstl.translate('ArrayTest.cgl', backend='opengl', save_shader='output/ArrayTest.glsl')"
           python -c "import crosstl; crosstl.translate('ArrayTest.cgl', backend='directx', save_shader='output/ArrayTest.hlsl')"
           python -c "import crosstl; crosstl.translate('ArrayTest.cgl', backend='vulkan', save_shader='output/ArrayTest.spirv')"
+          python -c "import crosstl; crosstl.translate('ArrayTest.cgl', backend='mojo', save_shader='output/ArrayTest.mojo')"
 
           # Simple Shader
           python -c "import crosstl; crosstl.translate('SimpleShader.cgl', backend='metal', save_shader='output/SimpleShader.metal')"
           python -c "import crosstl; crosstl.translate('SimpleShader.cgl', backend='opengl', save_shader='output/SimpleShader.glsl')"
           python -c "import crosstl; crosstl.translate('SimpleShader.cgl', backend='directx', save_shader='output/SimpleShader.hlsl')"
           python -c "import crosstl; crosstl.translate('SimpleShader.cgl', backend='vulkan', save_shader='output/SimpleShader.spirv')"
+          python -c "import crosstl; crosstl.translate('SimpleShader.cgl', backend='mojo', save_shader='output/SimpleShader.mojo')"
 
           # Perlin Noise
           python -c "import crosstl; crosstl.translate('PerlinNoise.cgl', backend='metal', save_shader='output/PerlinNoise.metal')"
           python -c "import crosstl; crosstl.translate('PerlinNoise.cgl', backend='opengl', save_shader='output/PerlinNoise.glsl')"
           python -c "import crosstl; crosstl.translate('PerlinNoise.cgl', backend='directx', save_shader='output/PerlinNoise.hlsl')"
           python -c "import crosstl; crosstl.translate('PerlinNoise.cgl', backend='vulkan', save_shader='output/PerlinNoise.spirv')"
+          python -c "import crosstl; crosstl.translate('PerlinNoise.cgl', backend='mojo', save_shader='output/PerlinNoise.mojo')"
 
           # Complex Shader
           python -c "import crosstl; crosstl.translate('ComplexShader.cgl', backend='metal', save_shader='output/ComplexShader.metal')"
           python -c "import crosstl; crosstl.translate('ComplexShader.cgl', backend='opengl', save_shader='output/ComplexShader.glsl')"
           python -c "import crosstl; crosstl.translate('ComplexShader.cgl', backend='directx', save_shader='output/ComplexShader.hlsl')"
           python -c "import crosstl; crosstl.translate('ComplexShader.cgl', backend='vulkan', save_shader='output/ComplexShader.spirv')"
+          python -c "import crosstl; crosstl.translate('ComplexShader.cgl', backend='mojo', save_shader='output/ComplexShader.mojo')"
         shell: bash
         continue-on-error: true
 
@@ -97,7 +101,13 @@ jobs:
           - { backend: "metal", example: "PerlinNoise", extension: ".metal" }
           - { backend: "metal", example: "ComplexShader", extension: ".metal" }
 
-          # Slang and Mojo backends are excluded as they're still experimental
+          # Mojo backend
+          - { backend: "mojo", example: "ArrayTest", extension: ".mojo" }
+          - { backend: "mojo", example: "SimpleShader", extension: ".mojo" }
+          - { backend: "mojo", example: "PerlinNoise", extension: ".mojo" }
+          - { backend: "mojo", example: "ComplexShader", extension: ".mojo" }
+
+          # Slang backend is excluded as it's still experimental
           # and not fully implemented
 
     steps:
diff --git a/examples/output/ArrayTest.mojo b/examples/output/ArrayTest.mojo
new file mode 100644
index 0000000..c025b1a
--- /dev/null
+++ b/examples/output/ArrayTest.mojo
@@ -0,0 +1,49 @@
+# Generated Mojo Shader Code
+from math import *
+from simd import *
+from gpu import *
+
+@value
+struct VertexInput:
+    var position: SIMD[DType.float32, 3]
+    var texCoord: SIMD[DType.float32, 2]
+
+@value
+struct VertexOutput:
+    var uv: SIMD[DType.float32, 2]
+    var position: SIMD[DType.float32, 4]
+
+@value
+struct FragmentInput:
+    var uv: SIMD[DType.float32, 2]
+
+@value
+struct FragmentOutput:
+    var color: SIMD[DType.float32, 4]
+
+# Constant Buffers
+@value
+struct TestBuffer:
+    var values: StaticTuple[Float32, 4]
+    var colors: StaticTuple[SIMD[DType.float32, 3], 2]
+
+# Vertex Shader
+@vertex_shader
+fn main(input: VertexInput) -> VertexOutput:
+    var output
+    (MemberAccessNode(object=output, member=uv) = input.texCoord)
+    (scale = (values[0] + values[1]))
+    (position = (input.position * scale))
+    (MemberAccessNode(object=output, member=position) = SIMD[DType.float32, 4](position, 1.0))
+    return output
+
+# Fragment Shader
+@fragment_shader
+fn main(input: FragmentInput) -> FragmentOutput:
+    var output
+    (color = colors[0])
+    if (input.uv.x > 0.5):
+        (color = colors[1])
+    (MemberAccessNode(object=output, member=color) = SIMD[DType.float32, 4](color, 1.0))
+    return output
+
diff --git a/tests/test_backend/test_mojo/test_codegen.py b/tests/test_backend/test_mojo/test_codegen.py
index 7ca911b..2b42f91 100644
--- a/tests/test_backend/test_mojo/test_codegen.py
+++ b/tests/test_backend/test_mojo/test_codegen.py
@@ -1,5 +1,6 @@
-from crosstl.backend.Mojo import MojoLexer
-from crosstl.backend.Mojo import MojoParser
+from crosstl.backend.Mojo import MojoCrossGLCodeGen
+from crosstl.backend.Mojo.MojoLexer import MojoLexer
+from crosstl.backend.Mojo.MojoParser import MojoParser
 import pytest
 from typing import List
 
@@ -11,6 +12,8 @@ def generate_code(ast_node):
     Returns:
         str: The generated code from the abstract syntax tree
     """
+    codegen = MojoCrossGLCodeGen.MojoToCrossGLConverter()
+    return codegen.generate(ast_node)
 
 
 def tokenize_code(code: str) -> List:
@@ -25,9 +28,468 @@ def parse_code(tokens: List):
     return parser.parse()
 
 
-# ToDO: Implement the tests
-def test_struct():
-    pass
+def test_struct_codegen():
+    code = """
+    struct VSInput:
+        var position: float4
+        var color: float2
+
+    struct VSOutput:
+        var out_position: float2
+
+    fn vertex_main(input: VSInput) -> VSOutput:
+        var output: VSOutput
+        output.out_position = input.position.xy
+        return output
+
+    struct PSInput:
+        var in_position: float2
+
+    struct PSOutput:
+        var out_color: float4
+
+    fn fragment_main(input: PSInput) -> PSOutput:
+        var output: PSOutput
+        output.out_color = float4(input.in_position, 0.0, 1.0)
+        return output
+    """
+    try:
+        tokens = tokenize_code(code)
+        ast = parse_code(tokens)
+        generated_code = generate_code(ast)
+        print(generated_code)
+        assert "struct VSInput" in generated_code
+        assert "struct VSOutput" in generated_code
+    except SyntaxError:
+        pytest.fail("Struct parsing or code generation not implemented.")
+
+
+def test_if_codegen():
+    code = """
+    struct VSInput:
+        var position: float4
+        var color: float4
+
+    struct VSOutput:
+        var out_position: float4
+
+    fn vertex_main(input: VSInput) -> VSOutput:
+        var output: VSOutput
+        output.out_position = input.position
+        if input.color.x > 0.5:
+            output.out_position = input.color
+        return output
+
+    struct PSInput:
+        var in_position: float4
+
+    struct PSOutput:
+        var out_color: float4
+
+    fn fragment_main(input: PSInput) -> PSOutput:
+        var output: PSOutput
+        output.out_color = input.in_position
+        if input.in_position.x > 0.5:
+            output.out_color = float4(1.0, 1.0, 1.0, 1.0)
+        return output
+    """
+    try:
+        tokens = tokenize_code(code)
+        ast = parse_code(tokens)
+        generated_code = generate_code(ast)
+        print(generated_code)
+        assert "if " in generated_code
+    except SyntaxError:
+        pytest.fail("If statement parsing or code generation not implemented.")
+
+
+def test_for_codegen():
+    code = """
+    struct VSInput:
+        var position: float4
+        var color: float4
+
+    struct VSOutput:
+        var out_position: float4
+
+    fn vertex_main(input: VSInput) -> VSOutput:
+        var output: VSOutput
+        output.out_position = input.position
+        for var i: Int = 0; i < 10; i = i + 1:
+            output.out_position = input.color
+        return output
+
+    struct PSInput:
+        var in_position: float4
+
+    struct PSOutput:
+        var out_color: float4
+
+    fn fragment_main(input: PSInput) -> PSOutput:
+        var output: PSOutput
+        output.out_color = input.in_position
+        for var i: Int = 0; i < 10; i = i + 1:
+            output.out_color = float4(1.0, 1.0, 1.0, 1.0)
+        return output
+    """
+    try:
+        tokens = tokenize_code(code)
+        ast = parse_code(tokens)
+        generated_code = generate_code(ast)
+        print(generated_code)
+        assert "for " in generated_code or "while " in generated_code
+    except SyntaxError:
+        pytest.fail("For loop parsing or code generation not implemented.")
+
+
+def test_while_codegen():
+    code = """
+    struct VSInput:
+        var position: float4
+        var color: float4
+
+    struct VSOutput:
+        var out_position: float4
+
+    fn vertex_main(input: VSInput) -> VSOutput:
+        var output: VSOutput
+        output.out_position = input.position
+        var i: Int = 0
+        while i < 10:
+            output.out_position = input.color
+            i = i + 1
+        return output
+
+    struct PSInput:
+        var in_position: float4
+
+    struct PSOutput:
+        var out_color: float4
+
+    fn fragment_main(input: PSInput) -> PSOutput:
+        var output: PSOutput
+        output.out_color = input.in_position
+        var i: Int = 0
+        while i < 10:
+            output.out_color = float4(1.0, 1.0, 1.0, 1.0)
+            i = i + 1
+        return output
+    """
+    try:
+        tokens = tokenize_code(code)
+        ast = parse_code(tokens)
+        generated_code = generate_code(ast)
+        print(generated_code)
+        assert "while " in generated_code
+    except SyntaxError:
+        pytest.fail("While loop parsing or code generation not implemented.")
+
+
+def test_else_codegen():
+    code = """
+    struct VSInput:
+        var position: float4
+        var color: float4
+
+    struct VSOutput:
+        var out_position: float4
+
+    fn vertex_main(input: VSInput) -> VSOutput:
+        var output: VSOutput
+        output.out_position = input.position
+        if input.color.x > 0.5:
+            output.out_position = input.color
+        else:
+            output.out_position = float4(0.0, 0.0, 0.0, 1.0)
+        return output
+
+    struct PSInput:
+        var in_position: float4
+
+    struct PSOutput:
+        var out_color: float4
+
+    fn fragment_main(input: PSInput) -> PSOutput:
+        var output: PSOutput
+        output.out_color = input.in_position
+        if input.in_position.x > 0.5:
+            output.out_color = float4(1.0, 1.0, 1.0, 1.0)
+        else:
+            output.out_color = float4(0.0, 0.0, 0.0, 1.0)
+        return output
+    """
+    try:
+        tokens = tokenize_code(code)
+        ast = parse_code(tokens)
+        generated_code = generate_code(ast)
+        print(generated_code)
+        assert "} else {" in generated_code or "else" in generated_code
+    except SyntaxError:
+        pytest.fail("Else statement parsing or code generation not implemented.")
+
+
+def test_function_call_codegen():
+    code = """
+    struct VSInput:
+        var position: float4
+        var color: float4
+
+    struct VSOutput:
+        var out_position: float4
+
+    fn add(a: float4, b: float4) -> float4:
+        return a + b
+
+    fn vertex_main(input: VSInput) -> VSOutput:
+        var output: VSOutput
+        output.out_position = input.position
+        let result = add(input.position, input.color)
+        return output
+
+    struct PSInput:
+        var in_position: float4
+
+    struct PSOutput:
+        var out_color: float4
+
+    fn fragment_main(input: PSInput) -> PSOutput:
+        var output: PSOutput
+        output.out_color = input.in_position
+        let result = add(input.in_position, float4(1.0, 1.0, 1.0, 1.0))
+        return output
+    """
+    try:
+        tokens = tokenize_code(code)
+        ast = parse_code(tokens)
+        generated_code = generate_code(ast)
+        print(generated_code)
+        assert "add(" in generated_code
+    except SyntaxError:
+        pytest.fail("Function call parsing or code generation not implemented.")
+
+
+def test_else_if_codegen():
+    code = """
+    struct VSInput:
+        var position: float4
+        var color: float4
+
+    struct VSOutput:
+        var out_position: float4
+
+    fn vertex_main(input: VSInput) -> VSOutput:
+        var output: VSOutput
+        output.out_position = input.position
+        if input.color.x > 0.5:
+            output.out_position = input.color
+        else:
+            output.out_position = float4(0.0, 0.0, 0.0, 1.0)
+        return output
+
+    struct PSInput:
+        var in_position: float4
+
+    struct PSOutput:
+        var out_color: float4
+
+    fn fragment_main(input: PSInput) -> PSOutput:
+        var output: PSOutput
+        if input.in_position.x > 0.5:
+            output.out_color = input.in_position
+        elif input.in_position.x == 0.5:
+            output.out_color = float4(1.0, 1.0, 1.0, 1.0)
+        else:
+            output.out_color = float4(0.0, 0.0, 0.0, 1.0)
+        return output
+    """
+    try:
+        tokens = tokenize_code(code)
+        ast = parse_code(tokens)
+        generated_code = generate_code(ast)
+        print(generated_code)
+        assert "} else if (" in generated_code or "else if" in generated_code
+    except SyntaxError:
+        pytest.fail("Else-if statement parsing or code generation not implemented.")
+
+
+def test_assignment_ops_codegen():
+    code = """
+    fn fragment_main(input: PSInput) -> PSOutput:
+        var output: PSOutput
+        output.out_color = float4(0.0, 0.0, 0.0, 1.0)
+
+        if input.in_position.x > 0.5:
+            output.out_color += input.in_position
+
+        if input.in_position.x < 0.5:
+            output.out_color -= float4(0.1, 0.1, 0.1, 0.1)
+
+        if input.in_position.y > 0.5:
+            output.out_color *= 2.0
+
+        if input.in_position.z > 0.5:
+            output.out_color /= 2.0
+
+        return output
+    """
+    try:
+        tokens = tokenize_code(code)
+        ast = parse_code(tokens)
+        generated_code = generate_code(ast)
+        print(generated_code)
+        assert "+=" in generated_code or "-=" in generated_code
+    except SyntaxError:
+        pytest.fail("Assignment ops parsing or code generation not implemented.")
+
+
+def test_bitwise_ops_codegen():
+    code = """
+    fn fragment_main(input: PSInput) -> PSOutput:
+        var output: PSOutput
+        output.out_color = float4(0.0, 0.0, 0.0, 1.0)
+        let val: UInt32 = 0x01
+        if val | 0x02:
+            # Test case for bitwise OR
+            pass
+        let filterA: UInt32 = 0b0001  # First filter
+        let filterB: UInt32 = 0b1000  # Second filter
+
+        # Merge both filters
+        let combinedFilter = filterA | filterB  # combinedFilter becomes 0b1001
+        return output
+    """
+    try:
+        tokens = tokenize_code(code)
+        ast = parse_code(tokens)
+        generated_code = generate_code(ast)
+        print(generated_code)
+        assert "|" in generated_code
+    except SyntaxError:
+        pytest.fail("Bitwise ops parsing or code generation not implemented.")
+
+
+def test_switch_case_codegen():
+    code = """
+    fn fragment_main(input: PSInput) -> PSOutput:
+        var output: PSOutput
+        switch input.in_position.x:
+            case 0.0:
+                output.out_color = float4(1.0, 0.0, 0.0, 1.0)
+                break
+            case 0.5:
+                output.out_color = float4(0.0, 1.0, 0.0, 1.0)
+                break
+            default:
+                output.out_color = float4(0.0, 0.0, 1.0, 1.0)
+                break
+        return output
+    """
+    try:
+        tokens = tokenize_code(code)
+        ast = parse_code(tokens)
+        generated_code = generate_code(ast)
+        print(generated_code)
+        assert "switch " in generated_code
+        assert "case " in generated_code
+    except SyntaxError:
+        pytest.fail("Switch case parsing or code generation not implemented.")
+
+
+def test_double_dtype_codegen():
+    code = """
+    struct VSInput:
+        var position: Float64
+        var color: Float64
+
+    fn vertex_main(input: VSInput) -> VSInput:
+        var output: VSInput
+        output.position = input.position * 2.0
+        output.color = input.color / 2.0
+        return output
+    """
+    try:
+        tokens = tokenize_code(code)
+        ast = parse_code(tokens)
+        generated_code = generate_code(ast)
+        print(generated_code)
+        assert "Float64" in generated_code or "double" in generated_code
+    except SyntaxError:
+        pytest.fail("Double data type parsing or code generation not implemented.")
+
+
+def test_vector_constructor_codegen():
+    code = """
+    fn vertex_main() -> float4:
+        let uv = float2(0.5, 0.5)
+        let color = float4(uv.x, uv.y, 0.0, 1.0)
+        return color
+    """
+    try:
+        tokens = tokenize_code(code)
+        ast = parse_code(tokens)
+        generated_code = generate_code(ast)
+        print(generated_code)
+        assert "float2(" in generated_code or "vec2(" in generated_code
+        assert "float4(" in generated_code or "vec4(" in generated_code
+    except SyntaxError:
+        pytest.fail("Vector constructor parsing or code generation not implemented.")
+
+
+def test_array_access_codegen():
+    code = """
+    fn vertex_main() -> float4:
+        var values: StaticTuple[Float32, 4]
+        values[0] = 1.0
+        values[1] = 2.0
+        values[2] = 3.0
+        values[3] = 4.0
+        return float4(values[0], values[1], values[2], values[3])
+    """
+    try:
+        tokens = tokenize_code(code)
+        ast = parse_code(tokens)
+        generated_code = generate_code(ast)
+        print(generated_code)
+        assert "[0]" in generated_code
+        assert "[1]" in generated_code
+    except SyntaxError:
+        pytest.fail("Array access parsing or code generation not implemented.")
+
+
+def test_ternary_operator_codegen():
+    code = """
+    fn vertex_main() -> float4:
+        let x: Float32 = 0.5
+        let result = x > 0.0 ? 1.0 : 0.0
+        return float4(result, 0.0, 0.0, 1.0)
+    """
+    try:
+        tokens = tokenize_code(code)
+        ast = parse_code(tokens)
+        generated_code = generate_code(ast)
+        print(generated_code)
+        assert "?" in generated_code or "if" in generated_code
+    except SyntaxError:
+        pytest.fail("Ternary operator parsing or code generation not implemented.")
+
+
+def test_import_codegen():
+    code = """
+    import math
+    import simd as s
+
+    fn vertex_main() -> float4:
+        let result = math.sin(0.5)
+        return float4(result, 0.0, 0.0, 1.0)
+    """
+    try:
+        tokens = tokenize_code(code)
+        ast = parse_code(tokens)
+        generated_code = generate_code(ast)
+        print(generated_code)
+        assert "import math" in generated_code or "// import math" in generated_code
+    except SyntaxError:
+        pytest.fail("Import parsing or code generation not implemented.")
 
 
 if __name__ == "__main__":
diff --git a/tests/test_backend/test_mojo/test_lexer.py b/tests/test_backend/test_mojo/test_lexer.py
index 3b98728..dc2143e 100644
--- a/tests/test_backend/test_mojo/test_lexer.py
+++ b/tests/test_backend/test_mojo/test_lexer.py
@@ -9,9 +9,298 @@ def tokenize_code(code: str) -> List:
     return lexer.tokenize()
 
 
+def test_struct_tokenization():
+    code = """
+    struct VSInput:
+        var position: float4
+        var color: float2
+
+    struct VSOutput:
+        var out_position: float2
+    """
+    try:
+        tokenize_code(code)
+    except SyntaxError:
+        pytest.fail("Struct tokenization not implemented.")
+
+
+def test_if_tokenization():
+    code = """
+    fn vertex_main(input: VSInput) -> VSOutput:
+        var output: VSOutput
+        output.out_position = input.position.xy
+        if input.color.x > 0.5:
+            output.out_position = input.color
+        return output
+    """
+    try:
+        tokenize_code(code)
+    except SyntaxError:
+        pytest.fail("If tokenization not implemented.")
+
+
+def test_for_tokenization():
+    code = """
+    fn main():
+        for var i: Int = 0; i < 10; i = i + 1:
+            print(i)
+    """
+    try:
+        tokenize_code(code)
+    except SyntaxError:
+        pytest.fail("For tokenization not implemented.")
+
+
+def test_while_tokenization():
+    code = """
+    fn main():
+        var i: Int = 0
+        while i < 10:
+            i = i + 1
+    """
+    try:
+        tokenize_code(code)
+    except SyntaxError:
+        pytest.fail("While tokenization not implemented.")
+
+
+def test_else_tokenization():
+    code = """
+    fn fragment_main(input: PSInput) -> PSOutput:
+        var output: PSOutput
+        if input.in_position.x > 0.5:
+            output.out_color = input.in_position
+        else:
+            output.out_color = float4(0.0, 0.0, 0.0, 1.0)
+        return output
+    """
+    try:
+        tokenize_code(code)
+    except SyntaxError:
+        pytest.fail("Else tokenization not implemented.")
+
+
+def test_function_call_tokenization():
+    code = """
+    fn fragment_main(input: PSInput) -> PSOutput:
+        var output: PSOutput
+        output.out_color = normalize(input.in_position)
+        return output
+    """
+    try:
+        tokenize_code(code)
+    except SyntaxError:
+        pytest.fail("Function call tokenization not implemented.")
+
+
+def test_else_if_tokenization():
+    code = """
+    fn fragment_main(input: PSInput) -> PSOutput:
+        var output: PSOutput
+        if input.in_position.x > 0.5:
+            output.out_color = input.in_position
+        elif input.in_position.x == 0.5:
+            output.out_color = float4(1.0, 1.0, 1.0, 1.0)
+        else:
+            output.out_color = float4(0.0, 0.0, 0.0, 1.0)
+        return output
+    """
+    try:
+        tokenize_code(code)
+    except SyntaxError:
+        pytest.fail("Else-if tokenization not implemented.")
+
+
+def test_assignment_ops_tokenization():
+    code = """
+    fn fragment_main():
+        var a: Int = 5
+        a += 3
+        a -= 2
+        a *= 4
+        a /= 2
+        a %= 3
+        a ^= 1
+        a |= 2
+        a &= 7
+        a <<= 1
+        a >>= 2
+    """
+    try:
+        tokenize_code(code)
+    except SyntaxError:
+        pytest.fail("Assignment operators tokenization not implemented.")
+
+
+def test_bitwise_ops_tokenization():
+    code = """
+    fn main():
+        let val: UInt32 = 0x01
+        let result = val | 0x02
+        let result2 = val & 0x04
+        let result3 = val ^ 0x08
+        let result4 = ~val
+        let result5 = val << 2
+        let result6 = val >> 1
+    """
+    try:
+        tokenize_code(code)
+    except SyntaxError:
+        pytest.fail("Bitwise operators tokenization not implemented.")
+
+
+def test_logical_ops_tokenization():
+    code = """
+    fn main():
+        let val_0: Bool = True
+        let val_1 = val_0 and False
+        let val_2 = val_0 or False
+        let val_3 = not val_0
+    """
+    try:
+        tokenize_code(code)
+    except SyntaxError:
+        pytest.fail("Logical operators tokenization not implemented.")
+
+
+def test_switch_case_tokenization():
+    code = """
+    fn fragment_main(input: PSInput) -> PSOutput:
+        var output: PSOutput
+        switch input.value:
+            case 1:
+                output.out_color = float4(1.0, 0.0, 0.0, 1.0)
+                break
+            case 2:
+                output.out_color = float4(0.0, 1.0, 0.0, 1.0)
+                break
+            default:
+                output.out_color = float4(0.0, 0.0, 1.0, 1.0)
+                break
+    """
+    try:
+        tokenize_code(code)
+    except SyntaxError:
+        pytest.fail("Switch-case tokenization not implemented.")
+
+
+def test_import_tokenization():
+    code = """
+    import math
+    import simd as s
+    from tensor import Tensor
+    """
+    try:
+        tokenize_code(code)
+    except SyntaxError:
+        pytest.fail("Import tokenization not implemented.")
+
+
+def test_data_types_tokenization():
+    code = """
+    fn main():
+        var a: Int8 = 10
+        var b: Int16 = 20
+        var c: Int32 = 30
+        var d: Int64 = 40
+        var e: UInt8 = 50
+        var f: UInt16 = 60
+        var g: UInt32 = 70
+        var h: UInt64 = 80
+        var i: Float16 = 1.5
+        var j: Float32 = 2.5
+        var k: Float64 = 3.5
+        var l: Bool = True
+    """
+    try:
+        tokenize_code(code)
+    except SyntaxError:
+        pytest.fail("Data types tokenization not implemented.")
+
+
+def test_vector_types_tokenization():
+    code = """
+    fn main():
+        var a: float2 = float2(1.0, 2.0)
+        var b: float3 = float3(1.0, 2.0, 3.0)
+        var c: float4 = float4(1.0, 2.0, 3.0, 4.0)
+        var d: int2 = int2(1, 2)
+        var e: int3 = int3(1, 2, 3)
+        var f: int4 = int4(1, 2, 3, 4)
+    """
+    try:
+        tokenize_code(code)
+    except SyntaxError:
+        pytest.fail("Vector types tokenization not implemented.")
+
+
+def test_attributes_tokenization():
+    code = """
+    @value
+    struct MyStruct:
+        var data: Int32
+    
+    @compute_shader
+    fn compute_main():
+        pass
+    """
+    try:
+        tokenize_code(code)
+    except SyntaxError:
+        pytest.fail("Attributes tokenization not implemented.")
+
+
+def test_ternary_operator_tokenization():
+    code = """
+    fn main():
+        let x: Float32 = 0.5
+        let result = x > 0.0 ? 1.0 : 0.0
+    """
+    try:
+        tokenize_code(code)
+    except SyntaxError:
+        pytest.fail("Ternary operator tokenization not implemented.")
+
+
+def test_array_access_tokenization():
+    code = """
+    fn main():
+        var values: StaticTuple[Float32, 4]
+        values[0] = 1.0
+        values[1] = 2.0
+        let result = values[0] + values[1]
+    """
+    try:
+        tokenize_code(code)
+    except SyntaxError:
+        pytest.fail("Array access tokenization not implemented.")
+
+
+def test_comments_tokenization():
+    code = """
+    # Single line comment
+    fn main():
+        var a: Int = 5  # End of line comment
+        \"\"\"
+        Multi-line comment
+        spanning multiple lines
+        \"\"\"
+        return a
+    """
+    try:
+        tokens = tokenize_code(code)
+        # Comments should be tokenized but filtered out
+        comment_found = any(
+            token[0] in ["COMMENT_SINGLE", "COMMENT_MULTI"] for token in tokens
+        )
+        # Since we skip comments in tokenization, we just ensure no error occurs
+    except SyntaxError:
+        pytest.fail("Comments tokenization not implemented.")
+
+
 def test_mod_tokenization():
     code = """
-        int a = 10 % 3;  // Basic modulus
+        let a: Int = 10 % 3  # Basic modulus
     """
     tokens = tokenize_code(code)
 
@@ -27,7 +316,7 @@ def test_mod_tokenization():
 
 def test_bitwise_not_tokenization():
     code = """
-        int a = ~5;  // Bitwise NOT
+        let a: Int = ~5  # Bitwise NOT
     """
     tokens = tokenize_code(code)
     has_not = False
@@ -38,5 +327,43 @@ def test_bitwise_not_tokenization():
     assert has_not, "Bitwise NOT operator (~) not tokenized correctly"
 
 
+def test_string_literals_tokenization():
+    code = """
+    fn main():
+        let message: String = "Hello, Mojo!"
+        let path: String = "path/to/file.txt"
+    """
+    try:
+        tokens = tokenize_code(code)
+        string_literals = [token[1] for token in tokens if token[0] == "STRING_LITERAL"]
+        assert (
+            '"Hello, Mojo!"' in string_literals
+        ), "String literal not tokenized correctly"
+        assert (
+            '"path/to/file.txt"' in string_literals
+        ), "String literal not tokenized correctly"
+    except SyntaxError:
+        pytest.fail("String literals tokenization not implemented.")
+
+
+def test_numeric_literals_tokenization():
+    code = """
+    fn main():
+        let decimal: Int = 42
+        let hex: Int = 0x2A
+        let binary: Int = 0b101010
+        let octal: Int = 0o52
+        let float_val: Float32 = 3.14159
+        let scientific: Float32 = 1.23e-4
+    """
+    try:
+        tokens = tokenize_code(code)
+        numbers = [token[1] for token in tokens if token[0] == "NUMBER"]
+        assert "42" in numbers, "Decimal literal not tokenized correctly"
+        assert "3.14159" in numbers, "Float literal not tokenized correctly"
+    except SyntaxError:
+        pytest.fail("Numeric literals tokenization not implemented.")
+
+
 if __name__ == "__main__":
     pytest.main()
diff --git a/tests/test_backend/test_mojo/test_parser.py b/tests/test_backend/test_mojo/test_parser.py
index 4759ac1..95dc7a0 100644
--- a/tests/test_backend/test_mojo/test_parser.py
+++ b/tests/test_backend/test_mojo/test_parser.py
@@ -1,7 +1,7 @@
 import pytest
 from typing import List
 from crosstl.backend.Mojo.MojoLexer import MojoLexer
-from crosstl.backend.Mojo import MojoParser
+from crosstl.backend.Mojo.MojoParser import MojoParser
 
 
 def parse_code(tokens: List):
@@ -22,6 +22,347 @@ def tokenize_code(code: str) -> List:
     return lexer.tokenize()
 
 
+def test_struct_parsing():
+    code = """
+    struct VSInput:
+        var position: float4
+        var color: float2
+
+    struct VSOutput:
+        var out_position: float2
+    """
+    try:
+        tokens = tokenize_code(code)
+        parse_code(tokens)
+    except SyntaxError:
+        pytest.fail("Struct parsing not implemented.")
+
+
+def test_if_parsing():
+    code = """
+    fn vertex_main(input: VSInput) -> VSOutput:
+        var output: VSOutput
+        output.out_position = input.position.xy
+        if input.color.x > 0.5:
+            output.out_position = input.color
+        return output
+    """
+    try:
+        tokens = tokenize_code(code)
+        parse_code(tokens)
+    except SyntaxError:
+        pytest.fail("If parsing not implemented.")
+
+
+def test_for_parsing():
+    code = """
+    fn main():
+        for var i: Int = 0; i < 10; i = i + 1:
+            print(i)
+    """
+    try:
+        tokens = tokenize_code(code)
+        parse_code(tokens)
+    except SyntaxError:
+        pytest.fail("For parsing not implemented.")
+
+
+def test_while_parsing():
+    code = """
+    fn main():
+        var i: Int = 0
+        while i < 10:
+            i = i + 1
+    """
+    try:
+        tokens = tokenize_code(code)
+        parse_code(tokens)
+    except SyntaxError:
+        pytest.fail("While parsing not implemented.")
+
+
+def test_else_parsing():
+    code = """
+    fn fragment_main(input: PSInput) -> PSOutput:
+        var output: PSOutput
+        if input.in_position.x > 0.5:
+            output.out_color = input.in_position
+        else:
+            output.out_color = float4(0.0, 0.0, 0.0, 1.0)
+        return output
+    """
+    try:
+        tokens = tokenize_code(code)
+        parse_code(tokens)
+    except SyntaxError:
+        pytest.fail("Else parsing not implemented.")
+
+
+def test_function_call_parsing():
+    code = """
+    fn fragment_main(input: PSInput) -> PSOutput:
+        var output: PSOutput
+        output.out_color = normalize(input.in_position)
+        return output
+    """
+    try:
+        tokens = tokenize_code(code)
+        parse_code(tokens)
+    except SyntaxError:
+        pytest.fail("Function call parsing not implemented.")
+
+
+def test_else_if_parsing():
+    code = """
+    fn fragment_main(input: PSInput) -> PSOutput:
+        var output: PSOutput
+        if input.in_position.x > 0.5:
+            output.out_color = input.in_position
+        elif input.in_position.x == 0.5:
+            output.out_color = float4(1.0, 1.0, 1.0, 1.0)
+        else:
+            output.out_color = float4(0.0, 0.0, 0.0, 1.0)
+        return output
+    """
+    try:
+        tokens = tokenize_code(code)
+        parse_code(tokens)
+    except SyntaxError:
+        pytest.fail("Else-if parsing not implemented.")
+
+
+def test_assignment_ops_parsing():
+    code = """
+    fn fragment_main():
+        var a: Int = 5
+        a += 3
+        a -= 2
+        a *= 4
+        a /= 2
+        a %= 3
+        a ^= 1
+        a |= 2
+        a &= 7
+        a <<= 1
+        a >>= 2
+    """
+    try:
+        tokens = tokenize_code(code)
+        parse_code(tokens)
+    except SyntaxError:
+        pytest.fail("Assignment operators parsing not implemented.")
+
+
+def test_bitwise_ops_parsing():
+    code = """
+    fn main():
+        let val: UInt32 = 0x01
+        let result = val | 0x02
+        let result2 = val & 0x04
+        let result3 = val ^ 0x08
+        let result4 = ~val
+        let result5 = val << 2
+        let result6 = val >> 1
+    """
+    try:
+        tokens = tokenize_code(code)
+        parse_code(tokens)
+    except SyntaxError:
+        pytest.fail("Bitwise operators parsing not implemented.")
+
+
+def test_logical_ops_parsing():
+    code = """
+    fn main():
+        let val_0: Bool = True
+        let val_1 = val_0 and False
+        let val_2 = val_0 or False
+        let val_3 = not val_0
+    """
+    try:
+        tokens = tokenize_code(code)
+        parse_code(tokens)
+    except SyntaxError:
+        pytest.fail("Logical operators parsing not implemented.")
+
+
+def test_switch_case_parsing():
+    code = """
+    fn fragment_main(input: PSInput) -> PSOutput:
+        var output: PSOutput
+        switch input.value:
+            case 1:
+                output.out_color = float4(1.0, 0.0, 0.0, 1.0)
+                break
+            case 2:
+                output.out_color = float4(0.0, 1.0, 0.0, 1.0)
+                break
+            default:
+                output.out_color = float4(0.0, 0.0, 1.0, 1.0)
+                break
+        return output
+    """
+    try:
+        tokens = tokenize_code(code)
+        parse_code(tokens)
+    except SyntaxError:
+        pytest.fail("Switch-case parsing not implemented.")
+
+
+def test_import_parsing():
+    code = """
+    import math
+    import simd as s
+    
+    fn main():
+        let result = math.sin(0.5)
+    """
+    try:
+        tokens = tokenize_code(code)
+        parse_code(tokens)
+    except SyntaxError:
+        pytest.fail("Import parsing not implemented.")
+
+
+def test_data_types_parsing():
+    code = """
+    fn main():
+        var a: Int8 = 10
+        var b: Int16 = 20
+        var c: Int32 = 30
+        var d: Int64 = 40
+        var e: UInt8 = 50
+        var f: UInt16 = 60
+        var g: UInt32 = 70
+        var h: UInt64 = 80
+        var i: Float16 = 1.5
+        var j: Float32 = 2.5
+        var k: Float64 = 3.5
+        var l: Bool = True
+    """
+    try:
+        tokens = tokenize_code(code)
+        parse_code(tokens)
+    except SyntaxError:
+        pytest.fail("Data types parsing not implemented.")
+
+
+def test_vector_types_parsing():
+    code = """
+    fn main():
+        var a: float2 = float2(1.0, 2.0)
+        var b: float3 = float3(1.0, 2.0, 3.0)
+        var c: float4 = float4(1.0, 2.0, 3.0, 4.0)
+        var d: int2 = int2(1, 2)
+        var e: int3 = int3(1, 2, 3)
+        var f: int4 = int4(1, 2, 3, 4)
+    """
+    try:
+        tokens = tokenize_code(code)
+        parse_code(tokens)
+    except SyntaxError:
+        pytest.fail("Vector types parsing not implemented.")
+
+
+def test_ternary_operator_parsing():
+    code = """
+    fn main():
+        let x: Float32 = 0.5
+        let result = x > 0.0 ? 1.0 : 0.0
+    """
+    try:
+        tokens = tokenize_code(code)
+        parse_code(tokens)
+    except SyntaxError:
+        pytest.fail("Ternary operator parsing not implemented.")
+
+
+def test_array_access_parsing():
+    code = """
+    fn main():
+        var values: StaticTuple[Float32, 4]
+        values[0] = 1.0
+        values[1] = 2.0
+        let result = values[0] + values[1]
+    """
+    try:
+        tokens = tokenize_code(code)
+        parse_code(tokens)
+    except SyntaxError:
+        pytest.fail("Array access parsing not implemented.")
+
+
+def test_member_access_parsing():
+    code = """
+    struct Vector3:
+        var x: Float32
+        var y: Float32
+        var z: Float32
+    
+    fn main():
+        var v: Vector3
+        v.x = 1.0
+        v.y = 2.0
+        v.z = 3.0
+        let length = sqrt(v.x * v.x + v.y * v.y + v.z * v.z)
+    """
+    try:
+        tokens = tokenize_code(code)
+        parse_code(tokens)
+    except SyntaxError:
+        pytest.fail("Member access parsing not implemented.")
+
+
+def test_function_with_parameters_parsing():
+    code = """
+    fn add(a: Float32, b: Float32) -> Float32:
+        return a + b
+    
+    fn multiply(x: Float32, y: Float32, z: Float32) -> Float32:
+        return x * y * z
+    
+    fn main():
+        let result1 = add(1.0, 2.0)
+        let result2 = multiply(2.0, 3.0, 4.0)
+    """
+    try:
+        tokens = tokenize_code(code)
+        parse_code(tokens)
+    except SyntaxError:
+        pytest.fail("Function with parameters parsing not implemented.")
+
+
+def test_variable_declarations_parsing():
+    code = """
+    fn main():
+        let constant_value: Int = 42
+        var mutable_value: Int = 10
+        var inferred_type = 3.14
+        let computed_value = constant_value + mutable_value
+    """
+    try:
+        tokens = tokenize_code(code)
+        parse_code(tokens)
+    except SyntaxError:
+        pytest.fail("Variable declarations parsing not implemented.")
+
+
+def test_nested_expressions_parsing():
+    code = """
+    fn main():
+        let a: Float32 = 1.0
+        let b: Float32 = 2.0
+        let c: Float32 = 3.0
+        let result = ((a + b) * c) / (a - b + c)
+        let complex_expr = sin(cos(tan(a))) + sqrt(b * b + c * c)
+    """
+    try:
+        tokens = tokenize_code(code)
+        parse_code(tokens)
+    except SyntaxError:
+        pytest.fail("Nested expressions parsing not implemented.")
+
+
 def test_mod_parsing():
     code = """
     fn main():
@@ -34,5 +375,49 @@ def test_mod_parsing():
         pytest.fail("Modulus operator parsing not implemented")
 
 
+def test_bitwise_not_parsing():
+    code = """
+    fn main():
+        let a: Int = 5
+        let b: Int = ~a  # Bitwise NOT
+    """
+    try:
+        tokens = tokenize_code(code)
+        parse_code(tokens)
+    except SyntaxError:
+        pytest.fail("Bitwise NOT operator parsing not implemented")
+
+
+def test_string_literals_parsing():
+    code = """
+    fn main():
+        let message: String = "Hello, Mojo!"
+        let path: String = "path/to/file.txt"
+        print(message)
+    """
+    try:
+        tokens = tokenize_code(code)
+        parse_code(tokens)
+    except SyntaxError:
+        pytest.fail("String literals parsing not implemented.")
+
+
+def test_numeric_literals_parsing():
+    code = """
+    fn main():
+        let decimal: Int = 42
+        let hex: Int = 0x2A
+        let binary: Int = 0b101010
+        let octal: Int = 0o52
+        let float_val: Float32 = 3.14159
+        let scientific: Float32 = 1.23e-4
+    """
+    try:
+        tokens = tokenize_code(code)
+        parse_code(tokens)
+    except SyntaxError:
+        pytest.fail("Numeric literals parsing not implemented.")
+
+
 if __name__ == "__main__":
     pytest.main()
diff --git a/tests/test_translator/test_codegen/test_mojo_codegen.py b/tests/test_translator/test_codegen/test_mojo_codegen.py
index 0993d03..d448f95 100644
--- a/tests/test_translator/test_codegen/test_mojo_codegen.py
+++ b/tests/test_translator/test_codegen/test_mojo_codegen.py
@@ -1,8 +1,9 @@
-from crosstl.translator.lexer import Lexer
 import pytest
-from typing import List
+import crosstl.translator
 from crosstl.translator.parser import Parser
+from crosstl.translator.lexer import Lexer
 from crosstl.translator.codegen.mojo_codegen import MojoCodeGen
+from typing import List
 
 
 def tokenize_code(code: str) -> List:
@@ -39,6 +40,7 @@ def test_struct():
     struct VSInput {
         vec2 texCoord @ TEXCOORD0;
     };
+
     struct VSOutput {
         vec4 color @ COLOR;
     };
@@ -46,8 +48,12 @@ def test_struct():
     try:
         tokens = tokenize_code(code)
         ast = parse_code(tokens)
-        code = generate_code(ast)
-        assert code is not None
+        generated_code = generate_code(ast)
+        assert "struct VSInput:" in generated_code
+        assert "struct VSOutput:" in generated_code
+        assert "var texCoord: SIMD[DType.float32, 2]" in generated_code
+        assert "var color: SIMD[DType.float32, 4]" in generated_code
+        print(generated_code)
     except SyntaxError:
         pytest.fail("Mojo struct codegen not implemented.")
 
@@ -78,11 +84,509 @@ def test_basic_shader():
     try:
         tokens = tokenize_code(code)
         ast = parse_code(tokens)
-        code = generate_code(ast)
-        assert code is not None
+        generated_code = generate_code(ast)
+        assert generated_code is not None
+        assert "fn main(" in generated_code
+        assert "@vertex_shader" in generated_code
+        assert "@fragment_shader" in generated_code
+        print(generated_code)
     except SyntaxError:
         pytest.fail("Mojo basic shader codegen not implemented.")
 
 
+def test_if_statement():
+    code = """
+    shader main {
+        struct VSInput {
+            vec2 texCoord @ TEXCOORD0;
+        };
+        struct VSOutput {
+            vec4 color @ COLOR;
+        };
+        sampler2D iChannel0;
+        vertex {
+            VSOutput main(VSInput input) {
+                VSOutput output;
+                if (input.texCoord.x > 0.5) {
+                    output.color = vec4(1.0, 1.0, 1.0, 1.0);
+                } else {
+                    output.color = vec4(0.0, 0.0, 0.0, 1.0);
+                }
+                output.color = vec4(input.texCoord, 0.0, 1.0);
+                return output;
+            }
+        }
+        fragment {
+            vec4 main(VSOutput input) @ gl_FragColor {
+                float brightness = texture(iChannel0, input.color.xy).r;
+                float bloom = max(0.0, brightness - 0.5);
+                if (bloom > 0.5) {
+                    bloom = 0.5;
+                } else {
+                    bloom = 0.0;
+                }
+                vec3 texColor = texture(iChannel0, input.color.xy).rgb;
+                vec3 colorWithBloom = texColor + vec3(bloom);
+                return vec4(colorWithBloom, 1.0);
+            }
+        }
+    }
+    """
+    try:
+        tokens = tokenize_code(code)
+        ast = parse_code(tokens)
+        generated_code = generate_code(ast)
+        assert "if " in generated_code
+        assert "else:" in generated_code
+        print(generated_code)
+    except SyntaxError:
+        pytest.fail("If statement codegen not implemented.")
+
+
+def test_for_statement():
+    code = """
+    shader main {
+        struct VSInput {
+            vec2 texCoord @ TEXCOORD0;
+        };
+        struct VSOutput {
+            vec4 color @ COLOR;
+        };
+        sampler2D iChannel0;
+        vertex {
+            VSOutput main(VSInput input) {
+                VSOutput output;
+                for (int i = 0; i < 10; i++) {
+                    output.color = vec4(1.0, 1.0, 1.0, 1.0);
+                }
+                output.color = vec4(input.texCoord, 0.0, 1.0);
+                return output;
+            }
+        }
+    }
+    """
+    try:
+        tokens = tokenize_code(code)
+        ast = parse_code(tokens)
+        generated_code = generate_code(ast)
+        assert "while " in generated_code  # Mojo uses while for C-style for loops
+        print(generated_code)
+    except SyntaxError:
+        pytest.fail("For statement codegen not implemented.")
+
+
+def test_else_if_statement():
+    code = """
+    shader main {
+        struct VSInput {
+            vec2 texCoord @ TEXCOORD0;
+        };
+        struct VSOutput {
+            vec4 color @ COLOR;
+        };
+        sampler2D iChannel0;
+        vertex {
+            VSOutput main(VSInput input) {
+                VSOutput output;
+                if (input.texCoord.x > 0.5) {
+                    output.color = vec4(1.0, 1.0, 1.0, 1.0);
+                } else if (input.texCoord.x < 0.5) {
+                    output.color = vec4(0.0, 0.0, 0.0, 1.0);
+                } else {
+                    output.color = vec4(0.5, 0.5, 0.5, 1.0);
+                }
+                output.color = vec4(input.texCoord, 0.0, 1.0);
+                return output;
+            }
+        }
+        fragment {
+            vec4 main(VSOutput input) @ gl_FragColor {
+                float brightness = texture(iChannel0, input.color.xy).r;
+                float bloom = max(0.0, brightness - 0.5);
+                if (bloom > 0.5) {
+                    bloom = 0.5;
+                } else if (bloom < 0.5) {
+                    bloom = 0.0;
+                } else {
+                    bloom = 0.5;
+                }
+                vec3 texColor = texture(iChannel0, input.color.xy).rgb;
+                vec3 colorWithBloom = texColor + vec3(bloom);
+                return vec4(colorWithBloom, 1.0);
+            }
+        }
+    }
+    """
+    try:
+        tokens = tokenize_code(code)
+        ast = parse_code(tokens)
+        generated_code = generate_code(ast)
+        assert "elif " in generated_code
+        print(generated_code)
+    except SyntaxError:
+        pytest.fail("Else if codegen not implemented.")
+
+
+@pytest.mark.parametrize(
+    "shader, expected_output",
+    [
+        (
+            """
+            shader TestShader {
+                void main() {
+                    float result = add(1.0, 2.0);
+                }
+                
+                float add(float a, float b) {
+                    return a + b;
+                }
+            }
+            """,
+            "add(1.0, 2.0)",
+        )
+    ],
+)
+def test_function_call(shader, expected_output):
+    ast = crosstl.translator.parse(shader)
+    code_gen = MojoCodeGen()
+    generated_code = code_gen.generate(ast)
+    assert expected_output in generated_code
+
+
+@pytest.mark.parametrize(
+    "shader, expected_output",
+    [
+        (
+            """
+            shader TestShader {
+                void main() {
+                    int a = 1;
+                    a |= 2;
+                }
+            }
+            """,
+            "a |= 2",
+        )
+    ],
+)
+def test_assignment_or_operator(shader, expected_output):
+    ast = crosstl.translator.parse(shader)
+    code_gen = MojoCodeGen()
+    generated_code = code_gen.generate(ast)
+    assert expected_output in generated_code
+
+
+def test_assignment_modulus_operator():
+    code = """
+    shader main {
+        vertex {
+            void main() {
+                int a = 10;
+                a %= 3;
+            }
+        }
+    }
+    """
+    try:
+        tokens = tokenize_code(code)
+        ast = parse_code(tokens)
+        generated_code = generate_code(ast)
+        assert "a %= 3" in generated_code or "a = a % 3" in generated_code
+    except SyntaxError:
+        pytest.fail("Assignment modulus operator codegen not implemented.")
+
+
+def test_assignment_xor_operator():
+    code = """
+    shader main {
+        vertex {
+            void main() {
+                int a = 5;
+                a ^= 3;
+            }
+        }
+    }
+    """
+    try:
+        tokens = tokenize_code(code)
+        ast = parse_code(tokens)
+        generated_code = generate_code(ast)
+        assert "a ^= 3" in generated_code or "a = a ^ 3" in generated_code
+    except SyntaxError:
+        pytest.fail("Assignment XOR operator codegen not implemented.")
+
+
+@pytest.mark.parametrize(
+    "shader, expected_output",
+    [
+        (
+            """
+            shader TestShader {
+                void main() {
+                    int a = 1;
+                    a <<= 2;
+                    a >>= 1;
+                }
+            }
+            """,
+            ["a <<= 2", "a >>= 1"],
+        )
+    ],
+)
+def test_assignment_shift_operators(shader, expected_output):
+    ast = crosstl.translator.parse(shader)
+    code_gen = MojoCodeGen()
+    generated_code = code_gen.generate(ast)
+    for output in expected_output:
+        assert output in generated_code
+
+
+@pytest.mark.parametrize(
+    "shader, expected_outputs",
+    [
+        (
+            """
+            shader TestShader {
+                void main() {
+                    int a = 1;
+                    int b = 2;
+                    int c = a | b;
+                    int d = a & b;
+                    int e = a ^ b;
+                }
+            }
+            """,
+            ["a | b", "a & b", "a ^ b"],
+        )
+    ],
+)
+def test_bitwise_operators(shader, expected_outputs):
+    ast = crosstl.translator.parse(shader)
+    code_gen = MojoCodeGen()
+    generated_code = code_gen.generate(ast)
+    for expected in expected_outputs:
+        assert expected in generated_code
+
+
+def test_bitwise_and_operator():
+    code = """
+    shader main {
+        struct VSInput {
+            vec2 texCoord @ TEXCOORD0;
+        };
+        struct VSOutput {
+            vec4 color @ COLOR;
+        };
+        sampler2D iChannel0;
+        vertex {
+            VSOutput main(VSInput input) {
+                VSOutput output;
+                output.color = vec4(float(int(input.texCoord.x * 100.0) & 15), 
+                                    float(int(input.texCoord.y * 100.0) & 15), 
+                                    0.0, 1.0);
+                return output;
+            }
+        }
+        fragment {
+            vec4 main(VSOutput input) @ gl_FragColor {
+                return vec4(input.color.rgb, 1.0);
+            }
+        }
+    }
+    """
+    try:
+        tokens = tokenize_code(code)
+        ast = parse_code(tokens)
+        generated_code = generate_code(ast)
+        print(generated_code)
+    except SyntaxError:
+        pytest.fail("Bitwise AND codegen not implemented")
+
+
+def test_double_data_type():
+    code = """
+    shader DoubleShader {
+        struct VSInput {
+            double texCoord @ TEXCOORD0;
+        };
+        struct VSOutput {
+            double color @ COLOR;
+        };
+        vertex {
+            VSOutput main(VSInput input) {
+                VSOutput output;
+                output.color = input.texCoord * 2.0;
+                return output;
+            }
+        }
+        fragment {
+            vec4 main(VSOutput input) @ gl_FragColor {
+                return vec4(input.color, 0.0, 0.0, 1.0);
+            }
+        }
+    }
+    """
+    try:
+        tokens = tokenize_code(code)
+        ast = parse_code(tokens)
+        generated_code = generate_code(ast)
+        assert "Float64" in generated_code  # Mojo uses Float64 for double
+        print(generated_code)
+    except SyntaxError:
+        pytest.fail("Double data type not supported.")
+
+
+@pytest.mark.parametrize(
+    "shader, expected_outputs",
+    [
+        (
+            """
+            shader TestShader {
+                void main() {
+                    int a = 1;
+                    int b = 2;
+                    int c = a << b;
+                    int d = a >> b;
+                }
+            }
+            """,
+            ["a << b", "a >> b"],
+        )
+    ],
+)
+def test_shift_operators(shader, expected_outputs):
+    ast = crosstl.translator.parse(shader)
+    code_gen = MojoCodeGen()
+    generated_code = code_gen.generate(ast)
+    for expected in expected_outputs:
+        assert expected in generated_code
+
+
+def test_bitwise_or_operator():
+    code = """
+    shader main {
+        struct VSInput {
+            vec2 texCoord @ TEXCOORD0;
+        };
+        struct VSOutput {
+            vec4 color @ COLOR;
+        };
+        sampler2D iChannel0;
+        vertex {
+            VSOutput main(VSInput input) {
+                VSOutput output;
+                output.color = vec4(float(int(input.texCoord.x * 100.0) | 15), 
+                                    float(int(input.texCoord.y * 100.0) | 15), 
+                                    0.0, 1.0);
+                return output;
+            }
+        }
+        fragment {
+            vec4 main(VSOutput input) @ gl_FragColor {
+                return vec4(input.color.rgb, 1.0);
+            }
+        }
+    }
+    """
+    try:
+        tokens = tokenize_code(code)
+        ast = parse_code(tokens)
+        generated_code = generate_code(ast)
+        print(generated_code)
+    except SyntaxError:
+        pytest.fail("Bitwise OR codegen not implemented")
+
+
+def test_ternary_operator():
+    code = """
+    shader main {
+        vertex {
+            vec4 main() {
+                float x = 0.5;
+                float result = x > 0.0 ? 1.0 : 0.0;
+                return vec4(result, 0.0, 0.0, 1.0);
+            }
+        }
+    }
+    """
+    try:
+        tokens = tokenize_code(code)
+        ast = parse_code(tokens)
+        generated_code = generate_code(ast)
+        assert (
+            "if" in generated_code and "else" in generated_code
+        )  # Mojo ternary syntax
+        print(generated_code)
+    except SyntaxError:
+        pytest.fail("Ternary operator codegen not implemented")
+
+
+def test_vector_constructor():
+    code = """
+    shader main {
+        vertex {
+            vec4 main() {
+                vec2 uv = vec2(0.5, 0.5);
+                vec4 color = vec4(uv, 0.0, 1.0);
+                return color;
+            }
+        }
+    }
+    """
+    try:
+        tokens = tokenize_code(code)
+        ast = parse_code(tokens)
+        generated_code = generate_code(ast)
+        assert "SIMD[DType.float32, 2]" in generated_code
+        assert "SIMD[DType.float32, 4]" in generated_code
+        print(generated_code)
+    except SyntaxError:
+        pytest.fail("Vector constructor codegen not implemented")
+
+
+def test_array_access():
+    code = """
+    shader main {
+        vertex {
+            vec4 main() {
+                float values[4];
+                values[0] = 1.0;
+                values[1] = 2.0;
+                return vec4(values[0], values[1], 0.0, 1.0);
+            }
+        }
+    }
+    """
+    try:
+        tokens = tokenize_code(code)
+        ast = parse_code(tokens)
+        generated_code = generate_code(ast)
+        assert "values[0]" in generated_code and "values[1]" in generated_code
+    except SyntaxError:
+        pytest.fail("Array access code generation not implemented.")
+
+
+def test_mojo_imports():
+    code = """
+    shader main {
+        vertex {
+            vec4 main() {
+                return vec4(0.0, 0.0, 0.0, 1.0);
+            }
+        }
+    }
+    """
+    try:
+        tokens = tokenize_code(code)
+        ast = parse_code(tokens)
+        generated_code = generate_code(ast)
+        assert "from math import *" in generated_code
+        assert "from simd import *" in generated_code
+        assert "from gpu import *" in generated_code
+        print(generated_code)
+    except SyntaxError:
+        pytest.fail("Mojo imports not generated")
+
+
 if __name__ == "__main__":
     pytest.main()