Merge pull request #251 from susliko/nested-multiline-comments

Nested block comments
text_sliders
eugene yokota 2023-05-27 19:29:16 +07:00 committed by GitHub
commit 8ba8016ae5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 54 additions and 15 deletions

@ -0,0 +1,33 @@
================================================================================
Single line comments
================================================================================
// comment 1
// comment 2
--------------------------------------------------------------------------------
(compilation_unit
(comment)
(comment))
================================================================================
Block comments
================================================================================
/**/
/** comment 1
* /* comment 2
* /* / * * /comment 3 */
// comment 4
* @param
* */
*/
--------------------------------------------------------------------------------
(compilation_unit
(block_comment)
(block_comment
(block_comment
(block_comment)
(comment))))

@ -76,7 +76,7 @@ class C {
(identifier)
(operator_identifier)
(integer_literal)))))
(comment)
(block_comment)
(call_expression
(field_expression
(identifier)
@ -813,7 +813,7 @@ class C {
(identifier)
(identifier))
(comment)
(comment)
(block_comment)
(identifier)))))))
================================================================================
@ -895,6 +895,7 @@ class C {
def main() {
a = b max c
d + e + f
a ** b
}
}
@ -920,6 +921,10 @@ class C {
(operator_identifier)
(identifier))
(operator_identifier)
(identifier))
(infix_expression
(identifier)
(operator_identifier)
(identifier)))))))
================================================================================

@ -27,7 +27,8 @@ module.exports = grammar({
extras: $ => [
/\s/,
$.comment
$.comment,
$.block_comment,
],
supertypes: $ => [
@ -1293,7 +1294,7 @@ module.exports = grammar({
wildcard: $ => '_',
/**
* Regex patterns created to avoid matching // comments.
* Regex patterns created to avoid matching // comments and /* comment starts.
* This could technically match illeagal tokens such as val ?// = 1
*/
operator_identifier: $ => token(choice(
@ -1308,8 +1309,8 @@ module.exports = grammar({
seq(
// opchar
/[\-!#%&*+\/\\:<=>?@\u005e\u007c~\p{Sm}\p{So}]/,
// opchar minus slash
/[\-!#%&*+\\:<=>?@\u005e\u007c~\p{Sm}\p{So}]/,
// opchar minus slash and asterisk
/[\-!#%&+\\:<=>?@\u005e\u007c~\p{Sm}\p{So}]/,
// opchar*
repeat(/[\-!#%&*+\/\\:<=>?@\u005e\u007c~\p{Sm}\p{So}]/),
),
@ -1519,14 +1520,14 @@ module.exports = grammar({
repeat1($.guard),
),
comment: $ => token(choice(
seq('//', /.*/),
seq(
'/*',
/[^*]*\*+([^/*][^*]*\*+)*/,
'/'
)
))
comment: $ => token(seq('//', /.*/)),
block_comment: $ => seq(
token('/*'),
repeat(token(/./)),
token('*/')
),
}
})

@ -4,7 +4,7 @@
SCALA_SCALA_LIBRARY_EXPECTED=94
SCALA_SCALA_COMPILER_EXPECTED=84
DOTTY_COMPILER_EXPECTED=80
DOTTY_COMPILER_EXPECTED=81
SYNTAX_COMPLEXITY_CEILING=2300
if [ ! -d "$SCALA_SCALA_DIR" ]; then