{"id":23756926,"url":"https://github.com/omkaarr1/nuvolang_custom_programming_language","last_synced_at":"2025-07-14T13:12:16.503Z","repository":{"id":267634533,"uuid":"901876793","full_name":"Omkaarr1/NuvoLang_Custom_Programming_Language","owner":"Omkaarr1","description":"This project implements a custom programming language interpreter in Java, complete with a lexer, parser, and interpreter.","archived":false,"fork":false,"pushed_at":"2025-01-30T13:11:30.000Z","size":66176,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-30T14:23:17.864Z","etag":null,"topics":["compiler-design","java","lexer-parser","programming-language"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"cc0-1.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Omkaarr1.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-12-11T13:35:17.000Z","updated_at":"2025-01-30T13:11:34.000Z","dependencies_parsed_at":null,"dependency_job_id":"f4ae513c-8819-41c0-af0d-0af3426e7bc7","html_url":"https://github.com/Omkaarr1/NuvoLang_Custom_Programming_Language","commit_stats":null,"previous_names":["omkaarr1/cpl"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Omkaarr1%2FNuvoLang_Custom_Programming_Language","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Omkaarr1%2FNuvoLang_Custom_Programming_Language/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Omkaarr1%2FNuvoLang_Custom_Programming_Language/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Omkaarr1%2FNuvoLang_Custom_Programming_Language/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Omkaarr1","download_url":"https://codeload.github.com/Omkaarr1/NuvoLang_Custom_Programming_Language/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239927823,"owners_count":19719835,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["compiler-design","java","lexer-parser","programming-language"],"created_at":"2024-12-31T19:28:50.773Z","updated_at":"2025-02-20T22:43:34.145Z","avatar_url":"https://github.com/Omkaarr1.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Custom Programming Language Interpreter in Java\r\n\r\nThis project implements a **custom programming language interpreter** in Java, complete with a **lexer**, **parser**, and **interpreter**. It reads program files, tokenizes and parses them, and executes the code line-by-line. The language supports a wide range of features, including variable assignments, arithmetic operations, conditional statements (`if-else`), functions, arrays, encrypted variables, machine learning integrations, blockchain functionalities, data science operations, **database interactions**, and temporal event triggers.\r\n\r\n---\r\n\r\n## Features\r\n\r\n### Key Features:\r\n1. **Basic Arithmetic and Variable Assignment**  \r\n   \\- Supports integer and floating-point arithmetic.  \r\n   \\- Assignment using `=` and compound assignment operators (`+=`, `-=`, `*=`, `/=`).  \r\n   \\- Increment and decrement operators (`++`, `--`) in both prefix and postfix forms.\r\n\r\n2. **Data Types**  \r\n   \\- Integers and floating-point numbers.  \r\n   \\- Strings delimited by double quotes `\" \"`.  \r\n   \\- Booleans (`true`, `false`).  \r\n   \\- Arrays created using bracket syntax `[element1, element2, ...]`.\r\n\r\n3. **Variables**  \r\n   \\- Dynamically assigned and typed variables.  \r\n   \\- **Encrypted Variables**: Variables prefixed with `@ENC`. Their values are stored encrypted, internally decrypted when needed for operations, then re-encrypted.  \r\n\r\n4. **Operators and Comparisons**  \r\n   \\- Standard arithmetic operators: `+`, `-`, `*`, `/`, `%`.  \r\n   \\- Comparison operators: `==`, `!=`, `\u003e`, `\u003c`, `\u003e=`, `\u003c=`.  \r\n   \\- Logical operators: `\u0026\u0026`, `||`, `!`.\r\n\r\n5. **Control Flow**  \r\n   \\- `if`/`else` statements for conditional execution.  \r\n   \\- `while` loops for iteration based on a boolean condition.  \r\n   \\- `for` loops supporting initialization, condition, and increment expressions.\r\n\r\n6. **Functions**  \r\n   \\- User-defined functions declared with the `function` keyword.  \r\n   \\- Parameterized functions with return values using `return`.  \r\n   \\- Recursive functions are supported.  \r\n   \\- Functions stored in a symbol table, callable by name.\r\n\r\n7. **Input/Output**  \r\n   \\- `print-\u003e\"message\";` for printing to standard output.  \r\n   \\- `input-\u003e\"prompt\"-\u003e variable;` for reading user input into a variable.  \r\n   \\- Supports string concatenation and printing of variables/expressions.\r\n\r\n8. **Arrays**  \r\n   \\- Creation of arrays, e.g. `arr = [1, 2, 3];`  \r\n   \\- Concatenation with `+=`.  \r\n   \\- Arrays can contain mixed types (numbers, strings, booleans).\r\n\r\n9. **Encryption Support**  \r\n   \\- **Encrypted Variables**: Variables starting with `@ENC` store their values in encrypted form.  \r\n   \\- Internally handles encryption/decryption during operations.  \r\n   \\- Example usage: `@ENCsecret = \"mySecretValue\";`.\r\n\r\n10. **Temporal Programming (Event Triggers)**  \r\n    \\- **Unique Feature**: Scheduling of code execution at specific times or intervals.  \r\n    \\- Syntax Examples:\r\n      - `@EVENT_TRIGGER(duration,\"seconds\") -\u003e \u003cstatement\u003e;`  \r\n        (e.g., `@EVENT_TRIGGER(5,\"seconds\") -\u003e print-\u003e\"Hello\";`)  \r\n      - `@EVENT_TRIGGER(\"YYYY-MM-DD HH:MM:SS\") -\u003e \u003cstatement\u003e;`  \r\n        Executes at the specified date/time.  \r\n    \\- **Use Cases**: Event-driven, time-based script execution.\r\n\r\n11. **Machine Learning Integration**  \r\n    \\- **ML Library**: Integrates with Weka for ML tasks.  \r\n    \\- **Methods**: `randomforest(csvPath, targetColumn)`, `linearregression(csvPath, targetColumn)`, `kmeans(csvPath)`.  \r\n    \\- **Features**: Loads CSV, trains/evaluates models, prints metrics (accuracy, precision, recall, F1-score).\r\n\r\n12. **Blockchain Functionality**  \r\n    \\- **Blockchain Library**: Simulates basic blockchain operations.  \r\n    \\- **Methods**: `init(privateKey, initialAmount)`, `transaction(toAddress, amount)`, `showCurrentBalance()`, `showTransactionHistory()`.  \r\n    \\- **Features**:  \r\n      \\- Initialize a blockchain wallet with a private key.  \r\n      \\- Perform/send transactions.  \r\n      \\- Show current balance and transaction history.\r\n\r\n13. **Data Science Operations**  \r\n    \\- **DataScience Library**: Provides data manipulation/statistical analysis.  \r\n    \\- **Methods**:  \r\n      \\- `loadCSV(csvPath)`  \r\n      \\- `calculateMean(data, attributeName)`  \r\n      \\- `calculateMedian(data, attributeName)`  \r\n      \\- `calculateStdDev(data, attributeName)`  \r\n      \\- `plotHistogram(data, attributeName, outputPath)`  \r\n      \\- `plotScatter(data, attributeX, attributeY, outputPath)`  \r\n      \\- `filterData(data, attribute, operator, value)`  \r\n    \\- **Features**:  \r\n      \\- Load/preprocess CSV datasets.  \r\n      \\- Statistical calculations.  \r\n      \\- Generate histogram/scatterplot visualizations.  \r\n      \\- Filter datasets.\r\n\r\n14. **Database Operations**  \r\n    \\- **Database Library**: Allows interaction with SQL databases.  \r\n    \\- **Methods**: `connect(connectionString, username, password)`, `query(sqlStatement)`, `close()`.  \r\n    \\- **Features**:  \r\n      \\- Connect to MySQL/PostgreSQL (via JDBC).  \r\n      \\- Execute queries (`CREATE`, `INSERT`, `UPDATE`, `DELETE`, `SELECT`).  \r\n      \\- Retrieve/manipulate results within the interpreter.  \r\n      \\- Manage connections and ensure resource handling.\r\n\r\n15. **AI Integration (SONAR AI)**  \r\n    \u003e **New Feature**  \r\n    - **Interactive AI Assistant**: SONAR AI can help generate or explain code in the custom language.  \r\n    - **Context-Aware Suggestions**: Provide code snippets, best practices, or quick fixes within the language.  \r\n    - **Syntax Correction**: SONAR AI can parse partial instructions (“I want a function that multiplies two variables…”) and produce valid code.  \r\n    - **Use Cases**:  \r\n      \\- Rapid code prototyping.  \r\n      \\- Language exploration and debugging.  \r\n      \\- Automated code generation from user queries.\r\n\r\n16. **Error Handling**  \r\n    \\- Lexer/Parser: Reports line and column for syntax errors.  \r\n    \\- Runtime: Detailed messages (e.g., undefined variable, division by zero).\r\n\r\n17. **Dynamic and Interpreted Nature**  \r\n    \\- **Interpreted Execution**: Code is lexed, parsed, and executed at runtime.  \r\n    \\- **Dynamic Typing**: No explicit type declarations; variables/fxns created at runtime.  \r\n    \\- **On-the-Fly Computations**: Modify variables or definitions as code executes.\r\n\r\n---\r\n\r\n## AI / SONAR AI Features\r\n\r\n### Overview\r\n**SONAR AI** is an **intelligent assistant** embedded into the language ecosystem. It can read your partial or complete instructions and generate:\r\n\r\n- **Code Snippets** in the custom language.\r\n- **Explanations** of language constructs (e.g., how to handle encrypted variables).\r\n- **Debugging Suggestions** based on partial code.\r\n- **Learning Resources** about best usage patterns, machine learning tasks, or database queries.\r\n\r\n### How It Works\r\n- **User Query**: The user types something like “Generate a function that calculates factorial using recursion.”  \r\n- **AI Processing**: SONAR AI, powered by an underlying large language model (e.g., GPT), interprets the request with knowledge of the custom language’s syntax and features.  \r\n- **Result**: SONAR AI returns a code snippet or explanation.\r\n\r\n### Example Usage\r\n```plaintext\r\nUser: \"Create an event trigger that prints 'Hello' every 2 seconds, \r\n       and also store the message in @ENCsecret.\"\r\n\r\nSONAR AI (Generated Code):\r\n@ENCsecret = \"Hello\";\r\n@EVENT_TRIGGER(2, \"seconds\") -\u003e print-\u003e@ENCsecret;\r\n```\r\n\r\n### Benefits\r\n1. **Faster Prototyping**: Eliminates manual coding for small, repetitive tasks.  \r\n2. **Code Explanation**: SONAR AI can break down complex code blocks in simpler terms.  \r\n3. **Learning Tool**: Helps new developers understand advanced features (ML, Blockchain, etc.).  \r\n\r\n---\r\n\r\n## Input File Syntax\r\n\r\n- **Statements** end with `;`.  \r\n- **Output**: `print-\u003e\"text\" + variable;`  \r\n- **Input**: `input-\u003e \"prompt\" -\u003e variable;`  \r\n- **Conditionals**: `if (condition) \u003cstatement\u003e else \u003cstatement\u003e;`  \r\n- **Function Definitions**: `function myFunction(a, b) { ... }`  \r\n- **Event Triggers**: `@EVENT_TRIGGER(duration,\"seconds\") -\u003e \u003cstatement\u003e;` or `@EVENT_TRIGGER(\"YYYY-MM-DD HH:MM:SS\") -\u003e \u003cstatement\u003e;`  \r\n- **Database**: `use database;` -\u003e then do `db.connect()`, `db.query()`, etc.\r\n\r\n(See **example.txt** below for a complete demonstration.)\r\n\r\n---\r\n\r\n## Example Input File (`example.txt`)\r\n\r\n```plaintext\r\nuse database;\r\nuse blockchain;\r\nuse data_science;\r\nuse ml;\r\n\r\n// ... [Same as before, demonstrating features: variable assignments, if-else, encryption, \r\n// event triggers, ML tasks, blockchain ops, data science ops, database ops, etc.] ...\r\n```\r\n\r\n*(Full example snippet omitted here for brevity, but it’s the same as described above.)*\r\n\r\n---\r\n\r\n## Project Structure\r\n\r\n1. **Main.java**  \r\n   - Entry point. Reads input code (e.g., `example.txt`), runs Lexer/Parser/Interpreter, and handles exceptions.\r\n\r\n2. **Lexer.java**  \r\n   - Tokenizes raw input. Groups characters into tokens (identifiers, keywords, numbers, etc.). Reports lexical errors with line/column info.\r\n\r\n3. **Token.java** and **TokenType.java**  \r\n   - Represents meaningful units of code.  \r\n   - `TokenType` is an enum of possible token types (keywords, operators, symbols).\r\n\r\n4. **Parser.java**  \r\n   - Builds an AST from tokens. Enforces grammar for expressions, statements, loops, functions, etc. Reports syntax errors with details.\r\n\r\n5. **Interpreter.java**  \r\n   - Executes the AST. Implements all language features: arithmetic, loops, encryption logic, event triggers, ML, blockchain, data science, and DB calls.  \r\n   - Integrates with **SONAR AI** for on-demand code generation or suggestions (optional, if your environment supports it).\r\n\r\n6. **Libraries** (ML, Blockchain, DataScience, Database)  \r\n   - **MlLibrary.java** for Weka-based ML.  \r\n   - **BlockchainLibrary.java** for simulating ledger, balances, transactions.  \r\n   - **DataScienceLibrary.java** for statistical calculations, visualizations, filtering.  \r\n   - **DatabaseLibrary.java** for SQL operations: connect/query/close.\r\n\r\n7. **example.txt**  \r\n   - Demo input that uses all key language features: variables, functions, encryption, event triggers, ML, blockchain, data science, database.\r\n\r\n8. **AI Integration**  \r\n   - If you have the SONAR AI module enabled, you can request code generation or clarifications from the language’s context.\r\n\r\n9. **Dependencies**  \r\n   - **Weka** for ML.  \r\n   - **JFreeChart** for charting.  \r\n   - **Apache Commons Math** for stats.  \r\n   - **Java Cryptography Extension (JCE)** for encryption.  \r\n   - **JDBC Driver** for SQL DB connectivity.  \r\n   - **(Optional)** Some AI bridging library if you want SONAR AI built into the interpreter environment.\r\n\r\n---\r\n\r\n## How to Run\r\n\r\n1. **Install JDK** (version 8+).  \r\n2. **Download Libraries** (Weka, JFreeChart, Commons Math, JDBC).  \r\n3. **Place** them in `lib/`.  \r\n4. **Compile**:\r\n   ```bash\r\n   javac -cp \"lib/*\" -d bin src/*.java\r\n   ```\r\n5. **Run**:\r\n   ```bash\r\n   java -cp \"lib/*;bin\" src.Main scripts/example.txt\r\n   ```\r\n   (*For Unix-based, replace `;` with `:` in the classpath*)\r\n\r\n6. **Check Output** in the console. Generated charts appear in `scripts/`. Database changes reflect in your configured SQL DB.\r\n\r\n---\r\n\r\n## Debugging Features\r\n\r\n- **Token Inspection**: Shows tokens from lexer.  \r\n- **AST Inspection**: Prints a tree for debugging.  \r\n- **Variable States**: Prints variables after each statement.  \r\n- **Errors**: Provides line/column if syntax or runtime error.\r\n\r\n---\r\n\r\n## AI / SONAR AI Usage\r\n\r\n- **Requires** an environment or server that can pass user prompts to the AI model (e.g., GPT-4).  \r\n- If integrated, you can do something like:  \r\n  1. `sonarAi.generateCode(\"I want a function that increments an encrypted variable.\");`  \r\n  2. The AI returns a snippet in the custom language.  \r\n  3. The interpreter can optionally run or store that code.\r\n\r\n*(Implementation details may vary based on your AI infrastructure.)*\r\n\r\n---\r\n\r\n## Customization\r\n\r\n1. **New Operators/Keywords**: Update `TokenType`, `Lexer`, `Parser`, and `Interpreter`.  \r\n2. **Additional Libraries**: Create `NewLibrary.java`, load it in `Interpreter` or in `libraries/`.  \r\n3. **Enhanced Encryption**: Extend encryption logic to new algorithms/keys.  \r\n4. **AI Extensions**: Let SONAR AI parse real-time logs, or auto-fix syntax errors, etc.\r\n\r\n---\r\n\r\n## Example Enhancements\r\n\r\n- **Machine Learning**:  \r\n  ```plaintext\r\n  use ml;\r\n  rfModel = ml.randomforest(\"scripts/data2.csv\", \"age\");\r\n  print-\u003e\"Random Forest Model: \" + rfModel;\r\n  ```\r\n- **Blockchain**:  \r\n  ```plaintext\r\n  use blockchain;\r\n  blockchain.init(\"myPrivateKey\", 1000);\r\n  blockchain.transaction(\"recipientAddress\", 250);\r\n  ```\r\n- **Data Science**:  \r\n  ```plaintext\r\n  use data_science;\r\n  dataset = data_science.loadCSV(\"scripts/data2.csv\");\r\n  meanAge = data_science.calculateMean(dataset, \"age\");\r\n  ...\r\n  ```\r\n- **Database**:  \r\n  ```plaintext\r\n  use database;\r\n  db.connect(\"jdbc:mysql://localhost:3306/supermarket\",\"root\",\"password\");\r\n  ...\r\n  ```\r\n\r\n- **SONAR AI** (New):\r\n  ```plaintext\r\n  // Hypothetical usage if integrated:\r\n  ai.generateCode(\"Write a function to add two numbers and print them.\");\r\n  ```\r\n\r\n---\r\n\r\n## Roadmap\r\n\r\n- [x] Loops, Functions, Booleans.  \r\n- [x] Arrays \u0026 Dynamic Typing.  \r\n- [x] Basic Error Handling.  \r\n- [x] ML Integration (Weka).  \r\n- [x] Blockchain Simulations.  \r\n- [x] Data Science Tools.  \r\n- [x] Encryption for Variables.  \r\n- [x] Temporal @EVENT_TRIGGER.  \r\n- [x] **Database Connectivity**.  \r\n- [x] **SONAR AI Integration** (optional advanced feature).\r\n\r\n### Future Enhancements\r\n- **Concurrency**: Possibly multi-threading or async triggers.  \r\n- **Advanced ML**: Additional models, deep learning.  \r\n- **UI**: A more user-friendly IDE or web-based interface.  \r\n- **Enhanced AI**: Automatic debugging, language expansions, or direct voice commands.  \r\n\r\n---\r\n\r\n## Contributing\r\n\r\n1. **Fork** and create a feature branch:\r\n   ```bash\r\n   git checkout -b feature/YourFeature\r\n   ```\r\n2. **Commit** changes:\r\n   ```bash\r\n   git commit -m \"Add Your Feature\"\r\n   ```\r\n3. **Push** to your fork:\r\n   ```bash\r\n   git push origin feature/YourFeature\r\n   ```\r\n4. **Open** a Pull Request on the main repo.\r\n\r\n---\r\n\r\n## License\r\n\r\nLicensed under the **CC0 1.0 License**. See `LICENSE` for details.\r\n\r\n---\r\n\r\n## Acknowledgments\r\n\r\n- **Compiler Design** references for lexical analysis, parsing, and interpretation.  \r\n- **Libraries**: Weka, JFreeChart, Apache Commons Math, JDBC drivers, Java Cryptography Extension.  \r\n- **Open-Source** community for tools and knowledge.  \r\n- **SONAR AI** and the GPT-based ecosystem for code generation/integration ideas.\r\n\r\n---\r\n\r\n**Happy Coding!**  \\[Enjoy building with **SONAR AI** + the custom language!\\]\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fomkaarr1%2Fnuvolang_custom_programming_language","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fomkaarr1%2Fnuvolang_custom_programming_language","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fomkaarr1%2Fnuvolang_custom_programming_language/lists"}