我正在尝试更新我的语言的注册,并且根据新规范,我需要定义大纲视图和摘要视图
这里是 pico dsl 的示例项目文件在这里和语言规范(我假设)在这里
module lang::pico::LanguageServer
import util::LanguageServer;
import util::IDEServices;
import ParseTree;
import util::Reflective;
import lang::pico::\syntax::Main;
import IO;
// a minimal implementation of a DSL in rascal
// users can add support for more advanced features
set[LanguageService] picoContributions() = {
parser(parser(#start[Program])), // register the parser function for the Pico language
outliner(picoOutliner),
summarizer(picoSummarizer, providesImplementations = false)
};
// we build a simple outline based on the grammar
list[DocumentSymbol] picoOutliner(start[Program] input)
= [symbol("<input.src>", DocumentSymbolKind::\file(), input.src, children=[
*[symbol("<var.id>", \variable(), var.src) | /IdType var := input]
])];
// normally you would import the typechecker and run it here
// for brevity we've inlined the implementation here
Summary picoSummarizer(loc l, start[Program] input) {
rel[str, loc] defs = {<"<var.id>", var.src> | /IdType var := input};
rel[loc, str] uses = {<id.src, "<id>"> | /Id id := input};
rel[loc, str] docs = {<var.src, "*variable* <var>"> | /IdType var := input};
return summary(l,
messages = {<src, error("<id> is not defined", src)> | <src, id> <- uses, id notin defs<0>},
references = (uses o defs)<1,0>,
definitions = uses o defs,
documentation = (uses o defs) o docs
);
}
// run this from a REPL while developing the DSL
int main() {
// we register a new language to Rascal's LSP multiplexer
// the multiplexer starts a new evaluator and loads this module and function
registerLanguage(
language(
pathConfig(srcs=[|project://pico-dsl-lsp/src/main/rascal|]),
"Pico", // name of the language
"pico", // extension
"lang::pico::LanguageServer", // module to import
"picoContributions"
)
);
return 0;
}
我正在尝试为我的语言构建一个 Outliner 和 Summarizer(AST 这里)。
data Pipeline
= pipeline(
Alphabet alphabet,
Options options,
list[Module] modules,
list[Constraint] constraints,
list[Handler] handlers
);
data Alphabet
= alphabet(
list[SymbolInfo] symbols);
这是到目前为止我所拥有的大纲,我无法找到有关其结构的更多文档:
list[DocumentSymbol] ldOutliner(start[Pipeline] pipeline) {
return [
symbol("Pipeline", DocumentSymbolKind::Namespace, pipeline.src, children=[
*[symbol("Alphabet"
{...}
]
])
];
}
另外,贡献样式定义如下,现在如何定义样式?
Contribution STYLE =
categories
(
(
"Name" : {bold()},
"String" : {foregroundColor(color("purple"))},
"Boolean" : {foregroundColor(color("DarkRed"))},
"ColorCode" : {foregroundColor(color("Violet"))},
"Character" :{foregroundColor(color("dimgray"))},
"ConstraintKeywords" :{foregroundColor(color("Olive"))},
"Integer" : {foregroundColor(color("orange")), bold()}
)
);
如有任何帮助,我们将不胜感激,谢谢!
()
。这使得它成为对函数的引用而不是数据类型的实例。可能是这个错误打印在与您正在查看的视图不同的视图中!