p.enthalabs

GitHub - xjslang/xjs: eXtensible JavaScript parser

Skip to content

Navigation Menu

[](https://github.com/)

Sign in

Appearance settings

* Platform

* AI CODE CREATION

- GitHub Copilot Write better code with AI

- GitHub Copilot app Direct agents from issue to merge

- MCP Registry Integrate external tools

* DEVELOPER WORKFLOWS

- Actions Automate any workflow

- Codespaces Instant dev environments

- Issues Plan and track work

- Code Review Manage code changes

- Code Quality Enforce quality at merge

* APPLICATION SECURITY

- GitHub Advanced Security Find and fix vulnerabilities

- Code security Secure your code as you build

- Secret protection Stop leaks before they start

* EXPLORE

- Why GitHub

- Documentation

- Blog

- Changelog

- Marketplace

View all features

* Solutions

* BY COMPANY SIZE

- Enterprises

- Small and medium teams

- Startups

- Nonprofits

* BY USE CASE

- App Modernization

- DevSecOps

- DevOps

- CI/CD

- View all use cases

* BY INDUSTRY

- Healthcare

- Financial services

- Manufacturing

- Government

- View all industries

View all solutions

* Resources

* EXPLORE BY TOPIC

- AI

- Software Development

- DevOps

- Security

- View all topics

* EXPLORE BY TYPE

- Customer stories

- Events & webinars

- Ebooks & reports

- Business insights

- GitHub Skills

* SUPPORT & SERVICES

- Documentation

- Customer support

- Community forum

- Trust center

- Partners

View all resources

* Open Source

* COMMUNITY

- GitHub Sponsors Fund open source developers

* PROGRAMS

- Security Lab

- Maintainer Community

- GitHub Stars

- Archive Program

* REPOSITORIES

- Topics

- Trending

- Collections

* Enterprise

* ENTERPRISE SOLUTIONS

- Enterprise platform AI-powered developer platform

* AVAILABLE ADD-ONS

- GitHub Advanced Security Enterprise-grade security features

- Copilot for Business Enterprise-grade AI features

- Premium Support Enterprise-grade 24/7 support

- Pricing

Search/

Sign in

Sign up

Appearance settings

You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert

{{ message }}

Uh oh!

There was an error while loading. Please reload this page.

xjslang/**xjs**Public

- NotificationsYou must be signed in to change notification settings

- Fork 0

- Star 11

- Code

- Issues 3

- Pull requests 0

- Actions

- Projects

- Security and quality 0

- Insights

Additional navigation options

- Code

- Issues

- Pull requests

- Actions

- Projects

- Security and quality

- Insights

[](https://github.com/xjslang/xjs)

main

**3**Branches**3**Tags

[](https://github.com/xjslang/xjs/branches)[](https://github.com/xjslang/xjs/tags)

Go to file

Code

Open more actions menu

Latest commit

![Image 1: gchumillas](https://github.com/gchumillas)gchumillas

docs: update README

Aug 28, 2026

4edd376·Aug 28, 2026

History

1,257 Commits

Open commit details

[](https://github.com/xjslang/xjs/commits/main/)1,257 Commits

Folders and files

| Name | Name | Last commit message | Last commit date | | --- | --- | --- | --- |

| [.githooks](https://github.com/xjslang/xjs/tree/main/.githooks ".githooks") | [.githooks](https://github.com/xjslang/xjs/tree/main/.githooks ".githooks") | [feat(lexer): create token.RegisterType function](https://github.com/xjslang/xjs/commit/cf11a1d8795a15614fd8062b6c45912104ae26af "feat(lexer): create token.RegisterType function") | Apr 24, 2026 |

| [.github](https://github.com/xjslang/xjs/tree/main/.github ".github") | [.github](https://github.com/xjslang/xjs/tree/main/.github ".github") | [chore: add CI workflow](https://github.com/xjslang/xjs/commit/4709e654cd0fc2c79a09690f7b73eb3d8364503b "chore: add CI workflow") | Aug 17, 2026 |

| [.vscode](https://github.com/xjslang/xjs/tree/main/.vscode ".vscode") | [.vscode](https://github.com/xjslang/xjs/tree/main/.vscode ".vscode") | [refactor: concatenate pass/*.js files into a single check/general.js …](https://github.com/xjslang/xjs/commit/1087fd5626a3b5743a871c8f404686c301770736 "refactor: concatenate pass/*.js files into a single check/general.js file") | Aug 6, 2026 |

| [ast](https://github.com/xjslang/xjs/tree/main/ast "ast") | [ast](https://github.com/xjslang/xjs/tree/main/ast "ast") | [feat(parser): implement export statement](https://github.com/xjslang/xjs/commit/ac2370220bdb70e3d4a205593d775624695e72e1 "feat(parser): implement export statement") | Jul 11, 2026 |

| [examples](https://github.com/xjslang/xjs/tree/main/examples "examples") | [examples](https://github.com/xjslang/xjs/tree/main/examples "examples") | [refactor: move js into jsextended and rename jsextended it to js](https://github.com/xjslang/xjs/commit/9dcfbb991ceaf1df0c5d8c1a582713c8c7f1be9f "refactor: move js into jsextended and rename jsextended it to js") | Aug 25, 2026 |

| [internal](https://github.com/xjslang/xjs/tree/main/internal "internal") | [internal](https://github.com/xjslang/xjs/tree/main/internal "internal") | [refactor: move js into jsextended and rename jsextended it to js](https://github.com/xjslang/xjs/commit/9dcfbb991ceaf1df0c5d8c1a582713c8c7f1be9f "refactor: move js into jsextended and rename jsextended it to js") | Aug 25, 2026 |

| [js](https://github.com/xjslang/xjs/tree/main/js "js") | [js](https://github.com/xjslang/xjs/tree/main/js "js") | [fix: benchmarks](https://github.com/xjslang/xjs/commit/f3a5fb671e274eb6de1429d7521ceecd2ed7916b "fix: benchmarks") | Aug 28, 2026 |

| [magefiles](https://github.com/xjslang/xjs/tree/main/magefiles "magefiles") | [magefiles](https://github.com/xjslang/xjs/tree/main/magefiles "magefiles") | [refactor: move js into jsextended and rename jsextended it to js](https://github.com/xjslang/xjs/commit/9dcfbb991ceaf1df0c5d8c1a582713c8c7f1be9f "refactor: move js into jsextended and rename jsextended it to js") | Aug 25, 2026 |

| [parser](https://github.com/xjslang/xjs/tree/main/parser "parser") | [parser](https://github.com/xjslang/xjs/tree/main/parser "parser") | [refactor: move scanner into parser](https://github.com/xjslang/xjs/commit/0dea297b8ee180f6e27bb2afd8d0e6699a6d4eea "refactor: move scanner into parser") | Aug 27, 2026 |

| [printer](https://github.com/xjslang/xjs/tree/main/printer "printer") | [printer](https://github.com/xjslang/xjs/tree/main/printer "printer") | [refactor: move js into jsextended and rename jsextended it to js](https://github.com/xjslang/xjs/commit/9dcfbb991ceaf1df0c5d8c1a582713c8c7f1be9f "refactor: move js into jsextended and rename jsextended it to js") | Aug 25, 2026 |

| [scanner](https://github.com/xjslang/xjs/tree/main/scanner "scanner") | [scanner](https://github.com/xjslang/xjs/tree/main/scanner "scanner") | [refactor: move scanner into parser](https://github.com/xjslang/xjs/commit/0dea297b8ee180f6e27bb2afd8d0e6699a6d4eea "refactor: move scanner into parser") | Aug 27, 2026 |

| [testdata/bench](https://github.com/xjslang/xjs/tree/main/testdata/bench "This path skips through empty directories") | [testdata/bench](https://github.com/xjslang/xjs/tree/main/testdata/bench "This path skips through empty directories") | [test(benchm): compare XJS with Goja and tdewolff](https://github.com/xjslang/xjs/commit/9af2d75f67764ee4046dfef9bb50507e9ddad6b1 "test(benchm): compare XJS with Goja and tdewolff") | Aug 26, 2026 |

| [token](https://github.com/xjslang/xjs/tree/main/token "token") | [token](https://github.com/xjslang/xjs/tree/main/token "token") | [refactor: remove token.Scanner interface](https://github.com/xjslang/xjs/commit/21fce9f62ff3199c33a1ef89e7da032c91965410 "refactor: remove token.Scanner interface") | Aug 27, 2026 |

| [.agent.md](https://github.com/xjslang/xjs/blob/main/.agent.md ".agent.md") | [.agent.md](https://github.com/xjslang/xjs/blob/main/.agent.md ".agent.md") | [feat(docs): update parser philosophy section to clarify syntax vs sem…](https://github.com/xjslang/xjs/commit/fb9bbe590c38513934ebcca74ecdcc285a9cf4e3 "feat(docs): update parser philosophy section to clarify syntax vs semantics") | Jul 31, 2026 |

| [.gitattributes](https://github.com/xjslang/xjs/blob/main/.gitattributes ".gitattributes") | [.gitattributes](https://github.com/xjslang/xjs/blob/main/.gitattributes ".gitattributes") | [chore: add .gitattributes to enforce LF line endings](https://github.com/xjslang/xjs/commit/0783d6f4616830737214a03346aeaee1797ce4ba "chore: add .gitattributes to enforce LF line endings") | Aug 17, 2026 |

| [.gitignore](https://github.com/xjslang/xjs/blob/main/.gitignore ".gitignore") | [.gitignore](https://github.com/xjslang/xjs/blob/main/.gitignore ".gitignore") | [Implement sourcemap functionality](https://github.com/xjslang/xjs/commit/fd974c03a3afa8fda417a2641cea571d54ca0669 "Implement sourcemap functionality") | Dec 14, 2025 |

| [.golangci.yml](https://github.com/xjslang/xjs/blob/main/.golangci.yml ".golangci.yml") | [.golangci.yml](https://github.com/xjslang/xjs/blob/main/.golangci.yml ".golangci.yml") | [chore(linter): enable gofumpt and fix minor lint issues](https://github.com/xjslang/xjs/commit/8a7079fb2c394e3c341ed42bdacb43ea474a9556 "chore(linter): enable gofumpt and fix minor lint issues") | May 18, 2026 |

| [CONTRIBUTING.md](https://github.com/xjslang/xjs/blob/main/CONTRIBUTING.md "CONTRIBUTING.md") | [CONTRIBUTING.md](https://github.com/xjslang/xjs/blob/main/CONTRIBUTING.md "CONTRIBUTING.md") | [chore: setup mage](https://github.com/xjslang/xjs/commit/fc9153c8dedebe586f22746cfaa722b2ea24456b "chore: setup mage - Add magefile.go - Add Lint command - Setup pre-push") | Apr 6, 2026 |

| [LICENSE](https://github.com/xjslang/xjs/blob/main/LICENSE "LICENSE") | [LICENSE](https://github.com/xjslang/xjs/blob/main/LICENSE "LICENSE") | [Refactor xjslang: Remove parser_go.go and introduce token package](https://github.com/xjslang/xjs/commit/a76c8842e967df108756e1470d9ca12ec7e0d2f1 "Refactor xjslang: Remove parser_go.go and introduce token package - Deleted parser_go.go, consolidating the parser logic into a more structured format. - Added token package to define token types and structures used by the lexer and parser. - Created documentation for the token package, detailing token types and usage examples. - Introduced xjslang package to provide a simplified interface for lexing and parsing input. - Added Parse function for convenience, returning the AST program node and any parsing errors. - Established versioning for the xjslang package.") | Aug 13, 2025 |

| [README.md](https://github.com/xjslang/xjs/blob/main/README.md "README.md") | [README.md](https://github.com/xjslang/xjs/blob/main/README.md "README.md") | [docs: update README](https://github.com/xjslang/xjs/commit/4edd376582326fa19bfc2ff8ec8182b16ea57fdd "docs: update README") | Aug 28, 2026 |

| [go.mod](https://github.com/xjslang/xjs/blob/main/go.mod "go.mod") | [go.mod](https://github.com/xjslang/xjs/blob/main/go.mod "go.mod") | [test(benchm): compare XJS with Goja and tdewolff](https://github.com/xjslang/xjs/commit/9af2d75f67764ee4046dfef9bb50507e9ddad6b1 "test(benchm): compare XJS with Goja and tdewolff") | Aug 26, 2026 |

| [go.sum](https://github.com/xjslang/xjs/blob/main/go.sum "go.sum") | [go.sum](https://github.com/xjslang/xjs/blob/main/go.sum "go.sum") | [test(benchm): compare XJS with Goja and tdewolff](https://github.com/xjslang/xjs/commit/9af2d75f67764ee4046dfef9bb50507e9ddad6b1 "test(benchm): compare XJS with Goja and tdewolff") | Aug 26, 2026 |

| [xjs.go](https://github.com/xjslang/xjs/blob/main/xjs.go "xjs.go") | [xjs.go](https://github.com/xjslang/xjs/blob/main/xjs.go "xjs.go") | [refactor: move js into jsextended and rename jsextended it to js](https://github.com/xjslang/xjs/commit/9dcfbb991ceaf1df0c5d8c1a582713c8c7f1be9f "refactor: move js into jsextended and rename jsextended it to js") | Aug 25, 2026 |

| [xjs_bench_test.go](https://github.com/xjslang/xjs/blob/main/xjs_bench_test.go "xjs_bench_test.go") | [xjs_bench_test.go](https://github.com/xjslang/xjs/blob/main/xjs_bench_test.go "xjs_bench_test.go") | [test(benchm): compare XJS with Goja and tdewolff](https://github.com/xjslang/xjs/commit/9af2d75f67764ee4046dfef9bb50507e9ddad6b1 "test(benchm): compare XJS with Goja and tdewolff") | Aug 26, 2026 |

| [xjs_test.go](https://github.com/xjslang/xjs/blob/main/xjs_test.go "xjs_test.go") | [xjs_test.go](https://github.com/xjslang/xjs/blob/main/xjs_test.go "xjs_test.go") | [refactor(scanner): change UseScanner signature](https://github.com/xjslang/xjs/commit/fd7deceb284bbef747de0c230632a552c4d5f0e8 "refactor(scanner): change UseScanner signature") | Aug 24, 2026 | | View all files |

Repository files navigation

- README

- Contributing

- MIT license

More items

XJS (eXtensible JavaScript parser)

[](https://github.com/xjslang/xjs#xjs-extensible-javascript-parser)

A tool for creating JavaScript dialects.

Why XJS?

[](https://github.com/xjslang/xjs#why-xjs)

It all started with an innocent question: "Would it be possible to use `defer` (from Go) in JS?" And the answer is "Yes, but with caveats."

We could write a Babel plugin or extend Acorn to transpile `defer()` to JS. But those and other approaches shared a common problem: "the extension had to respect JS grammar rules." And `defer` didn't.

That's why I decided to build a JS parser capable of transpiling exotic or experimental features into standard JS.

**What can you do with XJS?**

You can create your own dialect without having to build a language from scratch. You'd simply add your own operators and statements to JS. The only limit is your imagination.

Examples

[](https://github.com/xjslang/xjs#examples)

Real-world dialects built with XJS:

- DJS - JavaScript with `defer`.

- HJS - JavaScript with native HTML tags.

See also the `examples/` directory for basic samples.

How does it work?

[](https://github.com/xjslang/xjs#how-does-it-work)

It works by intercepting the parsing flow at strategic points and adding custom **scanners**, **parsers**, and **printers**. This is done through the following methods:

- `scanner.Builder.UseScanner`: add your own custom tokens.

- `parser.Builder.UseStmtParser`: add your own statement parsers.

- `parser.Builder.UsePrefixOpParser`: add your own prefix operators.

- `parser.Builder.UseInfixOpParser`: add your own infix operators.

- `parser.Builder.UseExprParser`: add your own expression parsers (*).

- `printer.Builder.UsePrinter`: add your own node printers.

(*): You usually do not need `UseExprParser`, since `UsePrefixOpParser` and `UseInfixOpParser` are enough.

What is a Scanner, a Parser and a Printer?

[](https://github.com/xjslang/xjs#what-is-a-scanner-a-parser-and-a-printer)

The parsing process is divided into three responsibilities:

- `scanner.Scanner`: splits or "tokenizes" the input into tokens, which are later processed by the parser.

- `parser.Parser`: interprets the tokens and produces the AST (Abstract Syntax Tree).

- `printer.Printer`: turns AST nodes back into code, whether compiled, formatted, or otherwise. Each printer has a different purpose.

Benchmarks

[](https://github.com/xjslang/xjs#benchmarks)

undefinedshell go test -run="^$" -bench=BenchmarkCompare -benchmem -count=10 . > result.out benchstat -col /parser result.out undefined

Results (lower is faster):

``` Goja ░░░░░░░░░░░░░░░░░░░░░░░░░░░ (9.65% faster) tdewolff ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ (2.37% faster) XJS ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ ```

**How to interpret the results?**

Comparisons are tricky, especially when the tools being compared serve different purposes. Therefore, the results above simply tell us that XJS is fast enough and uses memory and CPU resources in a modest way. Nothing more :)

Contributing

[](https://github.com/xjslang/xjs#contributing)

Help is welcome. The project is still under development, and maintaining a JavaScript parser is a lot of work.

See the open issues at https://github.com/xjslang/xjs/issues.

About

eXtensible JavaScript parser

pkg.go.dev/github.com/xjslang/xjs

Resources

Readme

MIT license

Contributing

Contributing

Activity

Custom properties

Stars

**11** stars

Watchers

**0** watching

Forks

**0** forks

Report repository

Releases

3 tags

Contributors1(1)

- ![Image 2: @gchumillas](https://github.com/gchumillas)**gchumillas**Gonzalo Chumillas

Languages

- Go 99.9%

- Shell 0.1%

Footer

[](https://github.com/) © 2026 GitHub,Inc.

Footer navigation

- Terms

- Privacy

- Security

- Status

- Community

- Docs

- Contact

- Manage cookies

- Do not share my personal information

You can’t perform that action at this time.