Sublime Forum

Syntax Hightlight for Comments inside Comments

#1

Hello guys, i’m new in this forum. I’m working with an old language called Progress ABL and this language have some peculiarities… One of them (which i’m racking their brains) is related to multi comments (one comment inside another).

Please don’t ask me why old guys used to do this, but since the old editor supports this, we need to “implement” this feature in our Sublime.

This is what we have today:

procedure test
  /*
    normal comment  /* comment inside comment */
  */
  return true.
end.

This is our ABL.tmLanguage inside patterns region:

<dict>
	<key>begin</key>
	<string>/\*</string>
	<key>end</key>
	<string>\*/</string>
	<key>name</key>
	<string>comment.block.source.abl</string>
</dict>

Do you have any ideas how can we make Sublime highlight the comments properly?

Thanks,
Augusto.

0 Likes

#2

I’m using YAML syntax here for better readability (check out docs.sublimetext.info/en/latest/ … xdefs.html), but bascially you want to include the comment pattern inside the comment pattern, so that they can be nested and are consumed. For that reason, it has to be defined in the repository for recursive application.

[code]# [PackageDev] target_format: plist, ext: tmLanguage

name: Syntax Name
scopeName: source.syntax_name
fileTypes: ]
uuid: 655f06c4-ad07-4ae5-a295-c2263ea30e46

patterns:

  • include: ‘#comments

repository:
comments:
name: comment.block.source.abl
begin: /*
end: */
patterns:
- include: ‘#comments
…[/code]

0 Likes