Replies: 4 comments 7 replies
-
I usually define C-Style comments like this: const SingleLineComment = createToken({
name: "SingleLineComment ",
pattern: /\/\/[^\n\r]*/,
group: Lexer.SKIPPED
})
const MultiLineComment = createToken({
name: "MultiLineComment",
pattern: /\/\*[\s\S]*?\*\//,
group: Lexer.SKIPPED
}) Note the |
Beta Was this translation helpful? Give feedback.
-
Thanks @msujew, single-line comments work for me only if I exclude the forward slash from other rules which may be longer.
|
Beta Was this translation helpful? Give feedback.
-
No, it is simply tokenized as But yes, I think I need the longer_alt property, just not sure how to use it |
Beta Was this translation helpful? Give feedback.
-
Sorry, I mistyped the problem case above... It is:
for which, no matter what I try, seems to always token only as |
Beta Was this translation helpful? Give feedback.
-
I'm trying to implement single-line and multi-line C-style comments for my DSL. Is there an example I can look at. I basically want these elements to be skipped by the lexer, without messing up line/column numbers in errors. Thanks
Beta Was this translation helpful? Give feedback.
All reactions