{"id":13778866,"url":"https://github.com/ndreynolds/flathead","last_synced_at":"2026-02-06T16:13:25.934Z","repository":{"id":4292198,"uuid":"5422596","full_name":"ndreynolds/flathead","owner":"ndreynolds","description":"A toy JavaScript interpreter written in C","archived":false,"fork":false,"pushed_at":"2023-12-12T02:33:16.000Z","size":937,"stargazers_count":90,"open_issues_count":5,"forks_count":16,"subscribers_count":11,"default_branch":"master","last_synced_at":"2024-08-03T18:13:27.828Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C","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/ndreynolds.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,"roadmap":null,"authors":null}},"created_at":"2012-08-15T05:51:18.000Z","updated_at":"2023-07-12T20:30:29.000Z","dependencies_parsed_at":"2024-01-16T12:49:44.508Z","dependency_job_id":"6fd20bd3-496d-4b1e-aa46-7986f346c84c","html_url":"https://github.com/ndreynolds/flathead","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/ndreynolds%2Fflathead","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ndreynolds%2Fflathead/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ndreynolds%2Fflathead/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ndreynolds%2Fflathead/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ndreynolds","download_url":"https://codeload.github.com/ndreynolds/flathead/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225048997,"owners_count":17412908,"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-08-03T18:00:58.339Z","updated_at":"2026-02-06T16:13:25.884Z","avatar_url":"https://github.com/ndreynolds.png","language":"C","funding_links":[],"categories":["C"],"sub_categories":[],"readme":"Flathead\n========\nFlathead is a tiny, portable JavaScript (ECMA-262) interpreter written in C.\n\n[![Build Status](https://travis-ci.org/ndreynolds/flathead.png?branch=master)](https://travis-ci.org/ndreynolds/flathead)\n\n![Flathead's REPL](doc/screenshot.png)\n\nThe interpreter does a direct evaluation of the parse tree—it does not\ncurrently build any further IR or perform any optimizations. As a result, it\nstarts up very quickly, and performs well on code that wouldn't benefit much\nfrom optimization, and less well on code that would (e.g. loops).\n\nFlathead builds on Linux, OSX and \\*BSD, on x86, x86_64 and ARM architectures.\n\nFlathead comes with the full EcmaScript runtime (i.e. the Date, Math, Array\nand other global objects) as well as a console object.\n\nMost of the language is now implemented, you can see the remaining\nwork to be done on [the Docket](#the-docket).\n\n\nInstalling\n----------\nDownload or clone the source and run `make` within.\n\n    git clone https://github.com/ndreynolds/flathead.git\n    cd flathead\n    make\n\nThis creates an executable at `bin/flat` within the source directory. (You can\noptionally run `make install` to copy this to `/usr/local/bin/`.)\n\n#### Dependencies\n\nIf you received any errors, you may just be missing dependencies.\n\n`flex` and `bison` are required to generate the lexer and parser.\n\nThe default build depends on GNU Readline (`lreadline`) for the REPL, and PCRE\n(`lpcre`) for the regular expression implementation. They're not required,\nhowever, for a minimal build. Run `make readline=off regexp=off` to compile\nwithout them.\n\nIf you're still having trouble building, please create an issue.\n\n\nRunning\n-------\nOnce built, you can run `bin/flat` without arguments to start a REPL:\n\n    $ bin/flat\n    \u003e 2 + 2\n    4\n    \u003e\n\nOr with a script as argument:\n\n    $ bin/flat say_hello.js\n    Hello!\n\nView the parse tree with `-n`:\n\n    $ bin/flat -n\n    \u003e 2 + 2\n    source list\n      expression statement\n        expression (binary)\n          +\n          number (2.000000)\n          number (2.000000)\n    4\n    \u003e\n\nSee all the options with `-h`:\n\n    $ bin/flat -h\n    Usage: flat [options] [script.js]\n\n    Options:\n      -v, --version       print version info\n      -h, --help          print this help text\n      -i, --interactive   force REPL\n      -n, --nodes         print the AST\n      -t, --tokens        print tokens\n\n\nRunning the tests\n-----------------\nFlathead's test suite can be run against the `bin/flat` executable, as well as\nother EcmaScript implementations (assuming you have them installed).\n\nThe test runner itself requires Node.js. It locates files with names beginning\nin `test_` and executes them with the configured implementation and options.\nThere are a few Node module dependencies, so you'll need to run `npm install`\nbefore you can run the tests.\n\nThe Makefile has a few shortcuts:\n\n`make test` to run with Flathead's `bin/flat` executable.\n`make test-v8` to run using `v8`.\n`make test-node` to run using `node`.\n`make test-sm` to run using `js` (SpiderMonkey).\n`make test-rhino` to run using `rhino`.\n\nThere's also:\n\n`make test-grammar` to verify parsing and AST formation\n\n\nThe Docket\n----------\n- With statement (`with`)\n- Labels (e.g. `loop1: ...; continue loop1;`)\n- Automatic Semicolon Insertion\n- Unicode\n- The JSON object ([JSON-js][1] can be used as polyfill)\n- URI functions\n- `String#replace`: replacement function\n- `String#split`: RegExp separators\n\n\n[1]: http://github.com/douglascrockford/JSON-js\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fndreynolds%2Fflathead","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fndreynolds%2Fflathead","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fndreynolds%2Fflathead/lists"}