首页 | 解释 API
完整导出参考。详细文档请点击链接前往对应 wiki 页面。
| 导出 |
类别 |
说明 |
详情 |
interpretText |
函数 |
解析 DSL 文本 + 一步解释 |
解释 API |
interpretTokens |
函数 |
遍历 token 树并 yield 输出节点 |
解释 API |
flattenText |
函数 |
从 token value 中提取纯文本 |
解释 API |
createRuleset |
辅助 |
恒等函数,提供类型推断 |
解释 API |
fromHandlerMap |
辅助 |
从 handler record 构建 interpret
|
解释 API |
dropToken |
辅助 |
不产生任何输出的 handler |
解释 API |
unwrapChildren |
辅助 |
直接透传子节点的 handler |
解释 API |
wrapHandlers |
辅助 |
给每个 handler 套统一包装 |
解释 API |
debugUnhandled |
辅助 |
将未处理 token 渲染为占位符 |
解释 API |
collectNodes |
辅助 |
Array.from 语法糖 |
解释 API |
| 导出 |
类别 |
说明 |
详情 |
findFirst |
函数 |
DFS——第一个匹配节点 |
结构查询 |
findAll |
函数 |
DFS——所有匹配节点 |
结构查询 |
walkStructural |
函数 |
DFS——带上下文访问每个节点 |
结构查询 |
nodeAtOffset |
函数 |
按偏移量定位最深节点 |
结构查询 |
nodePathAtOffset |
函数 |
从根到最深命中节点的完整路径 |
结构查询 |
enclosingNode |
函数 |
按偏移量定位最深标签节点 |
结构查询 |
| 导出 |
类别 |
说明 |
详情 |
lintStructural |
函数 |
运行规则,返回排序后的诊断 |
Lint |
applyLintFixes |
函数 |
原子化应用可修复的诊断 |
Lint |
| 导出 |
类别 |
说明 |
详情 |
parseSlice |
函数 |
局部重解析 + 位置映射(可选 fullTree 用于 shorthand 回退优化) |
结构切片 |
| 导出 |
类别 |
说明 |
详情 |
toSliceEdit |
函数 |
将 SourceSpan 转为 IncrementalEdit
|
增量语法糖 |
replaceSliceText |
函数 |
按 span 偏移量做纯字符串替换 |
增量语法糖 |
createSliceSession |
函数 |
创建增量 session |
增量语法糖 |
applyIncrementalEditBySpan |
函数 |
对 session 应用 span 编辑 |
增量语法糖 |
| 导出 |
类别 |
说明 |
详情 |
interpretTextAsync |
函数 |
异步解析 + 解释 |
异步解释 API |
interpretTokensAsync |
函数 |
异步 token 树遍历 |
异步解释 API |
fromAsyncHandlerMap |
辅助 |
fromHandlerMap 的异步版 |
异步解释 API |
wrapAsyncHandlers |
辅助 |
wrapHandlers 的异步版 |
异步解释 API |
collectNodesAsync |
辅助 |
收集 AsyncIterable 为数组 |
异步解释 API |
| 类型 |
是什么 |
详情 |
InterpretRuleset<TNode, TEnv> |
传给 interpretTokens 的规则集——createText、interpret、onUnhandled?、onError?
|
解释 API |
InterpretResult<TNode> |
interpret 的返回类型——5 种变体:nodes、text、flatten、unhandled、drop
|
解释 API |
ResolvedResult<TNode> |
InterpretResult 去掉 unhandled——onUnhandled 策略函数的返回类型 |
解释 API |
InterpretHelpers<TNode, TEnv> |
传给 interpret 的对象——interpretChildren、flattenText、env
|
解释 API |
UnhandledStrategy<TNode, TEnv> |
"throw" | "flatten" | "drop" | function——如何处理未处理的 token |
解释 API |
TokenHandler<TNode, TEnv> |
单个同步 handler 函数的简写:(token, helpers) => ResolvedResult
|
解释 API |
TextResult |
{ type: "text"; text: string }——debugUnhandled 回调的返回类型 |
解释 API |
| 类型 |
是什么 |
详情 |
AsyncInterpretRuleset<TNode, TEnv> |
InterpretRuleset 的异步版——interpret 可返回 Promise
|
异步解释 API |
AsyncInterpretResult<TNode> |
和 InterpretResult 类似但 nodes 可以是 AsyncIterable
|
异步解释 API |
AsyncResolvedResult<TNode> |
AsyncInterpretResult 去掉 unhandled
|
异步解释 API |
AsyncInterpretHelpers<TNode, TEnv> |
和 InterpretHelpers 类似但 interpretChildren 返回 AsyncIterable
|
异步解释 API |
AsyncUnhandledStrategy<TNode, TEnv> |
和 UnhandledStrategy 类似但回调可返回 Awaitable
|
异步解释 API |
AsyncTokenHandler<TNode, TEnv> |
异步 handler 函数的简写 |
异步解释 API |
Awaitable<T> |
T | Promise<T>——用于所有异步 API 签名 |
异步解释 API |
| 类型 |
是什么 |
详情 |
ParserLike |
任何有 parse(input, overrides?) 的对象——createParser(...) 满足此接口 |
结构切片 |
ParseOverrides |
ParserLike.parse 的选项——trackPositions、baseOffset、tracker
|
结构切片 |
| 类型 |
是什么 |
详情 |
SliceSession |
有状态增量 session——getDocument、applyEdit、rebuild
|
增量语法糖 |
SliceSessionApplyResult |
applyEdit 的返回值——doc、mode、fallbackReason?
|
增量语法糖 |
| 类型 |
是什么 |
详情 |
StructuralTagNode |
Extract<StructuralNode, { type: "inline" | "raw" | "block" }>——收窄后的标签节点 |
结构查询 |
StructuralVisitContext |
{ parent, depth, index }——predicate 和 visitor 的上下文 |
结构查询 |
StructuralPredicate |
(node, ctx) => boolean——findFirst / findAll 的谓词 |
结构查询 |
StructuralVisitor |
(node, ctx) => void——walkStructural 的访问者 |
结构查询 |
| 类型 |
是什么 |
详情 |
LintRule |
规则接口——id、severity?、check(ctx)
|
Lint |
LintContext |
check 中的上下文——source、tree、report、findFirst、findAll、walk
|
Lint |
LintOptions |
lintStructural 的选项——rules、overrides?、parseOptions?、onRuleError?、failFast?
|
Lint |
Diagnostic |
诊断结果——ruleId、severity、message、span、node?、fix?
|
Lint |
DiagnosticSeverity |
"error" | "warning" | "info" | "hint" |
Lint |
Fix |
自动修复——description、edits: TextEdit[]
|
Lint |
TextEdit |
源码编辑——span: SourceSpan、newText: string
|
Lint |
ReportInfo |
ctx.report() 的参数——Diagnostic 去掉 ruleId,severity 可选 |
Lint |