How dmomotic/matriosh-ts-c3d works
Project Type and Purpose
• The project is a Quasar Framework application, which means it is a Vue.js–based front-end. However, it is not a typical UI-only app. Alongside the user interface (built with Vue single-file components like App.vue, layouts, pages, and various UI components), the project embeds a complex compiler-like engine. This engine is divided into several modules (analyzer, abstract syntax tree construction, translation, and optimization) and handles tasks such as parsing, semantic analysis, intermediate code generation and optimization.
• In short, the project is a hybrid system: a front-end application (using Quasar/Vue components) that integrates a language processing engine (with its own analyzer, translator, and optimizer modules).
Analyzing the File Structure
• Top-Level Files: Configuration files (e.g., package.json, quasar.conf.js, babel.config.js) indicate that the project is managed via standard JavaScript tooling, including build and deployment scripts.
• Front-end/Quasar Layers: The "public" and "src" directories contain Vue components (App.vue, layouts, pages, router) and CSS/SCSS styling—these form the presentation layer.
• Domain Logic Modules:
• The "src/analizador" folder includes grammar definitions (using .jison files) and corresponding JavaScript result files. This is responsible for parsing input (likely using Jison as a parser generator).
• The "src/arbol" directory handles Abstract Syntax Tree (AST) nodes and error reporting (files like nodoAST.js and error.js/ts).
• The "src/traduccion" folder is subdivided into modules for expressions, instructions (with further segregations for assignments, conditionals, cycles, etc.), and code generation utilities like those for generating three-address code (as seen in codigo3D.js/ts). This indicates that translation from a source language to an intermediate representation is a core component.
• The "src/optimizacion" folder contains modules for several optimization strategies (handling both two-address and three-address assignment optimizations, among others). Both JavaScript and TypeScript versions coexist, possibly for gradual migration or additional typing.
• UI Layer:
• Components: Vue components in "src/components", "src/layouts", and "src/pages".
• Router: Navigation configured in "src/router".
• Bootstrapping: Initial configuration in the "src/boot" directory.
• Function: This layer supplies the interface for users to interact with the language processing engine (e.g., displaying the AST, symbol tables, and optimization results).
• Parsing/Analysis Module (Analizador):
• Contains grammar definitions (gramatica.jison, optimizacion.jison) that serve as the entry point for parsing user input.
• Converts source code into a preliminary AST.
• AST and Error Handling Module (Arbol):
• Manages AST node creation (nodoAST.js) and error reporting.
• Interacts with subsequent phases to pass on parsed data.
• Translation Module (Traduccion):
• Responsible for building the intermediate representation (e.g., Three Address Code).
• Organizes various language constructs (expressions, instructions, control structures) and leverages a set of utilities (from "src/traduccion/utils") to manage symbol tables, environments, and code generation.
• Optimization Module (Optimizacion):
• Applies optimization rules to the intermediate code.
• Contains specific implementations (assignment optimizations, control flow optimizations) and works alongside the translation module to refine the generated code.