Skip to content

Commit

Permalink
Optimize pins to build the AST in more cases #191
Browse files Browse the repository at this point in the history
  • Loading branch information
xonixx committed May 11, 2023
1 parent 1fb3d81 commit 37a1ccf
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/main/java/intellij_awk/Awk.bnf
Original file line number Diff line number Diff line change
Expand Up @@ -226,11 +226,14 @@ statement ::= action
| NEXT
| EXIT expr_opt
| RETURN expr_opt
| DO newlines_opt statement newlines_opt WHILE LPAREN expr RPAREN
| statement_do
| SEMICOLON newlines_opt
| simple_statement
| gawk_statement_switch

private statement_do ::= DO newlines_opt statement newlines_opt WHILE LPAREN expr RPAREN
{ pin=1 }

private statement_if ::= IF LPAREN expr RPAREN newlines_opt
statement terminator* [ ELSE newlines_opt statement ]
{ pin=1 }
Expand Down Expand Up @@ -268,10 +271,13 @@ private case_value ::= ([unary_add_sub] NUMBER) | STRING | ERE | TYPED_ERE

private simple_statement_opt ::= simple_statement?

simple_statement ::= DELETE gawk_var_name
simple_statement ::= statement_delete
| expr
| print_statement

private statement_delete ::= DELETE gawk_var_name
{ pin=1 }

print_statement ::= simple_print_statement output_redirection?

simple_print_statement ::=
Expand Down
8 changes: 8 additions & 0 deletions src/test/java/intellij_awk/AwkEnsurePinsTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,14 @@ public void test6() {
checkByText("BEGIN { switch }");
}

public void test7() {
checkByText("BEGIN { do }");
}

public void test8() {
checkByText("BEGIN { delete }");
}

// XXX for some reason fixing below makes it terribly slow or hanging on profile5.awk
/*
public void test3() {
Expand Down

0 comments on commit 37a1ccf

Please sign in to comment.