Skip to content

Commit

Permalink
Merge pull request #141 from nlmixr2/140-parse-error-for-data-with-ch…
Browse files Browse the repository at this point in the history
…aracter-equality-test

140 parse error for data with character equality test
  • Loading branch information
mattfidler committed Jun 14, 2023
2 parents 3efeebd + 6eaec99 commit d77a962
Show file tree
Hide file tree
Showing 5 changed files with 583 additions and 408 deletions.
2 changes: 2 additions & 0 deletions NEWS.md
@@ -1,5 +1,7 @@
# nonmem2rx (development version)

* Add parsing of accept/ignore characters for example `IGNORE=(C='C')` (See Issue #140)

# nonmem2rx 0.1.1

- Fix internal memory issue (`LTO`, `valgrind` etc)
Expand Down
7 changes: 6 additions & 1 deletion inst/data.g
Expand Up @@ -20,9 +20,14 @@ records_statement: ('RECORDS' | 'Records' | 'records') '='? decimalint;
lrecl_statement: ('LRECL' | 'lrecl' | 'Lrecl') '='? decimalint;
rewind_statement: ('NOREWIND' | 'REWIND' | 'norewind' | 'rewind' | 'Norewind' | 'Rewind');

logic_bracket: '(' (simple_logic)* (',' simple_logic)* ')';
logic_bracket: '(' (simple_logic | quote_logic)* (',' (simple_logic | quote_logic))* ')';
simple_logic: identifier_nm logic_compare (identifier_nm | logic_constant);

char_t1: "\'([^\'\\]|\\[^])*\'";
char_t2: "\"([^\"\\]|\\[^])*\"";

quote_logic: identifier_nm (neq_expression_nm | eq_expression_nm) (char_t1 | char_t2);

logic_compare: eq_expression_nm
| neq_expression_nm
| lt_expression_nm
Expand Down
8 changes: 7 additions & 1 deletion src/data.c
Expand Up @@ -90,6 +90,11 @@ void wprint_parsetree_data(D_ParserTables pt, D_ParseNode *pn, int depth, print_
v[len-1] = 0;
nonmem2rxPushDataFile(v);
return;
} else if (!strcmp("char_t1", name) ||
!strcmp("char_t2", name)) {
char *v = (char*)rc_dup_str(pn->start_loc.s, pn->end);
sAppend(&curLine, "%s", v);
return;
} else if (!strcmp("le_expression_nm", name)) {
sAppendN(&curLine, " <= ", 4);
return;
Expand Down Expand Up @@ -140,7 +145,8 @@ void wprint_parsetree_data(D_ParserTables pt, D_ParseNode *pn, int depth, print_
wprint_parsetree_data(pt, xpn, depth, fn, client_data);
}
}
if (!strcmp("simple_logic", name)) {
if (!strcmp("simple_logic", name) ||
!strcmp("quote_logic", name)) {
nonmem2rxPushDataCond(curLine.s);
sClear(&curLine);
}
Expand Down

0 comments on commit d77a962

Please sign in to comment.