# sweet-js/sweet-core

**Attribution required: if you use, quote, or summarise this content, you must credit and link back to [awesome-repositories.com](https://awesome-repositories.com/repository/sweet-js-sweet-core).**

4,559 stars · 210 forks · JavaScript · BSD-2-Clause · archived

## Links

- GitHub: https://github.com/sweet-js/sweet-core
- Homepage: https://www.sweetjs.org
- awesome-repositories: https://awesome-repositories.com/repository/sweet-js-sweet-core.md

## Topics

`javascript` `macros` `parser`

## Description

Sweet-core is a JavaScript source-to-source compiler and Lisp-style macro system. It functions as a syntax transformer that extends JavaScript by allowing the definition of custom syntax and operators during the compilation process.

The system provides a framework for building domain-specific languages through hygienic, recursive macro expansion and the creation of new language constructs. It distinguishes itself by supporting custom operator definitions with configurable associativity and precedence to control expression evaluation.

The compiler includes a specialized module system for managing compile-time dependencies and runtime helper integration. Its internal architecture covers abstract syntax tree transformation, grammar production matching, and syntax object generation to ensure lexical hygiene.

A command line interface is provided to transform source files into standard JavaScript output files or directories.

## Tags

### Programming Languages & Runtimes

- [Macro Compilers](https://awesome-repositories.com/f/programming-languages-runtimes/javascript-compilers/macro-compilers.md) — Functions as a JavaScript macro compiler that extends the language with custom syntax and operators during compilation.
- [Custom Macro Definitions](https://awesome-repositories.com/f/programming-languages-runtimes/language-features-paradigms/metaprogramming-macros/custom-macro-definitions.md) — Provides the ability to create named macros that transform specific code patterns into new syntax. ([source](https://www.sweetjs.org/browser/editor))
- [Recursive Macro Definitions](https://awesome-repositories.com/f/programming-languages-runtimes/language-features-paradigms/metaprogramming-macros/custom-macro-definitions/recursive-macro-definitions.md) — Supports recursive macros by binding transformers to names available within their own definitions. ([source](http://sweetjs.org/doc/1.0/reference.html))
- [Hygienic Macro Systems](https://awesome-repositories.com/f/programming-languages-runtimes/language-features-paradigms/metaprogramming-macros/hygienic-macro-systems.md) — Implements a hygienic macro system that tracks lexical contexts to prevent identifier collisions during expansion.
- [Macro Expansion Engines](https://awesome-repositories.com/f/programming-languages-runtimes/language-features-paradigms/metaprogramming-macros/hygienic-macro-systems/macro-expansion-engines.md) — Features a macro expansion engine that supports recursive calls, allowing syntax transformers to process nested constructs.
- [Domain Specific Languages](https://awesome-repositories.com/f/programming-languages-runtimes/programming-language-varieties/domain-specific-languages.md) — Enables the development of domain-specific languages by extending JavaScript with custom grammar and syntax rules.
- [JavaScript Source Transformers](https://awesome-repositories.com/f/programming-languages-runtimes/source-code-compilers/source-code-templates/source-code-transformation-engines/javascript-source-parsers/javascript-source-transformers.md) — Acts as a JavaScript source transformer that creates new language constructs and operators via macros.
- [Hygienic Syntax Generation](https://awesome-repositories.com/f/programming-languages-runtimes/syntax-extensions/hygienic-syntax-generation.md) — Creates identifiers, literals, keywords, and delimiters while maintaining lexical contexts to ensure code hygiene. ([source](http://sweetjs.org/doc/1.0/reference.html))
- [Compile-Time Macro Dependency Management](https://awesome-repositories.com/f/programming-languages-runtimes/compile-time-macro-dependency-management.md) — Implements a system for importing runtime code or other macros into the compile-time environment. ([source](https://www.sweetjs.org/doc/tutorial))
- [Compile-Time Module Bindings](https://awesome-repositories.com/f/programming-languages-runtimes/compile-time-module-bindings.md) — Provides a specialized module system to load macro definitions and runtime helpers into the compiler environment.
- [Compile-Time Runtime Integration](https://awesome-repositories.com/f/programming-languages-runtimes/compile-time-runtime-integration.md) — Implements a mechanism for loading runtime code and utility functions into the compile-time environment for use within macro definitions. ([source](http://sweetjs.org/doc/1.0/tutorial.html))
- [Operator Binding Definitions](https://awesome-repositories.com/f/programming-languages-runtimes/custom-operator-implementations/operator-binding-definitions.md) — Allows the definition of custom operators with specific precedence and associativity to control expression evaluation. ([source](http://sweetjs.org/doc/1.0/tutorial.html))
- [Macro Definition Exports](https://awesome-repositories.com/f/programming-languages-runtimes/module-export-and-import-systems/macro-definition-exports.md) — Provides specialized module directives to share custom syntax definitions and compile-time bindings across multiple files. ([source](http://sweetjs.org/doc/1.0/tutorial.html))
- [Recursive Grammar Matching](https://awesome-repositories.com/f/programming-languages-runtimes/recursive-grammar-matching.md) — Groups multiple syntax objects by matching them against specific grammar rules during the expansion process. ([source](https://www.sweetjs.org/doc/tutorial))
- [Syntax Object Unwrapping](https://awesome-repositories.com/f/programming-languages-runtimes/syntax-object-unwrapping.md) — Unwraps syntax objects to retrieve underlying primitive representations like strings or numbers for logic processing. ([source](http://sweetjs.org/doc/1.0/reference.html))

### Software Engineering & Architecture

- [Compile-Time Code Generation](https://awesome-repositories.com/f/software-engineering-architecture/compile-time-code-generation.md) — Automates the production of JavaScript code by manipulating syntax objects and expanding macros at build time.
- [Abstract Syntax Tree Transformations](https://awesome-repositories.com/f/software-engineering-architecture/compile-time-code-generation/compile-time-hooks/abstract-syntax-tree-transformations.md) — Implements abstract syntax tree transformations to convert raw syntax objects into new structures during the compilation process.
- [Macro-Driven Transformations](https://awesome-repositories.com/f/software-engineering-architecture/compile-time-code-generation/macro-driven-transformations.md) — Supports advanced macro-driven transformations for implementing custom language features and recursive syntax transformers.
- [Operator Precedence Management](https://awesome-repositories.com/f/software-engineering-architecture/operator-precedence-management.md) — Provides a custom operator precedence table to define the evaluation order and grouping of new language symbols.
- [Call-Site Parsing](https://awesome-repositories.com/f/software-engineering-architecture/syntax-parsing-engines/call-site-parsing.md) — Iterates through source code at the macro invocation site to match specific grammar productions like expressions. ([source](http://sweetjs.org/doc/1.0/reference.html))
- [Compile-Time Syntax Analysis](https://awesome-repositories.com/f/software-engineering-architecture/syntax-tree-analysis/syntax-inspection/compile-time-syntax-analysis.md) — Analyzes code structure at compile time by identifying keywords and iterating through nested delimiters. ([source](https://www.sweetjs.org/doc/tutorial))

### Development Tools & Productivity

- [Compiler Command Line Interfaces](https://awesome-repositories.com/f/development-tools-productivity/compiler-command-line-interfaces.md) — Ships a command line interface for executing the compilation process on source files and directories. ([source](https://www.sweetjs.org/doc/reference))
- [File Output Managers](https://awesome-repositories.com/f/development-tools-productivity/file-output-managers.md) — Provides capabilities to write the results of macro expansion to specific files or directories via the CLI. ([source](http://sweetjs.org/doc/1.0/reference.html))
