{"id":29473430,"url":"https://github.com/axarva/pura-compiler","last_synced_at":"2025-07-14T15:38:51.571Z","repository":{"id":303756269,"uuid":"1016469130","full_name":"Axarva/pura-compiler","owner":"Axarva","description":"A compiler project for 情報メディア特別演習. Not quite sure what the language to be compiled does.","archived":false,"fork":false,"pushed_at":"2025-07-09T08:08:49.000Z","size":17,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-07-09T09:25:36.741Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Haskell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Axarva.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-07-09T04:15:20.000Z","updated_at":"2025-07-09T08:10:44.000Z","dependencies_parsed_at":"2025-07-09T09:25:44.173Z","dependency_job_id":"e5b26439-12e6-43dd-b3e7-97bcbe70327d","html_url":"https://github.com/Axarva/pura-compiler","commit_stats":null,"previous_names":["axarva/pura-compiler"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Axarva/pura-compiler","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Axarva%2Fpura-compiler","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Axarva%2Fpura-compiler/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Axarva%2Fpura-compiler/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Axarva%2Fpura-compiler/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Axarva","download_url":"https://codeload.github.com/Axarva/pura-compiler/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Axarva%2Fpura-compiler/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265313474,"owners_count":23745190,"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":[],"created_at":"2025-07-14T15:38:47.891Z","updated_at":"2025-07-14T15:38:51.560Z","avatar_url":"https://github.com/Axarva.png","language":"Haskell","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n# Pura Compiler — Current Status and Roadmap\n\n## 1. What the compiler does now\n\n- **Lexer**:  \n  Converts raw source code text into a stream of tokens like `TokLet`, `TokIdentifier`, `TokStringLiteral`, `TokStrConcat`, etc.\n\n- **Parser**:  \n  Transforms token stream into an Abstract Syntax Tree (AST).  \n  Currently supports:  \n  - Function definitions (`let greet = (name) =\u003e { ... } REQUIRES ...`)  \n  - Expressions: string literals, variables, function calls, string concatenations (`++`), do blocks, and blocks `{ ... }`  \n  - Optional effect annotations (`REQUIRES ConsoleWrite, FileIO`)\n\n- **AST**:  \n  Data types representing functions, expressions, and effects for further processing.\n\n---\n\n## 2. How the greet function is parsed\n\nSource:\n\n```pura\nlet greet = (name) =\u003e {\n  \"Hello, \" ++ name ++ \"!\"\n} REQUIRES ConsoleWrite\n```\n\n### Token stream (output of lexer):\n\n```\n[TokLet, TokIdentifier \"greet\", TokEquals, TokLParen, TokIdentifier \"name\", TokRParen, TokArrow, TokLBrace,\n TokStringLiteral \"Hello, \", TokStrConcat, TokIdentifier \"name\", TokStrConcat, TokStringLiteral \"!\", TokRBrace,\n TokRequires, TokIdentifier \"ConsoleWrite\", TokEOF]\n```\n\n### Parser workflow:\n\n- `parseFunction` expects the `let` keyword → parses the function name → parses parameters → parses arrow `=\u003e` → parses function body block → optionally parses the `REQUIRES` clause.  \n- `parseBlock` collects expressions inside `{ ... }`.  \n- `parseExpr` parses concatenation expressions, recursively building nested `Concat` AST nodes for `++`.  \n- `parseTerm` recognizes string literals, variables, function calls, or do blocks.  \n- `parseEffectName` maps identifiers like `\"ConsoleWrite\"` to the `Effect` data type.\n\n### Final AST:\n\n```haskell\nFunction\n  { funcName = \"greet\"\n  , funcArgs = [\"name\"]\n  , funcBody = Block\n      [ Concat\n          (LitString \"Hello, \")\n          (Concat (Var \"name\") (LitString \"!\"))\n      ]\n  , funcEffects = [ConsoleWrite]\n  }\n```\n\n---\n\n## 3. Compiler Architecture Roadmap\n\n### Pipeline overview:\n\n```\nSource code\n  ↓ Lexer\nTokens\n  ↓ Parser\nAST\n  ↓ Type Checker (verify types, e.g., string concatenation validity)\n  ↓ Effect Checker (verify declared vs used side effects)\n  ↓ Code Generator (target JS, bytecode, or other)\n```\n\n### Module responsibilities:\n\n- **Lexer** (`Lexer.hs`): tokenizes source text.  \n- **Parser** (`Parser.hs`): builds AST from tokens.  \n- **AST** (`AST.hs`): defines data types for functions, expressions, and effects.  \n- **TypeChecker** (`TypeChecker.hs`): enforces type rules.  \n- **EffectChecker** (`EffectChecker.hs`): verifies side effect declarations.  \n- **CodeGen** (`CodeGen.hs`): outputs target code.\n\n---\n\n## 4. Next steps\n\n- Implement basic **type checking** for expressions and functions.  \n- Implement **effect checking**:  \n  - Detect unused or undeclared effects.  \n  - Warn or error accordingly.  \n- Expand language syntax (numbers, conditionals, recursion).  \n- Start prototype **code generation** for a simple target (e.g., JS or Haskell).  \n- Add test cases and improve error reporting.\n\n---\n\n## 5. TODO for July 9 2025\n\n- Design primitives (what exactly are included in primitives?)\n  -\u003e Consider primitive types\n  -\u003e Consider primitive operators\n- Implement primitives\n- Implement type check for primitives\n- Implement list -\u003e (Try by 7/16)\n- Implement function types like (a -\u003e  a)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faxarva%2Fpura-compiler","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faxarva%2Fpura-compiler","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faxarva%2Fpura-compiler/lists"}