diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2015-02-15 18:27:58 -0800 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2015-02-15 18:27:58 -0800 |
commit | c554153d3fe9a21e57854d3174e2804adfb22f00 (patch) | |
tree | de34fa225a1118767dceb0b90f5ec070a0db8cbf /regex.c | |
parent | 289c8aec7ecdf837ae5ba01987ec3f34e3307b78 (diff) | |
download | txr-c554153d3fe9a21e57854d3174e2804adfb22f00.tar.gz txr-c554153d3fe9a21e57854d3174e2804adfb22f00.tar.bz2 txr-c554153d3fe9a21e57854d3174e2804adfb22f00.zip |
* regex.c (print_rec): A compound must use parentheses for
elements which have a higher precedence than catenation.
Diffstat (limited to 'regex.c')
-rw-r--r-- | regex.c | 10 |
1 files changed, 8 insertions, 2 deletions
@@ -1773,8 +1773,14 @@ static void print_rec(val exp, val stream) } put_char(chr(']'), stream); } else if (sym == compound_s) { - while (args) - print_rec(pop(&args), stream); + for (; args; args = cdr(args)) { + val arg = car(args); + if (consp(arg) && car(arg) != zeroplus_s && car(arg) != oneplus_s && + car(arg) != optional_s && car (arg) != compound_s) + paren_print_rec(arg, stream); + else + print_rec(arg, stream); + } } else if (sym == zeroplus_s || sym == oneplus_s || sym == optional_s) { val arg = pop(&args); if (consp(arg) && car(arg) != set_s && car(arg) != cset_s) |