{"id":19212543,"url":"https://github.com/fasterthanlime/pug","last_synced_at":"2025-11-14T09:01:55.752Z","repository":{"id":19430731,"uuid":"22673602","full_name":"fasterthanlime/pug","owner":"fasterthanlime","description":"My new language project, I guess.","archived":false,"fork":false,"pushed_at":"2014-08-15T20:45:05.000Z","size":3340,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-01-04T17:30:46.624Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-2-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fasterthanlime.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}},"created_at":"2014-08-06T07:26:30.000Z","updated_at":"2015-02-28T23:32:15.000Z","dependencies_parsed_at":"2022-08-20T22:20:11.447Z","dependency_job_id":null,"html_url":"https://github.com/fasterthanlime/pug","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/fasterthanlime%2Fpug","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fasterthanlime%2Fpug/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fasterthanlime%2Fpug/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fasterthanlime%2Fpug/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fasterthanlime","download_url":"https://codeload.github.com/fasterthanlime/pug/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240286520,"owners_count":19777353,"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":"2024-11-09T13:47:16.608Z","updated_at":"2025-11-14T09:01:55.661Z","avatar_url":"https://github.com/fasterthanlime.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n# pug\n\npug is my new programming language project, I guess.\n\nObjectives:\n\n  - jit interpreter (libjit) + aot compiler (llvm)\n  - prototype-based, duck typing\n  - batteries included: bignum, collections, unicode\n\nInfluences: lua, javascript, ruby\n\nUntil further notice, this project isn't useful for any purpose - I'm just\ntrying out new things for fun, we'll see where it leads.\n\n## License\n\nThe pug project is released under the terms of the Simplified BSD license\n(2-clause) - see the LICENSE file for a copy.\n\nDependencies are originally licensed as follows:\n\n  - libjit: LGPL-2.1 - must be dynamically linked\n  - libcollections: BSD\n  - greg: BSD\n  - gc: permissive, similar to X11 license\n  - jansson: BSD\n  - bstring: GPL/BSD dual-licensed (I choose you, BSD!)\n\n## Captain's log\n\nHint: read it from bottom to top.\n\n### 2014-08-14\n\nAfter fixing parsing with greg, and managing to store it in a few data\nstructures, I've started thinking about AST traversal, dumping it for\ndebug, various transformations, etc.\n\nThe problem with 'C-structs-as-first-argument-of-a-bunch-of-functions'-style\nis that you don't necessarily have a common, uh, structure for your structs.\nie. your structs aren't tagged with a type, you can't have a visitor pattern\nbecause you have no idea how to dispatch (remember, a `void*` pointer is only\nuseful if you roughly know what's hiding underneath).\n\nI don't want to go full-ooc where everything has a class, and classes have\nmetaclasses, and everything is virtual and overrideable and blah, that's\ntoo heavy. I took a look at GLib, even thought of rewriting the whole thing\nin Vala or Genie, and then snapped back to reality.\n\nSo I'm thinking, something light could do the trick - a pointer to a `class`\nfield, that's a pointer to a struct of known type, say, `pug_ast_node_interface`.\nThis struct has pointers to various other structs - if they're non-null, the\ninterfaces are implemented for that class.\n\nFor examples, some nodes might be typed, or have a scope, things like that,\nthat will make AST traversal easier (at least, possible). It's still very\ncumbersome to do anything with C at all, but as I'm learning the hard way,\n\"it's nothing that a few macros can't fix\".\n\nI care more about safety and debuggability than runtime performance at the\nmoment - already ran into a few bad segfaults that I had to whip out gdb\nfor (and on OSX, even brew-installed gdb must be codesigned by hand now,\nso I wasn't really happy about that).\n\nI added [jansson][jansson] to take care of JSON decoding/encoding. I've\nstarted writing an AST dump to json - this will not only make external\ntools easy to write, it'll also make the frontend easy to test: just check\nthat the JSON structure matches. It might not be ideal for bytecode, for\ninstance, but I have yet to figure that out completely (with libjit).\n\nI added [bstring][bstring] to manipulate strings. C's stdlib functions are just\ntoo barebones and error-prone for my taste. At least now I can substring,\nconcatenate, format, replace, and split without worrying about things\nexploding.  I had to modify bstring a little to use GC-allocated memory, and\nwrote a tiny bridge macro to help jansson deal with bstrings.\n\n[jansson]: http://www.digip.org/jansson/\n[bstring]: http://bstring.sourceforge.net/\n\n### 2014-08-13\n\nIt was fun to experiment with PackCC, and `packrat` seemed like a fun buzzword,\nmaybe it would've been faster than Ian Piumarta's peg/leg, maybe allowing left\nrecursion and memoizing and everything would've been fantastic, but right now:\n\n  - PackCC doesn't support leg grammar, and I really like leg grammar\n  - PackCC error reporting isn't the greatest, let's be honest\n\nIt's probably a very fine project, but right now I'm more used to [greg][greg]\n- I know how to make friendly parsers with it, the leg syntax is nice, and\neverything. I reused a bunch of tricks from [nagaqueen][nagaqueen], the ooc\ngrammar, for reading from memory \u0026 file streams, rewinding whitespace, etc.\n\nI still have no idea how I could parse a significant-whitespace language\nwith a PEG. A quick search turns up [moonscript][moonscript], I should ask\nleafo about it - or just muster up the courage to decipher lpeg-using-code.\n\nI adapted gf3/peg.vim to get [leg syntax highlighting in vim][leg.vim].\n\nI've also decided to rely on the [Boehm GC][bdw-gc] for the compiler/interpreter.\nI don't really want to deal with manual memory allocation in such a codebase\nfor now. I might, later, but I have to make the best use of my limited\navailable brainspace.\n\n[moonscript]: https://github.com/leafo/moonscript/blob/master/moonscript/parse.lua\n[greg]: https://github.com/fasterthanlime/greg\n[leg.vim]: https://github.com/fasterthanlime/leg.vim\n[bdw-gc]: http://www.hboehm.info/gc/ \n\n### 2014-08-11\n\nMigrated project to CMake - its `ExternalProject` feature makes it easy to\nbuild, well, external projects, whether they are autotools-based, cmake-based,\nor god-knows-what-based. Really the only bad thing I can say about it is that\nyou can't specify environment variables.\n\nAs for our own CMakeLists.txt, I'm using `file(GLOB)` directives because I'm\nlazy and don't want to list everything by hand - also because I expect the\nnumber of source files to explode over the next few weeks.\n\n[cmake]: http://www.cmake.org/\n\n### 2014-08-07\n\nFixed libcollections so that it builds on MinGW (win32 gcc) - turns out you\ncan't use `TYPES_H` as a header guard and expect your stuff to run everywhere\n(don't blame me, I'm just using.)\n\nSpent way too long trying to get the whole thing compiling in a win32\nenvironment. While waiting for libjit to try and compile for the 20th time that\nevening, tried a cross-compilation from [Debian][debian] out of boredness,\nwhich pretty much worked first time, and much quicker too.\n\nI think I may be done messing with mingw on Windows at all.\n[mingw-w64][mingw-w64] on Debian is now my weapon of choice to produce Windows\nbinaries.\n\n[mingw-w64]: http://mingw-w64.sourceforge.net/\n[debian]: http://www.debian.org/\n\n### 2014-08-06\n\nAfter experimenting with a few JITs, decided to take [libjit][libjit] for a spin.\n\nSet up a minimal project with a hand-written Makefile.\n\nUsing [packcc][packcc] to generate a parser from a [PEG][peg] grammar. It seems\nold, but works so far.\n\nUsing [libcollections][libcollections] so I don't have to write a hash table,\nvector, etc. all over again. It seems mostly header-based, but it's kinda good\n- it gets you compiler warnings on incompatible types, and your own function\nname, I kind of like it so far.\n\nHappy with vendoring (= including the sources of) libs I'm depending on, so\nthat I can apply fixes if needed. For example, libjit had a codepath that used\ndeprecated OSX APIs instead of [dlopen/dlsym/dlclose][dlfcn] - I disabled it\n(it crashed when dlopening NULL, instead of exposing the global symbol table).\n\n[libjit]: https://www.gnu.org/software/libjit/\n[packcc]: http://sourceforge.net/projects/packcc/\n[peg]: https://en.wikipedia.org/wiki/Parsing_expression_grammar\n[libcollections]: https://bitbucket.org/manvscode/libcollections\n[dlfcn]: https://en.wikipedia.org/wiki/Dynamic_loading\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffasterthanlime%2Fpug","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffasterthanlime%2Fpug","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffasterthanlime%2Fpug/lists"}