Skip to content

Commit

Permalink
Merge pull request #44 from kit494way/fix-parsing-comment
Browse files Browse the repository at this point in the history
Fix parsing of comment
  • Loading branch information
fdncred authored Dec 25, 2023
2 parents bdf1926 + ed68fc8 commit edbb7dd
Show file tree
Hide file tree
Showing 4 changed files with 272 additions and 148 deletions.
98 changes: 98 additions & 0 deletions corpus/comment/comment.nu
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
=====
comment-001-single
=====

# comment

-----

(nu_script
(comment))

=====
comment-002-before-command
=====

# comment
echo hello

-----

(nu_script
(comment)
(pipeline
(pipe_element
(command
(cmd_identifier)
(val_string)))))

=====
comment-003-empty-before-command
=====

#
echo hello

-----

(nu_script
(comment)
(pipeline
(pipe_element
(command
(cmd_identifier)
(val_string)))))

=====
comment-003-end-of-line
=====

echo hello # comment

-----

(nu_script
(pipeline
(pipe_element
(command
(cmd_identifier)
(val_string)))
(comment)))

=====
comment-003-empty-end-of-line
=====

echo hello #

-----

(nu_script
(pipeline
(pipe_element
(command
(cmd_identifier)
(val_string)))
(comment)))

=====
comment-003-empty-end-of-line-before-command
=====

echo hello #
echo world

-----

(nu_script
(pipeline
(pipe_element
(command
(cmd_identifier)
(val_string)))
(comment))
(pipeline
(pipe_element
(command
(cmd_identifier)
(val_string)))))
2 changes: 1 addition & 1 deletion grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -928,7 +928,7 @@ module.exports = grammar({

/// Comments

comment: ($) => seq(PUNC().hash, /.*\n/),
comment: ($) => seq(PUNC().hash, /.*/),
},
});

Expand Down
2 changes: 1 addition & 1 deletion src/grammar.json
Original file line number Diff line number Diff line change
Expand Up @@ -7049,7 +7049,7 @@
},
{
"type": "PATTERN",
"value": ".*\\n"
"value": ".*"
}
]
}
Expand Down
Loading

0 comments on commit edbb7dd

Please sign in to comment.