摩纳哥语言匹配空行

Monaco Language Match Empty Line

我正在尝试 create a language definition for the Monaco editor。该语言是一种非常自以为是的语言,我无法控制编译器等

“\”转义字符是通用的;单行注释可以以"\"

结尾继续到下一行

一些示例,使用 C++ 风格的注释:

// This comment \
   continues on the following line

// This one does NOT continue \
   because the escape char was itself escaped

// This one DOES continue because \\
   the 1st '\' escapes the 2nd; the 3rd escapes EOL

// This comment continues to the following line \

But the line was empty. This should not be commented.

我已经实现了除最后一部分之外的所有语义,因为在我看来不可能在空行上进行匹配。我在文档中找到的最接近的是“@eos”,但我不知道如何使用它。这是我当前的实现:

comments: [
  [/\/\/$/, 'comment'], // empty single-line comment
  [/\/\//, 'comment', '@comment_cpp'],
],

comment_cpp: [
  [/(?:[^\]|(?:\.))+$/, 'comment', '@pop'],
  [/.+$/, 'comment'],
],

有没有我可以添加的规则,使我能够在空行上从“@comment_cpp”规则中“@pop”,从而满足以下条件?

// This comment continues to the following line \
   and this one continues to the following empty line \

But this line is not commented

此问题已解决;摩纳哥团队添加了对 /$/.

匹配的支持

https://github.com/microsoft/monaco-editor/issues/1235