Skip to content

Commit

Permalink
* and + rules with \n terminator
Browse files Browse the repository at this point in the history
 - Having the `\n` terminator reproduces the exact matching
  as languages such as Java and JavaScript
  • Loading branch information
dvmarcilio committed Dec 2, 2022
1 parent f11f6ef commit 50e4937
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions polyglot/piranha/src/cleanup_rules/go/rules.toml
Original file line number Diff line number Diff line change
Expand Up @@ -342,11 +342,11 @@ query = """
(
(block
(statement_list
(_)* @pre
(block
(((_) "\\n"?)* @pre)
((block
(statement_list) @nested.statements
) @nested.block
(_)* @post
) @nested.block)
(((_) "\\n"?)* @post)
) @outer.stmt_list
) @outer.block
)
Expand All @@ -355,7 +355,7 @@ replace = "@nested.statements"
replace_node = "nested.block"

# This rule is not deleting multiple statements after return.
# `(statement)+ @post` is only matching the first statement
# Although `(((statement) "\\n"?)+ @post)` matches all post statements, replacing is only happening for the first one.
# Thus, we are using a self-edge to keep removing statements.
#
[[rules]]
Expand All @@ -364,9 +364,9 @@ query = """
(
(block
(statement_list
((statement)* @pre)
(((statement) "\\n"?)* @pre)
((return_statement) @r)
((statement)+ @post)
(((statement) "\\n"?)+ @post)
) @stmt_list
) @b
)
Expand Down

0 comments on commit 50e4937

Please sign in to comment.