31 个仓库
Tools for modifying and rewriting syntax trees to generate new code structures.
Distinct from Syntax Tree Construction: Focuses on the mutation and transformation of the tree nodes rather than the initial construction of the tree.
Explore 31 awesome GitHub repositories matching software engineering & architecture · Syntax Tree Transformers. Refine with filters or upvote what's useful.
This project is a unified toolchain for JavaScript and TypeScript development, providing a suite of specialized tools for bundling, parsing, linting, and formatting source code. The toolchain is implemented in Rust and utilizes a shared internal representation to allow multiple tools to operate on the same parsed source code. It employs a parallelized analysis pipeline and single-pass parsing with error recovery to process files across CPU cores. The suite covers several core capability areas, including static analysis for identifying programmatic errors, automated style standardization, and
Implements tools for modifying and rewriting syntax trees to perform linting and formatting tasks.
oxc is a high-performance JavaScript toolchain developed in Rust for parsing, transforming, and analyzing JavaScript and TypeScript source code. It provides a set of core utilities including a parser that converts code into an abstract syntax tree, a linter for identifying problematic patterns, a formatter for standardizing visual style, and a minifier for reducing production file sizes. The project focuses on high-performance execution through a system design that utilizes single-pass parsing, zero-copy string slicing, and parallel worker processing to handle large codebases. It further opti
Implements a biphasic system that separates syntax tree analysis from code generation to optimize transformation speed.
CoffeeScript is a source-to-source transpiler that transforms a concise high-level syntax into standard JavaScript. It enables the development of logic for web applications and server-side environments by converting source code into a format compatible with browsers and server runtimes. The project provides a workflow for rapid prototyping and script execution automation, allowing users to run source files through a compiler and execute the resulting code immediately without a manual build step. The tooling leverages lexical analysis and abstract syntax tree transformations to manipulate cod
Implements syntax tree transformers to rewrite language constructs into JavaScript.
Prepack is a build-time code evaluator and JavaScript bundle optimizer. It functions as a static analysis compiler that pre-evaluates static code and precalculates function results and global assignments during the build phase to accelerate startup times and reduce bundle size. The project specifically targets JSX optimization by processing syntax and node serialization to improve user interface rendering efficiency. It utilizes a partial evaluation engine and static execution analysis to replace runtime computations with precalculated constants. The tool covers a range of capabilities inclu
Implements syntax tree transformations to inline expressions and strip type annotations during the build process.
YAPF 是一个 Python 代码格式化程序和样式合规工具。它作为一个基于 AST 的重格式化程序运行,使用具体语法树来确保源文件之间的结构一致性和统一的视觉呈现。 该引擎利用基于惩罚的布局优化器,通过计算不同格式化选择的数值成本来确定最佳换行符。它采用多进程代码处理器将多个文件的格式化分布到多个 CPU 核心上。 该工具涵盖了通过就地文件修改、差异分析和处理部分代码片段进行的源代码重格式化。它包括一个用于管理样式预设、布局规则和项目级设置的基于规则的配置系统。 集成能力包括用于持续集成流水线的样式合规验证、Git 钩子自动化以及基于编辑器的保存时格式化功能。
Reconstructs source code by modifying concrete syntax tree representations while preserving the original structural integrity.
AST Explorer 是一个基于 Web 的工具,用于将源代码解析为抽象语法树并可视化生成的树结构。它作为一个代码检查器和转换游乐场,允许用户通过交互式浏览器界面探索各种编程语言的结构表示。 该工具提供了一个转换环境,用户可以在其中应用修改规则来解析树,以测试代码修改逻辑。它具有双向映射功能,随着光标在编辑器中移动,可以同时突出显示匹配的树节点和源文本。 该平台支持通过文件上传或拖放界面导入代码,并允许通过状态编码的 URL 共享特定的代码状态和解析器配置。
Provides a pipeline for applying modification functions to a syntax tree to rewrite the underlying code.
SWIG is a tool that generates wrapper code to expose C and C++ libraries to a wide range of higher-level programming languages. It reads annotated C/C++ header files and produces language-specific bindings from a single interface definition, supporting languages such as Python, Java, Ruby, C#, Perl, and many others. The generated wrapper code is free from the project's GPL license, allowing users to distribute it under their own terms. The tool handles modern C++ features including templates, namespaces, smart pointers, and constructs up to C++20 through specialized parsing and code generatio
Builds an internal parse tree from C/C++ source and transforms it into target language bindings.
ts-morph is a TypeScript AST manipulation library and a high-level wrapper for the TypeScript compiler API. It provides a programmatic interface for analyzing, modifying, and generating TypeScript source code, serving as a tool for automated code refactoring and source code generation. The library simplifies the process of navigating and inspecting project structures by offering an object-oriented abstraction over the underlying compiler API. It allows for the programmatic transformation of existing codebases to automate structural updates and bulk code migrations. Its capabilities cover sta
Provides tools for modifying and rewriting TypeScript syntax trees to generate new code structures.
Lark 是一个 Python 解析工具包,用于定义语法并将原始文本转换为带注释的解析树。它作为一个抽象语法树生成器和语法定义语言,用于通过终结符和正则表达式指定语言规则。 该库提供两种主要的解析实现:一种是能够处理所有上下文无关语言(包括具有歧义和左递归的语言)的 Earley 解析库;另一种是专为具有低内存开销的确定性语言设计的高性能 LALR 解析库。 除了核心解析外,该工具包还包括模块化语法组合、基于规则的树转换以及源位置坐标跟踪功能。它还支持将 LALR 语法序列化为独立的解析器模块。
Uses a visitor-pattern mechanism to transform parse trees into custom data structures via specific grammar branch mappings.
ts-migrate is an automated migration tool designed to transform JavaScript source code into compiling TypeScript files. It functions as a code migration framework that uses abstract syntax trees to perform large-scale refactoring and structural changes across a project. The tool provides a customizable framework for defining plugin-based transformation rules, allowing for the automation of specific code changes. It includes specialized engines for converting JSDoc type definitions into native TypeScript annotations and a utility for suppressing compiler errors by inserting type assertions or
Modifies syntax trees to reorganize class members and apply accessibility modifiers.
Hy 是 Python 的一种 Lisp 实现,允许编写编译为 Python 字节码的 Lisp 语法。它作为一种基于 Python 的 Lisp 方言和 S 表达式语言运行,提供对 Python 标准库和生态系统的完全访问权限。 该语言专注于基于宏的元编程,具有 AST 遍历宏系统和读取器宏,允许自定义语法转换和解析规则。它能够操纵抽象语法树以扩展语言功能。 该项目包括一个用于交互式开发的读取-求值-打印循环(REPL),并支持独立脚本执行。它涵盖了函数式编程功能,例如结构化模式匹配以及使用 async 和 await 构造的异步程序开发。 源代码可以转换为等效的 Python 源文件以供检查或分发。
Provides a macro system for creating custom syntax transformations that modify the abstract syntax tree.
Recast 是一个 JavaScript AST 解析器和打印机,专为自动化代码重构而设计。它将源代码转换为抽象语法树,这些树可以被修改,然后打印回源代码。 该项目专注于保持格式的转换,在语法树节点中存储原始空格和缩进元数据,以在不丢失原始布局的情况下重构代码。它还生成字符级源映射,以保持原始输入和转换输出之间的精确对应关系。 该工具包包括使用访问者模式(visitor pattern)进行语法树操作的实用程序,以及用于通用样式美化打印的选项。它提供了一个命令行界面,用于在目标文件上执行这些转换函数并将结果写入磁盘。
Provides tools for modifying and rewriting syntax trees to perform complex code transformations.
Poi 是一个可扩展、零配置的模块打包器与资产编译器,适用于现代前端开发。它作为一个构建系统,将 JavaScript、JSX 与 CSS 转换为浏览器兼容的文件,并将它们组合成用于 Web 交付的单一包。 该工具围绕插件架构构建,允许对构建流水线进行自定义扩展,并添加专门的资产处理逻辑。它采用基于约定的映射系统来自动化构建设置与目标输出,无需手动配置文件。 该项目涵盖了广泛的打包能力,包括前端框架编译、自动资产解析以及静态文件处理。它利用抽象语法树(AST)转换来实现源代码的程序化修改与框架特定的编译。
Implements syntax tree transformations to enable programmatic modification and framework-specific compilation of source code.
Unified 是一个语法树处理引擎和内容生态系统,旨在解析、转换和序列化文本内容。它作为一个基于插件的内容流水线,利用纯 JavaScript 对象将原始文本转换为结构化的抽象语法树,以便进行程序化的检查和修改。 该项目通过模块化架构脱颖而出,支持跨生态系统转换,允许在 HTML 和 Markdown 等不同规范之间转换语法树。它利用不可变处理器克隆和共享状态容器系统,确保处理流水线可以在不更改原始配置的情况下进行扩展和定制。 该系统提供了全面的语法树管理功能,包括深度优先遍历、基于 CSS 的节点选择和递归转换。其处理范围涵盖自然语言分析、GitHub Flavored Markdown 解析,以及将语法树映射到虚拟 DOM 元素以进行浏览器可视化。 处理逻辑可以通过模块打包器或 CDN 集成到 Web 应用程序中。
Runs sequences of plugins to modify or analyze syntax trees before serialization.
TSDoc 是一个用于在 TypeScript 代码中编写结构化注释的文档标准和规范。它提供了一个可移植的系统,用于在源代码中定义元数据、标签和交叉引用,以确保在不同工具链之间实现一致的解析和渲染。 该项目包含一个文档注释解析器,可将注释转换为结构化语法树,以及一个强制执行语法一致性的验证器。它允许通过外部配置文件定义自定义文档标签,并支持多种语法验证模式以协助规范合规性。 该规范涵盖了广泛的 API 文档需求,包括标记发布阶段、稳定性和弃用状态。它支持详细说明函数参数、返回值和异常类型,以及管理内部可见性、继承和声明之间的交叉引用。
Converts structured syntax trees back into plain text comments to allow for automated modification of source code.
Lost 是一个 CSS 网格系统和 PostCSS 插件,旨在通过数学计算定义列宽和位置,以实现响应式屏幕设计。它作为一个构建时工具,将自定义网格规则处理为浏览器兼容的 CSS 布局。 该框架将非标准布局声明转换为原生的 CSS Grid 和 Flexbox 属性。它使用基于 PostCSS 的流水线来计算精确的坐标和列宽,确保生成的样式与标准 Web 浏览器兼容。 该项目作为与预处理器无关的中间件层运行,允许它处理样式,无论源文件是纯 CSS、Sass 还是 Less。它自动化生成响应式网格结构,根据屏幕尺寸调整元素大小和位置。
Implements a PostCSS-based transformation of the CSS abstract syntax tree to modify layout properties.
Myth 是一个 CSS 构建工具和预处理器,将现代样式规范和未来语法转换为当前 Web 浏览器兼容的代码。它充当 Polyfill 工具,将高级功能转换为标准 CSS,以确保一致的跨浏览器渲染。 该项目基于浏览器支持数据提供自动化的厂商前缀添加,并将 CSS 变量解析为静态值以实现遗留浏览器兼容性。它还处理自定义媒体查询别名的转译,并将高级颜色函数转换为标准格式。 该工具集包括用于样式表编译的命令行界面,具有用于压缩的输出压缩功能和用于调试的源映射生成功能。它进一步支持构建时数学计算和文件更改监控,以自动化处理流水线。
Uses an abstract syntax tree to transform modern CSS specifications into browser-compatible code.
pyupgrade 是一个 Python 静态代码现代化工具和语法升级器。它自动重写源代码,以根据指定的版本目标实现现代语言特性和语法。 该工具专注于通过删除已弃用的导入、兼容性垫片和过时的特定版本条件块来消除技术债务。它还重构类型注解以使用当前标准,例如简化的泛型别名和联合运算符。 其能力范围包括更新标准库使用、优化内置函数调用,以及将冗长的集合构造函数或字符串格式化转换为简洁的现代等价物。这些转换通过一个目标版本化的规则引擎执行,该引擎保留了原始格式和注释。
Implements transformations on concrete syntax trees to ensure that original source formatting and comments are preserved during rewriting.
csso is a CSS minifier and optimizer that reduces stylesheet file sizes through structural analysis and algebraic transformations. It functions as an abstract syntax tree processor, converting styles into a structured tree to perform deep analysis and semantic-preserving code transformations while maintaining the original visual presentation. The project distinguishes itself through usage-aware optimization, analyzing external HTML markup and class identifiers to prune unused styles and reorganize rules based on actual document usage. It also performs structural refactoring by identifying and
Implements a transformation system that modifies the CSS abstract syntax tree to optimize style rules.
unplugin-auto-import is a build-time import automation plugin and AST-based code transformer. It analyzes source code to identify missing identifiers and automatically injects the required import statements during the bundling process. The project functions as a cross-bundler build plugin, providing a unified abstraction layer that ensures consistent behavior across Vite, Webpack, and Rollup. It utilizes a pattern-based module resolver to scan local directories via glob patterns and employs a TypeScript declaration generator to maintain type definition files for IDE autocompletion. Its capab
Parses source code into a structural tree to identify missing identifiers and inject import statements.