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

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

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