From 0887c4d577545e47820df4389b5be81fe2fee0c3 Mon Sep 17 00:00:00 2001 From: Adrian Thurston Date: Sun, 3 Jan 2021 20:41:50 -0800 Subject: various refcount fixes - added downref when undoing a tree push - using correct opcode for undoing pushing stream - added an upref when sending back ignored trees --- test/colm.d/balance1.lm | 33 +++++++++++++++++++++++++++++++++ test/colm.d/balance2.lm | 38 ++++++++++++++++++++++++++++++++++++++ test/colm.d/balance3.lm | 32 ++++++++++++++++++++++++++++++++ 3 files changed, 103 insertions(+) create mode 100644 test/colm.d/balance1.lm create mode 100644 test/colm.d/balance2.lm create mode 100644 test/colm.d/balance3.lm (limited to 'test') diff --git a/test/colm.d/balance1.lm b/test/colm.d/balance1.lm new file mode 100644 index 00000000..e5ec8e6b --- /dev/null +++ b/test/colm.d/balance1.lm @@ -0,0 +1,33 @@ +lex + token id /[a-z]+/ + ignore /[ \t\n]/ + + literal `; + + token PLUS /'+'/ { + input->pull( match_length ) + + parse S: stmt "there is more;" + input->push( S ) + input->push( "; " ) + } +end + +def stmt + [id* `;] + +def main + [stmt+] + +parse M: main [stdin] + +print + "parsed tree + [M] + "<- +##### IN ##### +a b + c d; +##### EXP ##### +parsed tree +a b ; there is more; c d; +<- diff --git a/test/colm.d/balance2.lm b/test/colm.d/balance2.lm new file mode 100644 index 00000000..962df3cb --- /dev/null +++ b/test/colm.d/balance2.lm @@ -0,0 +1,38 @@ +lex + token id /[a-z]+/ + ignore WS /[ \t\n]/ + + literal `; `! `@ + + token PLUS /'+'/ { + # input->pull( match_length ) + input->push_ignore( make_token( typeid, input->pull(match_length) ) ) + + parse S: stmt "there is more;" + input->push( S ) + input->push( "; " ) + } +end + +def E1 [] +def E2 [] + +def stmt + [id* `;] + +def main + [E1 stmt+ `!] +| [E2 stmt+ `@] + +parse M: main [stdin] + +print + "parsed tree + [M] + "<- +##### IN ##### +a b + c d; @ +##### EXP ##### +parsed tree +a b ; there is more;+ c d; @ +<- diff --git a/test/colm.d/balance3.lm b/test/colm.d/balance3.lm new file mode 100644 index 00000000..aae049b7 --- /dev/null +++ b/test/colm.d/balance3.lm @@ -0,0 +1,32 @@ +lex + token id /[a-z]+/ + ignore /[ \t\n]/ + + literal `; + + token PLUS /'+'/ { + input->pull( match_length ) + + parse M: main "there is more;" + input->push( M ) + input->push( "; " ) + } +end + +def stmt + [id* `;] + +def main + [stmt+] + +parse M: main [stdin] + +print + "parsed tree + [M] + "<- +##### IN ##### +a b + c d; @ +##### EXP ##### +parsed tree +NIL<- -- cgit v1.2.1