preserving comments #2868
-
Hi! I am trying to parse a language where comments contain annotations which I want to preserve. Now I have:
How can I preserve my |
Beta Was this translation helpful? Give feedback.
Answered by
WillLillis
Feb 11, 2024
Replies: 1 comment 1 reply
-
Would it be possible to define the annotations as a subfield of a comment? Looking at what you currently have in the repo, would something like this work? module.exports = grammar({
name: 'core',
extras: $ => [
/\s/,
$.comment,
],
rules: {
source_file: $ => repeat1($.declaration),
comment: _ => token(choice(
/--.*\n/,
seq('{-', field('annotation', /.*/), '-}'))),
... |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
amaanq
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Would it be possible to define the annotations as a subfield of a comment? Looking at what you currently have in the repo, would something like this work?