摩纳哥语言比赛空行

时间:2018-12-12 06:27:31

标签: monaco-editor

我正在尝试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

1 个答案:

答案 0 :(得分:0)

此问题已解决;摩纳哥团队增加了对/$/上的匹配的支持。

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