{"id":16982281,"url":"https://github.com/maxpatiiuk/alia","last_synced_at":"2026-04-25T22:34:07.119Z","repository":{"id":126933147,"uuid":"529473212","full_name":"maxpatiiuk/alia","owner":"maxpatiiuk","description":"The ultimate Alia compiler and interpreter","archived":false,"fork":false,"pushed_at":"2023-12-03T22:07:25.000Z","size":5702,"stargazers_count":2,"open_issues_count":2,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-02T05:55:09.615Z","etag":null,"topics":["3ac","compiler","compilers","graphviz","interpreter","language","lexer","llvm","mips","parser","programming-language","x64"],"latest_commit_sha":null,"homepage":"https://max.patii.uk/projects/alia","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/maxpatiiuk.png","metadata":{"files":{"readme":"README.md","changelog":null,"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}},"created_at":"2022-08-27T03:43:37.000Z","updated_at":"2023-03-27T23:38:43.000Z","dependencies_parsed_at":"2023-12-03T22:31:25.284Z","dependency_job_id":null,"html_url":"https://github.com/maxpatiiuk/alia","commit_stats":null,"previous_names":["maxpatiiuk/alia"],"tags_count":11,"template":false,"template_full_name":null,"purl":"pkg:github/maxpatiiuk/alia","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maxpatiiuk%2Falia","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maxpatiiuk%2Falia/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maxpatiiuk%2Falia/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maxpatiiuk%2Falia/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/maxpatiiuk","download_url":"https://codeload.github.com/maxpatiiuk/alia/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maxpatiiuk%2Falia/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32279657,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-25T18:29:39.964Z","status":"ssl_error","status_checked_at":"2026-04-25T18:29:32.149Z","response_time":59,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["3ac","compiler","compilers","graphviz","interpreter","language","lexer","llvm","mips","parser","programming-language","x64"],"created_at":"2024-10-14T02:07:49.928Z","updated_at":"2026-04-25T22:34:07.077Z","avatar_url":"https://github.com/maxpatiiuk.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Alia\n\nThe ultimate Alia compiler and interpreter.\n\nWritten in TypeScript.\n\nAlia follows c-like syntax. Example code:\n\n```javascript\nint x;\n\nint double(int x) {\n    return x * 2;\n}\n\nint main() {\n  output \"Hello World!\\n\";\n  \n  // Function Pointer\n  fn(int)-\u003eint f = double;\n  \n  output \"Input a number: \";\n  input x;\n  \n  if(x == 42) {\n    output \"The answer to the \\\"ultimate question of life, the universe, and everything,\\\"\\n\";\n  }\n  \n  return f(x);\n}\n```\n\nA larger example is provided in [`./infile.alia`](./infile.alia). It includes an\nimplementation of a tiny testing library, that is then used to test the very\nlanguage it is written in.\n\nAlia can be compiled down\nto [x64, MIPS, and LLVM assembly](#running-compiler). It can also be\nrun in an [interpreter](#running-interpreter).\n\n## Contents\n\n- [Alia](#alia)\n    * [Contents](#contents)\n    * [Prerequisites](#prerequisites)\n    * [Installation](#installation)\n    * [Running Compiler](#running-compiler)\n        + [Compiling to x64](#compiling-to-x64)\n        + [Compiling to MIPS](#compiling-to-mips)\n        + [Compiling to LLVM Assembly](#compiling-to-llvm-assembly)\n    * [Running Interpreter](#running-interpreter)\n    * [Testing](#testing)\n    * [Architecture](#architecture)\n        + [Lexical Analysis (Tokenizing)](#lexical-analysis-tokenizing)\n        + [Syntactic analysis (Parsing)](#syntactic-analysis-parsing)\n            - [Syntax directed translation](#syntax-directed-translation)\n                * [Parse tree generation](#parse-tree-generation)\n                    + [(optional) Prettify the code](#optional-prettify-the-code)\n                * [Abstract syntax tree (AST) generation](#abstract-syntax-tree-ast-generation)\n                    + [(optional) Prettify the code](#optional-prettify-the-code-1)\n        + [Semantic analysis](#semantic-analysis)\n            - [Name analysis](#name-analysis)\n            - [Type analysis](#type-analysis)\n        + [Intermediate code generation](#intermediate-code-generation)\n            - [Intermediate code optimization](#intermediate-code-optimization)\n        + [Final code generation](#final-code-generation)\n            - [Final code optimization](#final-code-optimization)\n        + [Execution](#execution)\n            - [Runtime environment](#runtime-environment)\n                * [MIPS](#mips)\n                * [x64 and LLVM](#x64-and-llvm)\n            - [Interpreter](#interpreter)\n    * [`alia` Documentation](#alia-documentation)\n    * [Development Documentation](#development-documentation)\n    * [Appendix 1: Extending the language](#appendix-1-extending-the-language)\n    * [Appendix 2: Generating a graph of the grammar](#appendix-2-generating-a-graph-of-the-grammar)\n    * [Appendix 3: Sources](#appendix-3-sources)\n        + [CYK Parser](#cyk-parser)\n        + [SLR Parser](#slr-parser)\n        + [MIPS](#mips-1)\n        + [x64](#x64)\n        + [LLVM](#llvm)\n    * [Appendix 4: Naming](#appendix-4-naming)\n\n## Prerequisites\n\n- Node 18\n- NPM 8\n\n## Installation\n\n1. [Follow `llvm-bindings` installation instructions](https://github.com/ApsarasX/llvm-bindings/tree/69c93f7aae697c3cb3e75d01e447554b0565e3d5#install)\n\n   Also, you may have\n   to [explicitly specify the location of LLVM](https://github.com/ApsarasX/llvm-bindings/tree/69c93f7aae697c3cb3e75d01e447554b0565e3d5#custom-llvm-installation)\n   ,\n   if it isn't found automatically.\n\n2. Install alia dependencies:\n\n   ```sh\n   npm install\n   ```\n\n## Running Compiler\n\nTo see available options, run the script with the `--help` argument:\n\n```sh\n./alia --help\n```\n\n### Compiling to x64\n\nExample call:\n\n```sh\n./alia infile.alia -o outfile.s\n```\n\nBy default, compilation runs intermediate code optimization and final code\noptimization (using peephole optimization and dead code elimination). You can\ndisable those by running the compiler with the `--dontOptimize` flag (useful\nwhen trying to debug the output)\n\nAfter compiling, you need to run a linker. This can be done\nusing the `make link` command, which accepts optional arguments:\n\n```sh\nmake link OUTFILE=outfile.s PROG=dev.prog\n```\n\nWhere:\n\n- `OUTFILE` is the name of the assembly file generated in the previous\n  step (`outfile.s` is the default value).\n- `PROG` is the name of the executable for the program (`dev.prog` is the\n  default value).\n\nExample of generated x64 assembly:\n\n![Example x64 output](./docs/img/amd-assembly.png)\n\n[Full example](./src/quads/__tests__/__snapshots__/toAmd.test.ts.snap)\n\n### Compiling to MIPS\n\nExample call:\n\n```\n./alia infile.alia -m mips.asm 2\u003e errors.txt\n```\n\nThen, open `mips.asm` in MARS and run it.\n\nMIPS assembly code was written to work with MARS 4.5\n\n\u003e NOTE: when compiling to MIPS, registers are stored as 32-bit values to\n\u003e simplify the multiplication and division operations\n\n\nExample of generated MIPS assembly:\n\n![Example MIPS output](./docs/img/mips-assembly.png)\n\n[Full example](./src/quads/__tests__/__snapshots__/toMips.test.ts.snap)\n\n### Compiling to LLVM Assembly\n\nWorkflow for an x64 machine:\n\n```sh\n# Compile to LLVM assembly\n./alia infile.alia -l llvm.ll\n\n# Optimize the LLVM assembly\n# NOTE, you will have to change the paths to the LLVM binaries\n/home/a807d786/llvm_dist/bin/opt -O3 -S llvm.ll -o llvm.opt.ll\n\n# Compile to target machine assembly\n/home/a807d786/llvm_dist/bin/llc llvm.opt.ll -o llvm.s\n\n# Create an executable and run it\nmake link OUTFILE=llvm.s\n\n```\n\nExample LLVM output:\n\n![Example LLVM output](./docs/img/llvm-assembly.png)\n\n[Full example](./src/quads/__tests__/__snapshots__/toLlvm.test.ts.snap)\n\n## Running Interpreter\n\nStart the interpreter:\n\n```sh\n./aliainterp\n```\n\nThe interpreter supports several meta-commands. Type `:help` to see those.\n\nSeveral restrictions are lifted when running Alia in an interpreter:\n\n- Semicolon for the last line is optional\n- Variable re-declarations are treated as shadowing the variable, rather than\n  emit an error\n- Statements can be included outside of the function\n- `output` statements always include a trailing newline\n\nExample Interpreter session:\n\n![Example Interpreter session](./docs/img/interpreter-session.png)\n\n## Testing\n\nJest is used for unit testing.\n\nYou can run it like this:\n\n```sh\nnpm test\n```\n\nFor example, automated tests for the interpreter are in\n[./src/interpreter/__\ntests__/runtime.test.ts](./src/interpreter/__tests__/runtime.test.ts)\n\nExample test run:\n\n![Example test run](./docs/img/test-results.png)\n\n## Architecture\n\nA deep dive into the architecture of the compiler follows.\n\n`alia` consists of 5 parts. When compiling a program, you go through each of\nthese\nstages in order:\n\n### Lexical Analysis (Tokenizing)\n\n\u003e Lexical analysis means grouping a stream of letters or sounds into sets of\n\u003e units that represent meaningful syntax\n\nThis process converts the source code into a stream of tokens. Example of\ntokens:\n\n- Reserved keywords (`if`, `else`, `while`, etc.)\n- Identifiers (`foo`, `bar`, etc.)\n- Operators (`+`, `-`, etc.)\n- Literals (`1`, `2`, `3`, etc.)\n- Comments (`// this is a comment`)\n\nSource code for tokenizer is in [`./src/tokenize`](./src/tokenize)\n\nEach file in that directory has a comment at the top describing the purpose\nof the file.\n\nYou can run the compiler in tokenizing-only mode like this:\n\n```sh\n./alia infile.alia --tokensOutput tokens.out\n```\n\nThis would output the token stream into `./tokens.out` text file.\n\nExample token stream:\n\n![Example token stream](./docs/img/tokens-stream.png)\n\n### Syntactic analysis (Parsing)\n\nThe syntactic analysis makes sure that the token stream created in the previous\nstep\nconforms to the grammar, and sets the stage up for Syntax Directed Translation.\n\nThe grammar for the language is defined using Context Free Grammar.\n\nSee [`./src/grammar`](./src/grammar) for the grammar definition.\n\nThree parsers have been implemented:\n\n- SLR Parser (default)\n\n  This parser is used by default. You can explicitly specify it like this:\n\n  ```sh\n  ./alia infile.alia --parser SLR -m mips.asm\n  ```\n\n  The source code for the SLR parser is in [`./src/slrParser`](./src/slrParser)\n\n  [More information about SLR parsers](http://www.egr.unlv.edu/~matt/teaching/SLR.pdf)\n\n  Additionally, there is an option to [generate a Graphviz graph based on the\n  SLR automata](#appendix-2-generating-a-graph-of-the-grammar).\n\n- CYK Parser\n\n  Benefits:\n    - Supports ambiguous grammar\n\n  Drawbacks:\n    - Runs as `n^3` complexity.\n    - Requires converting grammar to Chomsky Normal Form, thus was harder to\n      implement\n    - Hard to convert the result of the CYK parser into a parse tree\n\n  For these reasons, the CYK parser was implemented only out of curiosity rather\n  than for practical reasons. You can run the CYK parser to see whether\n  parsing resulted in any errors, but you cannot move on to the\n  \"Syntax directed translation\" if CYK parser was used.\n\n  You can run the CYK Parser like this:\n\n  ```sh\n  ./alia infile.alia --parser CYK\n  ```\n\n  The program will exit with exit code 0 on successful parsing.\n\n  Otherwise, it will print an error and exit with 1.\n\n  The source code for the CYK parser is in [`./src/cykParser`](./src/cykParser)\n\n  [More information about CYK parsers](https://en.wikipedia.org/wiki/CYK_algorithm)\n\n- LL(1) Parser\n\n  LL(1) parser was implemented in a separate project and is available at\n  [maxpatiiuk/leto](https://github.com/maxpatiiuk/leto).\n\n  Unlike this project, `maxpatiiuk/leto` is geared towards making it trivially\n  easy to customize the grammar and the syntax-directed translation.\n\n#### Syntax-directed translation\n\n##### Parse tree generation\n\nAs part of running an SLR parser, a parse tree is generated. The parse tree is\nan intermediate form between the token stream and the abstract syntax tree. It\nclosely resembles the token stream and can be though of as the same token\nstream, but with all nodes rearranged to have some children and parent nodes\nassigned.\n\n[More information about parse trees](https://en.wikipedia.org/wiki/Parse_tree)\n\n###### (optional) Prettify the code\n\nThere is an ability to format the input code based on just the AST.\n\nThe result is not always as great as formatting the AST, but it stays closer\nto the original code (preserves redundant parenthesis and other features that\ndon't change the semantics). It is also faster than formatting based on AST.\n\nSource code is in [`./src/unparseParseTree`](./src/unparseParseTree)\n\nExample call:\n\n```sh\n./alia infile.alia --unparseMode parseTree --unparse pretty-output.alia\n```\n\n##### Abstract syntax tree (AST) generation\n\nA tree representation of the code that constitutes a processed parse tree, with\nnon-essential information striped (like parenthesis and whitespace).\n\nThis is later used for name analysis, type analysis, and intermediate code\ngeneration. AST is also where the first optimization steps are taken.\n\n[More information about ASTs](https://en.wikipedia.org/wiki/Abstract_syntax_tree)\n\nThe source code for the AST generation is in [`./src/ast`](./src/ast)\n\nThe definitions of all AST nodes are\nin [`./src/ast/definition/`](./src/ast/definitions)\n\n###### (optional) Prettify the code\n\nAST can be used as an excellent source for pretty-printing the code.\n\nExample call:\n\n```sh\n./alia infile.alia --unparse pretty-output.alia\n```\n\n(you don't have to specify the `--unparseMode ast` argument, as it is the\ndefault unparse mode)\n\n### Semantic analysis\n\nName analysis annotates the AST with information about used identifiers, their\nscope, and their type. This is the last stage where compile-time errors can be\nthrown.\n\n#### Name analysis\n\n\u003e Name analysis is the process of assigning a scope to each identifier in the\n\u003e program. It also checks for duplicate declarations and undeclared identifiers.\n\nThe definitions of all AST nodes are\nin [`./src/ast/definition/`](./src/ast/definitions)\n\nEach AST node has a `nameAnalysis` method that is called during name analysis.\n\nIt collects information about used variables, and their scope and reports\nerrors.\n\nExample name analysis output:\n\n![Example name analysis output](./docs/img/name-analysis.png)\n\n#### Type analysis\n\n\u003e Type analysis is the process of assigning a type to each identifier in the\n\u003e program. It also checks for type mismatches and other type-related errors.\n\n[More information about type analysis](https://en.wikipedia.org/wiki/Type_system)\n\nThe definitions of all AST nodes are\nin [`./src/ast/definition/`](./src/ast/definitions)\n\nEach AST node has a `typeAnalysis` method that is called during type analysis.\n\nIt collects information about the type of each variable, and function and\nreports\nany incorrect type conversions.\n\nExample type analysis output:\n\n![Example type analysis output](./docs/img/type-analysis.png)\n\nYou can also output the prettified source code with name analysis and type\nanalysis annotations like this:\n\n```sh\n./alia infile.alia --namedUnparse named.alia\n```\n\nThis is useful for debugging.\n\nExample annotated output:\n![Example annotated output](./docs/img/annotated-unparse.png)\n\n### Intermediate code generation\n\nThe intermediate code is generated from the AST. The intermediate code is\na pseudo-assembly language (also called 3AC or Quads) that is used for\nintermediate code optimization and generation for MIPS, x64 and LLVM assembly\ncode.\n\n[More information about 3AC](https://en.wikipedia.org/wiki/Three-address_code)\n\nThe definitions of all AST nodes are\nin [`./src/ast/definition/`](./src/ast/definitions).\n\nEach node contains a `toQuads()` method that is used for converting AST\nnode to a list of Quads.\n\nAll Quads are defined in the [./src/quads](./src/quads) directory.\n\nFor debugging purposes, you can make the compiler output the intermediate code:\n\n```sh\n./alia infile.alia -a 3ac.txt\n```\n\nExample Quads output:\n\n![Example Quads output](./docs/img/quads-output.png)\n\n[Full example](./src/quads/__tests__/__snapshots__/toQuads.test.ts.snap)\n\n#### Intermediate code optimization\n\nDuring the generation of quads, the first steps of optimization are taken.\n\nMainly, this stage is concerned with dead code elimination (like removing\nuseless arithmetic operations). This code also replaces `+ 1` and `- 1`\noperations with post-increment and post-decrement, as those, can be more\nefficiently represented in x64 assembly.\n\nNote, a whole lot more optimization could be done at this stage (using frame\nanalysis, more dead code elimination, reducing stack usage, and reusing\nregisters\nmore), but those are outside of the scope of this project.\n\n\u003e You can disable all optimizations by passing a `--dontOptimize` argument.\n\u003e This is useful for debugging as that way generated intermediate code is\n\u003e a 1:1 representation of the AST.\n\n### Final code generation\n\nThe final code is assembly. The compiler can generate code for MIPS (32-bit),\nx64 (64-bit) and LLVM (64-bit).\n\nThe code of the compiler is trying to output universal assembly as much as\npossible. This helps ensure consistency between the assembly code\nfor different architectures, as well as allows for sharing optimizations between\narchitectures.\n\nAll Quads are defined in the [./src/quads](./src/quads) directory.\n\nEach Quad has a `toMips()` and `toMipsValue()` methods for converting to\nassembly and `toAmd()` and `toAmdValue()` for converting to x64 assembly.\nThese are described in more detail\nin [./src/quads/definitions/index.ts](./src/quads/definitions/index.ts).\n\nTo simplify optimization and reduce the possibility of typos, an\nintermediate level has been added. Rather than converting Quads directly into\nassembly strings, they are converted into instances of\nthe [`Instruction`](./src/instructions/definitions/index.ts) class.\n\nFor example, it is much easier to permute an object, than it is to permute\na string. It also increases type safety, as instructions can specify the types\nand order of arguments.\n\n[Documentation on compiling and executing generated MIPS assembly](#compiling-to-mips)\n\n[Documentation on compiling and executing generated x64 assembly](#compiling-to-x64)\n\n[Documentation on compiling and executing generated LLVM assembly](#compiling-to-llvm-assembly)\n\n#### Final code optimization\n\nFinal code optimization consists\nof [peephole optimization](https://en.wikipedia.org/wiki/Peephole_optimization)\n\nThe source code is located\nin [./src/instructions/optimize](./src/instructions/optimize).\n\nThe optimization is made as platform-independent as possible.\n\n\u003e You can disable all optimizations by passing a `--dontOptimize` argument.\n\u003e This is useful for debugging as that way generated intermediate code is\n\u003e a 1:1 representation of the AST.\n\n### Execution\n\n#### Runtime environment\n\n##### MIPS\n\nMIPS runtime environment\nis [MARS](http://courses.missouristate.edu/kenvollmar/mars/)\n\nThe code takes advantage of its syscalls.\n\n##### x64 and LLVM\n\nx64 runtime environment is any x64 capable machine. LLVM assembly can be\ncompiled to run on any machine.\n\nThe generated assembly code does not make syscalls directly, but rather\nuses [a tiny C helpers library](src/instructions/definitions/std/amd.c).\n\nThis greatly simplifies the code generation process, as printing numbers/strings\nto the screen or receiving input from the IO stream using bare syscalls is too\nhardcore.\n\n#### Interpreter\n\nBesides compiling down to assembly, a TypeScript-based interpreter is also\navailable.\n\nSource code is located in [./src/interpreter](./src/interpreter)\n\n[Usage instructions](#running-interpreter)\n\nThe definitions of all AST nodes are\nin [`./src/ast/definition/`](./src/ast/definitions).\n\nEach AST node has an `evaluate()` method that is called during interpretation.\n\nEach variable declaration has a `.value` property, that stores the current\nvalue.\n\nSince function pointers are supported, the variable value may point to function\ndeclaration.\n\n## `alia` Documentation\n\n[Language Specification](./docs/README.md) includes detailed description of the\nLexical system, Syntactic analysis and the Type System.\n\n## Development Documentation\n\n`alia` is built using TypeScript.\n\nYou can run TypeScript in Node.js using on-the-fly transpilation like this:\n\n```sh\nnpx ts-node-esm src/index.ts --your --arguments --here\n```\n\nNode.js debugger could also be used. Instructions for\n[WebStorm/PyCharm](https://www.jetbrains.com/help/webstorm/running-and-debugging-typescript.html#ws_ts_debug)\nand [VS Code](https://code.visualstudio.com/docs/typescript/typescript-debugging)\n\nAs far as dependencies, chalk is used in the interpreter for adding color and\ncommander is used in the compiler for parsing the CLI arguments.\n\nFor debugging generated MIPS code,\n[MARS](http://courses.missouristate.edu/kenvollmar/mars/) is very helpful - it\nprovided a step-by-step debugger.\n\nFor debugging generated x64 `gdbtui` is very helpful.\n\nJust start the debugger like `gdbtui ./dev.prog`, then enter the assembly\nlayout using `layout asm`, and then\nfollow [the assembly debugging commands](http://web.cecs.pdx.edu/~apt/cs510comp/gdb.pdf)\n.\n\n## Appendix 1: Extending the language\n\nA high-level overview of the steps necessary to extend the Alia language:\n\n- Read the [Compiler Architecture](#architecture) section of this document\n- If necessary, add additional tokens.\n  See [Lexical Analysis](#lexical-analysis-tokenizing)\n- Modify the grammar to add rules for the new tokens / new combinations of\n  existing tokens. See [Syntax Analysis](#syntactic-analysis-parsing)\n- Add new AST nodes for the new rules.\n  See [AST](#abstract-syntax-tree-ast-generation)\n- Add new Quads for the new AST nodes.\n  See [Intermediate code generation](#intermediate-code-generation)\n- If necessary, define new instructions.\n  See [Final code generation](#final-code-generation)\n- Add test cases for the changes made in each of the above steps.\n\nIf you are interested in a language that is easier to customize, take a look at\n[maxpatiiuk/leto](https://github.com/maxpatiiuk/leto).\n\nUnlike this project, `maxpatiiuk/leto` is geared towards making it trivially\neasy to customize the grammar and the syntax-directed translation.\n\n## Appendix 2: Generating a graph of the grammar\n\nOptional step of the SLR parser that helps to visualize (and debug) the grammar.\n\nConvert the SLR automata into a Graphviz graph definition, which in turn can\nbe converted into an SVG or a PNG.\n\n\u003e NOTE: due to grammar being quite large, the resulting graph is enormous.\n\u003e\n\u003e To make it more practical, I commented out large portions of the grammar\n\u003e before running the graph generation to reduce the size of the\n\u003e graph.\n\nFirst, create a `parser.dot` text file (in the DOT format):\n\n```\n./alia infile.alia --diagramPath parser.dot\n```\n\nThen, convert it into a `parser.svg` image (assuming dot is installed):\n\n```sh\ndot -Tsvg parser.dot -o parser.svg\n```\n\nTested with `dot v6.0.1`\n\nExample of a tiny slice of the generated graph:\n![Example of a tiny slice of the generated graph](./docs/img/graphviz-graph.png)\n\n## Appendix 3: Sources\n\nThe following pages have been helpful during the development of the compiler.\n\n### CYK Parser\n\n- https://www.geeksforgeeks.org/cyk-algorithm-for-context-free-grammar/\n- https://www.xarg.org/tools/cyk-algorithm/\n- https://www.youtube.com/watch?v=VTH1k-xiswM\n\n### SLR Parser\n\n- https://www.geeksforgeeks.org/slr-parser-with-examples/\n\n### MIPS\n\n- https://godbolt.org/\n- http://courses.missouristate.edu/kenvollmar/mars/\n- https://inst.eecs.berkeley.edu/~cs61c/resources/MIPS_Green_Sheet.pdf\n- https://uweb.engr.arizona.edu/~ece369/Resources/spim/MIPSReference.pdf\n- https://stackoverflow.com/questions/15331033/how-to-get-current-pc-register-value-on-mips-arch\n- https://courses.cs.washington.edu/courses/cse378/09wi/lectures/lec04-annotated.pdf\n- https://courses.missouristate.edu/kenvollmar/mars/help/SyscallHelp.html\n- https://ecs-network.serv.pacific.edu/ecpe-170/tutorials/mips-example-programs\n- https://www.quora.com/What-is-the-actual-difference-between-x86-ARM-and-MIPS-architectures\n\n### x64\n\n- https://godbolt.org/\n- https://learn.microsoft.com/en-us/windows-hardware/drivers/debugger/x64-architecture\n- https://cs.brown.edu/courses/cs033/docs/guides/x64_cheatsheet.pdf\n- https://stackoverflow.com/questions/20637569/assembly-registers-in-64-bit-architecture\n- https://wiki.cdot.senecacollege.ca/wiki/X86_64_Register_and_Instruction_Quick_Start\n- https://learn.microsoft.com/en-us/cpp/build/stack-usage?view=msvc-170#stack-allocation\n- https://www.cs.swarthmore.edu/~newhall/cs31/resources/ia32_gdb.php\n- http://web.cecs.pdx.edu/~apt/cs510comp/gdb.pdf\n- https://stackoverflow.com/questions/2420813/using-gdb-to-single-step-assembly-code-outside-specified-executable-causes-error\n\n### LLVM\n\n- https://godbolt.org/\n- https://mapping-high-level-constructs-to-llvm-ir.readthedocs.io/en/latest/README.html\n- https://llvm.org/docs/tutorial/MyFirstLanguageFrontend/LangImpl01.html\n- https://clang.llvm.org/doxygen/index.html\n- https://releases.llvm.org/2.6/docs/LangRef.html\n- https://formulae.brew.sh/formula/llvm\n- https://www.embecosm.com/appnotes/ean10/ean10-howto-llvmas-1.0.html\n- https://llvm.org/devmtg/2013-11/slides/Zakai-Emscripten.pdf\n- https://www.oreilly.com/library/view/llvm-cookbook/9781785285981/ch01s04.html\n- https://manpages.ubuntu.com/manpages/impish/man1/ld.lld.1.html\n- https://www.npmjs.com/package/llvm-bindings\n- https://www.npmjs.com/package/llvm-node\n- https://groups.google.com/g/llvm-dev/c/-ihkMNlDvEQ\n- https://purelyfunctional.org/posts/2018-04-02-llvm-hs-jit-external-function.html\n- https://llvm.org/docs/SourceLevelDebugging.html#llvm-dbg-declare\n\n### Misc\n\n- https://ecotrust-canada.github.io/markdown-toc/\n- https://carbon.now.sh/\n\n## Appendix 4: Naming\n\nThe language is named after \"Alia Atreides\" from the Dune book series.\n\nMy #1 source of sci-fi sounding terms is the [Dune terminology](https://dune.fandom.com/wiki/List_of_Dune_terminology)\npage. Also, glossaries of sci-fi terms are helpful\n([techrepublic.com](https://www.techrepublic.com/article/75-words-every-sci-fi-fan-should-know/),\n[bowdoin.edu](https://courses.bowdoin.edu/ital-2500-spring-2015/terminology/))","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaxpatiiuk%2Falia","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmaxpatiiuk%2Falia","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaxpatiiuk%2Falia/lists"}