summaryrefslogtreecommitdiff
path: root/colm/bytecode.c
diff options
context:
space:
mode:
authorAdrian Thurston <thurston@complang.org>2013-02-10 11:11:34 -0500
committerAdrian Thurston <thurston@complang.org>2013-02-10 11:11:34 -0500
commit2ccf3932d99d1a82f12e8cccbd2c1e7f54e63bb4 (patch)
tree5e7a73ee359dc8f0bc43574409d02a5921757978 /colm/bytecode.c
parentc6b71985f817f6b5e4c7d1ec6f19383404507396 (diff)
downloadcolm-2ccf3932d99d1a82f12e8cccbd2c1e7f54e63bb4.tar.gz
support stream pull outside of a parser
Diffstat (limited to 'colm/bytecode.c')
-rw-r--r--colm/bytecode.c22
1 files changed, 19 insertions, 3 deletions
diff --git a/colm/bytecode.c b/colm/bytecode.c
index d167013c..4d93c0f7 100644
--- a/colm/bytecode.c
+++ b/colm/bytecode.c
@@ -300,10 +300,10 @@ break; }
return PcrDone;
}
-Tree *streamPullBc( Program *prg, FsmRun *fsmRun, StreamImpl *in, Tree *length )
+Tree *streamPullBc( Program *prg, PdaRun *pdaRun, StreamImpl *in, Tree *length )
{
long len = ((Int*)length)->value;
- Head *tokdata = streamPull( prg, fsmRun, in, len );
+ Head *tokdata = streamPull( prg, pdaRun, in, len );
return constructString( prg, tokdata );
}
@@ -2456,7 +2456,8 @@ again:
Stream *accumStream = (Stream*)vm_pop();
Tree *len = vm_pop();
- Tree *string = streamPullBc( prg, exec->parser->pdaRun->fsmRun, accumStream->in, len );
+ PdaRun *pdaRun = exec->parser != 0 ? exec->parser->pdaRun : 0;
+ Tree *string = streamPullBc( prg, pdaRun, accumStream->in, len );
treeUpref( string );
vm_push( string );
@@ -2470,6 +2471,21 @@ again:
treeDownref( prg, sp, len );
break;
}
+
+ case IN_INPUT_PULL_WC: {
+ debug( REALM_BYTECODE, "IN_INPUT_PULL_WC\n" );
+
+ Stream *accumStream = (Stream*)vm_pop();
+ Tree *len = vm_pop();
+ PdaRun *pdaRun = exec->parser != 0 ? exec->parser->pdaRun : 0;
+ Tree *string = streamPullBc( prg, pdaRun, accumStream->in, len );
+ treeUpref( string );
+ vm_push( string );
+
+ treeDownref( prg, sp, (Tree*)accumStream );
+ treeDownref( prg, sp, len );
+ break;
+ }
case IN_INPUT_PULL_BKT: {
Tree *string;
read_tree( string );