diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2016-10-18 05:41:45 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2016-10-18 05:41:45 -0700 |
commit | f91ef728d1149d7a849d7c818b3fdc03c61847ad (patch) | |
tree | 1114df7103b610538a25a00ea603afc72960daf7 /parser.c | |
parent | b25e08a3328ffa4bf29a8a8651973d88ae79b90c (diff) | |
download | txr-f91ef728d1149d7a849d7c818b3fdc03c61847ad.tar.gz txr-f91ef728d1149d7a849d7c818b3fdc03c61847ad.tar.bz2 txr-f91ef728d1149d7a849d7c818b3fdc03c61847ad.zip |
Detect cycles in rlcp_tree.
This will be required when the parser becomes
capable of creating object graphs with cycles.
* parser.c (parser_callgraph_circ_check): New function.
* parser.h (struct circ_stack): New struct.
(parser_callgraph_circ_check): Declared.
* parser.y (rlcp_tree_rec): New static function.
(rlcp_tree): Reduced to wrapper for rlcp_tree_rec.
Diffstat (limited to 'parser.c')
-rw-r--r-- | parser.c | 10 |
1 files changed, 10 insertions, 0 deletions
@@ -200,6 +200,16 @@ void prime_parser_post(parser_t *p, enum prime_parser prim) p->recent_tok.yy_char = 0; } +int parser_callgraph_circ_check(struct circ_stack *rs, val obj) +{ + for (; rs; rs = rs->up) { + if (rs->obj == obj) + return 0; + } + + return 1; +} + void open_txr_file(val spec_file, val *txr_lisp_p, val *name, val *stream) { enum { none, tl, txr } suffix; |