diff options
| author | Danil-Zaripov <catharsiandev@gmail.com> | 2026-03-06 21:47:22 +0300 |
|---|---|---|
| committer | Danil-Zaripov <catharsiandev@gmail.com> | 2026-03-07 12:51:51 +0300 |
| commit | 4caf4984763dd50d2bcc2f8127296df6587ea891 (patch) | |
| tree | 0226352b3495d7318dd7295d3c6152ae2e489aa8 /src/inpla.y | |
| parent | 28703bd92c53e28ed020c2c24820a14c1c468c57 (diff) | |
| download | inpla-4caf4984763dd50d2bcc2f8127296df6587ea891.tar.gz inpla-4caf4984763dd50d2bcc2f8127296df6587ea891.zip | |
Improve list parsing
The previous algorithm was O(n^2)
Diffstat (limited to '')
| -rw-r--r-- | src/inpla.y | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/inpla.y b/src/inpla.y index 0bdf4b4..bc612f7 100644 --- a/src/inpla.y +++ b/src/inpla.y @@ -195,7 +195,7 @@ static char *Errormsg = NULL; %token INTERFACE IFCE PRNAT FREE EXIT MEMSTAT %token END_OF_FILE USE -%type <ast> body astterm astterm_item nameterm agentterm astparam astparams +%type <ast> body astterm astterm_item nameterm agentterm astparam astparams_rev astparams val_declare rule ap aplist @@ -513,9 +513,13 @@ astparam | '(' astparams ')' { $$ = $2; } ; -astparams +astparams_rev : astterm { $$ = ast_makeList1($1); } -| astparams ',' astterm { $$ = ast_addLast($1, $3); } +| astparams_rev ',' astterm { $$ = ast_addFirst($1, $3); } +; + +astparams +: astparams_rev { $$ = ast_reverseList($1); } ; ap |
