{"id":16918309,"url":"https://github.com/forloveofcats/mountain","last_synced_at":"2025-10-30T06:47:07.915Z","repository":{"id":157600577,"uuid":"196094973","full_name":"ForLoveOfCats/Mountain","owner":"ForLoveOfCats","description":"Compiler I once wrote for a custom language called Mountain","archived":false,"fork":false,"pushed_at":"2021-03-14T06:27:33.000Z","size":418,"stargazers_count":8,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"OriginalC","last_synced_at":"2025-04-11T16:32:16.050Z","etag":null,"topics":["c","compiler","language","parser","programming-language"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ForLoveOfCats.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","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":"2019-07-09T22:55:49.000Z","updated_at":"2023-07-17T01:43:47.000Z","dependencies_parsed_at":null,"dependency_job_id":"7aa67be0-e41d-4c00-aa1b-f84ce0c91b60","html_url":"https://github.com/ForLoveOfCats/Mountain","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ForLoveOfCats%2FMountain","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ForLoveOfCats%2FMountain/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ForLoveOfCats%2FMountain/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ForLoveOfCats%2FMountain/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ForLoveOfCats","download_url":"https://codeload.github.com/ForLoveOfCats/Mountain/tar.gz/refs/heads/OriginalC","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248441349,"owners_count":21103976,"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":["c","compiler","language","parser","programming-language"],"created_at":"2024-10-13T19:39:34.067Z","updated_at":"2025-10-30T06:47:02.878Z","avatar_url":"https://github.com/ForLoveOfCats.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Mountain, a rather simple language + compiler\n\nThis is the original compiler for a toy language I was building about a\nyear and a half ago now. It was written entirely in C and generated\nexecutables by outputting C source which was then built with a C compiler.\nThere are numerious problems with the implementation which drove me to ditch\nit and start over again before dropping the project entirely.\n\nIssues:\n * Conflated the parse tree and semantic tree. This would not be an overly egregious\n  issue if it weren't for the next issue as some compilers intentionally model their\n  internals like this to reduce allocations for the sake of speed\n * Uses a single struct to represent all potential nodes in the program tree. This\n  means that if even one node needs a field then all nodes had that field. This really\n  should have been a union.\n * The expression parser is just plain god-awful. It was my first of many expression\n  parsers and really had not business working as well as it did. In a desperate attempt\n  to correctly handle operator precedence I turned it into the most difficult to follow\n  spagetti.\n\nTo play around with it use the `Debug.sh`, `Test.sh`, and `Reproduction.sh` scripts to\nbuild and run the compiler on various pieces of Mountain code. This will only work on a\nPOSIX-ish OS. By default they will use `clang` to build the compiler and emitted C source.\nThis can be trivially swapped out for `gcc` by simply modifying the scripts.\n * `Debug.sh`: This will build and run the Mountain code under `./examples`\n * `Test.sh`: This will build and run the \"test suite\" under `./tests`\n * `Reproduction.sh`: This will build and run the stub Mountain code under `./reproduction`\n * `Build.sh`: This will just build the Mountain compiler itself, used by the other\n  scripts\n\nAs mentioned I eventually gave up on this implementation and began again with a new codebase\nbeing implemented in Zig. The remains of how far I got is still present in another branch. I\nended up scraping the project in frustration in having Zig constantly being shifted and changed\nbeneath my feet. That of course is my fault in attempting to build a \"serious\" project in an\nactively evolving language.\n\n# Original ReadMe\n## Mountain Programming Language\n### A (hopefully) fast, C compatible, language designed to enable greatness\n\n\n#### Welcome to the Github repo for the (WIP) Mountain bootstrap compiler\n\nThe goal is to have a self hosted compiler by the end of\nsummer 2020. At the moment Mountain rather far away from that goal.\n\n\n#### Vision\n\nMountain has several core tenants:\n* Usefulness is key, all other tenants can be sacrificed in the name\n  of usefulness.\n    * Seamless C interop is important for usefulness.\n    * High performance is important for usefulness.\n* Explicitness is important for readability and reason-ability.\n    * Explicit does not always have to mean verbose\n* Maximizing expressiveness is valuable where possible\n    * Balancing this with performance is a razors edge, trust the\n      developer to use the right language tools where appropriate.\n* Avoid restricting the developer's freedom for philosophical reasons.\n* It is not the language's job to enforce a specific coding \"style\".\n\nMountain draws much inspiration from Zig, Rust, and of course its\nparent language C.\n\n\n## This language is nowhere near usable for literally anything\nThis is currently little more than a fun side project with hopes of\neventually becoming more. Read the feature wishlist\n[here](WISHLIST.md) for more information about what Mountain hopes to\nbe capable of. Feel free to poke around.\n\nBe aware that this is *extremely* WIP. There are many areas where\nthings should change or be improved. Performance could be improved by\nfixing a few rather egregious design cases (symbol lookup is a worst\ncase O(n) while loop checking each symbol with strcmp, the nodes\nshould be tagged unions, I should be using string interning,\nect). Originally this compiler was being built to be thrown away once\na self-hosted compiler could be built. However now the goal is to port\nthis codebase into Mountain so these design oversights are slowly\nbeing corrected.\n\nAs of currently Mountain is a transpiling language in that the\ncompiler emits C source code which is then fed through GCC or Clang in\norder to produce the final binary. Mountain should eventually move to\ndirectly using LLVM. I decided to not use LLVM right out of the gate\ndue to the high barrier of entry to utilizing LLVM and the extra work\nit will take to ensure ABI compatibility with various C\ncompilers. With the goal to get the language functional and useful\nquickly I opted to transpile to C for now.\n\n\n#### Currently supported features\n* Variable declaration (requires a value or explicitly left undefined)\n* Variable value set\n* Global variables\n* Symbol scoping\n* Basic type system (current builtin types are `u8`, `i32`, `Bool`,\n  and `Ptr`, also supports custom types (enums and structs))\n* Function declarations (with parameters and return type)\n* Return values from non-Void functions (can also return no value from\n  Void functions to early exit)\n* Basic function return tracing\n* Function calls (with and without return value)\n* Enums definition and usage\n* Stuct definition (TODO dependency loops not yet detected, reliant on\n  order relative to other structs)\n* Stack allocated struct initialization\n* Read and write to struct fields\n* Order of global symbols does not matter\n* Expression parsing with precedence\n* Boolean inversion with `!`\n* Full set of comparison operators (==, !=, \u003e, \u003c, \u003e= \u003c=)\n* Basic pointers (take address of, compare, dereference, and overwrite\n  value pointed at)\n* Basic module system (each file declares what module it exists in,\n  all files in a module share a single namespace (but not imports) and\n  modules can be imported (accessing contents requires prefixing with\n  module name) or `using` imported (does not require module name\n  prefix))\n* Conditional flow control with `if`/`elif`/`else`\n* Conditional flow control with `while` (includes `break` and `continue`)\n* Basic in-langauge test system (simply returns a bool for\n  success/failure, not final design)\n* Functions can be defined inside other functions\n* Single line comments\n* Character literal parsing (with escape sequence support)\n* Semi-decent parse errors\n* As many validation error checks (with decent messages) that I could\n  think of\n\n\n### This is currently only tested on Linux\n\nIt will probably work on macOS but *will not* work on Windows as it\nuses `dirent.h`. This will change in the future, until then if you\nreally want to run this on Windows go grab an dirent wrapper or open\nan issue to bug me into prioritizing this more.\n\n\n### Building\n\nRequires SCons and a recent revision of Clang. It will also build with\nGCC but depending on the platform the `SConstruct` will need to be\nmodified.\n\nTo perform the most basic build simply execute the command `scons`\nwhile in the repo root.\n\nThe shell script `Debug.sh` builds the compiler, compiles the code\nunder `./examples`, and then runs it. The other script `Test.sh`\nbuilds the compiler, builds the test code under `./tests`, and then\nruns those tests.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fforloveofcats%2Fmountain","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fforloveofcats%2Fmountain","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fforloveofcats%2Fmountain/lists"}