Custom Grammar with Special Characters


#1

I was trying to create a custom grammar for the PLC Structured Text language. The first thing I tried to do was to set the rules for highlighting the comments.
The comments are written as (*COMMENTS*)

In my config.cson for the package, I used the following:

‘fileTypes’: [‘plc’]
‘name’: ‘PLC Structured Text’
‘patterns’: [
{
‘begin’ : ‘\(\
‘end’ : '\
\)’
‘name’ : ‘comment.plc.structured.text’
}
]
‘scopeName’: ‘source.plc’

However, this gives me the following error when I try to load the grammar on a .plc file:
Error: target of repeat operator is not specified
at Error (native)
at Scanner.module.exports.Scanner.createScanner

substituting the begin and end values for ‘~’ provides no problems and works as expected in commenting lines such as: ~COMMENT~

I have a feeling this has something to do with that I am trying to use special characters. However I did cancel them in the code, so a little bit puzzled as to how I can get this to work, if at all…


#2

I believe that special characters in grammars should be doubly escaped, e.g. \\*


#3

That did the trick, thanks!