【问题标题】:Add a Pascal rule on ACE web editor在 ACE Web 编辑器上添加 Pascal 规则
【发布时间】:2017-05-03 14:25:20
【问题描述】:

我正在使用 ACE Web 编辑器以帕斯卡语言进行编码,并且想在 mode-pascal.js 原生文件中添加规则。

我想要的是在所有以“property”开头并以“;”结尾的行中突出显示所有“read”和“write”关键字。

类似:

property Lala : Integer read (123) write (456);

但不是:

var read := "write"; 

而使用 ACE...我只需要一个正则表达式就可以做到这一点,很有趣。

如果有人有想法,它可以挽救生命!

【问题讨论】:

  • 所以你想用读写字选择整行?
  • 单个正则表达式是不可能的(如果不是 .NET 或 PyPi 正则表达式)。
  • @Rahul 只是“读”和“写”,而不是整行,可以有好几行。
  • @WiktorStribiżew 我也认为,也许可以手动完成,但我在 ACE 文档中找不到方法。
  • 是的,这就是为什么这个问题对于 SO 来说太宽泛、离题了。

标签: javascript regex editor ace-editor


【解决方案1】:

Ace 语法高亮支持类似于 textmate 和 sublime 的状态。 这意味着您可以匹配property 关键字,并切换到突出显示readwrite 的状态,如下所示:

[
...
{
   regex: /property\b/
   token: "keyword",
   next: [
       {
           regex: /(read|write)\b/
           token: "keyword",
       },
       { include: "start" }, // include other rules if you want
       {
           regex: "$|;", 
           token: "text",
           next: "start" // exit the property state on line end or ;
       }
   ]
}
...

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-01-14
    • 1970-01-01
    • 1970-01-01
    • 2014-04-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多