如何嵌入内联C++另一种语言定义中的语法?
我有一个 Sublime Text 3 的自定义 Perl 语法文件,我想添加对嵌入式 C++ 代码的突出显示支持。
在 Perl 代码中,内联 C++
代码始终以 __CPP__
开头,并以 __END__
结束。
我正在使用“嵌入/匹配/转义”方法,但 C++ 代码的语法高亮不会改变(使用 ctrl-alt-shift-p 获取范围,它仍然显示为 source.perl
)。
这是我在语法文件中使用的规则:
contexts:
main:
- include: inline-cpp
...lot of rules...
inline-cpp:
- match: '__CPP__'
embed: scope:source.c++
embed_scope: source.c++.embedded
escape: '__XXX__'
请有人帮助我找出我做错了什么?
I have a custom Perl syntax file for Sublime Text 3 and I would like to add an highlighting support for embedded C++ code.
The inline C++
code always starts with __CPP__
and ends with __END__
among the perl code.
I'm using the 'embed/match/escape' approach but the syntax highliting of the C++ code won't change (getting the scope with ctrl-alt-shift-p it still appears as source.perl
).
Here the rule I'm using in my syntax file:
contexts:
main:
- include: inline-cpp
...lot of rules...
inline-cpp:
- match: '__CPP__'
embed: scope:source.c++
embed_scope: source.c++.embedded
escape: '__XXX__'
Please could someone help me figure out what I'm doing wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
解决了将
include
放在prototype
部分而不是main
中的问题:Solved putting the
include
inprototype
section instead ofmain
: