jEdit 自定义模式下的多行正则表达式
我目前正在与朋友一起创建一种语言,我想在 jEdit 中为其提供突出显示。 它的语法实际上非常简单。函数只能匹配此模式: $function_name(arguments)
请注意,我们的解析器当前正在工作,没有像 C 样式半列那样的结束标记,我们希望保留此功能。
我创建了 jEdit 模式,并且(几乎)成功地使用
突出显示了我的模式。我是这样做的:
但这还不够好。
这就是我想要的:
- 整个函数骨架的颜色相同:
$func( )
- 特别突出显示(已在
ARGS
规则集中定义)%content1%
in$func(%content1%)
- 不高亮显示不跟在
$func
后面的括号 - 授权替代多行语法,如
$func
(
args
)
目前尚未突出显示。 我猜我需要更改我的
正则表达式以接受换行符,但似乎 jEdit 无法匹配多行正则表达式来突出显示,尽管他完美地完成了 search&replace !
我尝试了 (?s)
和 (?m)
标志、[\d\D]*
解决方法,甚至 [ \r\n]*
但它永远不起作用。
所以,这是我的问题:
- 有谁知道如何在 jEdit 模式
中匹配多行正则表达式? - 如果没有,有人知道如何做我需要的事情吗?
I'm currently creating a language with a friend and I would like to provide a highlighting for it in jEdit.
It's syntax is actually quite simple. The functions can only match this pattern:$function_name(arguments)
Note that our parser is currently working without closing tag like the C-style semi-column and that we would like to keep this feature.
I created my jEdit mode and (almost) succeeded in highligting my pattern with <SPAN_REGEXP>
. Here's how I did it:
<SPAN_REGEXP HASH_CAR="\$" TYPE="KEYWORD3" DELEGATE="ARGS">
<BEGIN>\$[A-Za_z0-9_]*\s*\(</BEGIN>
<END>)</END>
</SPAN_REGEXP>
But It's not good enough.
Here's what I would like:
- Same color for the entire function skeleton :
$func( )
- Special highlighting (already defined within the
ARGS
rules set) for%content1%
in$func(%content1%)
- No highlighting for brackets not following a
$func
- Authorize alternative multiline syntax like
$func
(
args
)
which is for now not highlighted.
I guessed I needed to change my <BEGIN>
regexp to accept newlines, but it seems that jEdit is unable to match multiline regexp for highlighting although he does it perfectly for search&replace !
I tried the (?s)
and (?m)
flags, the [\d\D]*
workaround, even [\r\n]*
but it never works.
So, here are my questions:
- Does anyone know how to match multiline regexp in jEdit modes
<SPAN_REGEXP>
? - If not, does anyone have any idea how to do what I need ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如帮助中所述,SPAN_REGEXP 不支持多行正则表达式。您当然可以指定多行正则表达式,但它们仅针对单独的行进行检查,因此永远不会匹配。如果还没有功能请求,您可以将功能请求发布到 jEdit 的功能请求跟踪器。
As stated in the help, the SPAN_REGEXP does not support multi-line regexes. You can of course specify multi-line regexes, but they are only checked against individual lines and thus will then never match. You could post a Feature Request to the Feature Request Tracker of jEdit though if there is none for it yet.