2010/4/11 François Perrad <[email protected]>: > 2010/4/11 François Perrad <[email protected]>: >> I try to refactor runtime/parrot/library/TAP/parser.pir with a generator >> (see attached patch) >> >> this naive implementation : >> .sub '_get_results' >> .param pmc parser >> .local pmc result >> result = new 'ResizablePMCArray' >> L1: >> $P0 = parser.'next'() >> if null $P0 goto L2 >> diag($P0) >> push result, $P0 >> goto L1 >> L2: >> .return (result) >> .end >> cannot work with more than 1 file. >> And fails at the beginning of second file with the message : >> Cannot resume dead coroutine. >> > > This behaviour is fine for me. > I don't like the idea of a silently restart. > >> this other implementation with a Coroutine PMC : >> .sub '_get_results' >> .param pmc parser >> .local pmc result >> result = new 'ResizablePMCArray' >> $P0 = get_hll_global ['TAP';'Parser'], 'next' >> .local pmc coro >> coro = new 'Coroutine', $P0 >> L1: >> $P0 = coro(parser) >> if null $P0 goto L2 >> diag($P0) >> push result, $P0 >> goto L1 >> L2: >> .return (result) >> .end >> fails with the message : >> exists_keyed_str() not implemented in class 'Coroutine' >> Something seems to be broken and parrot lacks of tests for this part. >> > > Now, when I instanciate explicity a Coroutine > const 'Sub' func = 'my_coro' > $P0 = new 'Coroutine', func > I want each time, a 'new' coroutine in its initial state. > > Another idea is cloning the coroutine before using it, and consume > only the clone. > That's work with the attached sample. > But gives a new error with TAP/Parser which uses a lexical 'state'. > > .sub '_get_results' > .param pmc parser > .local pmc result > result = new 'ResizablePMCArray' > $P0 = get_hll_global ['TAP';'Parser'], 'next' > .local pmc coro > coro = clone $P0 > L1: > $P0 = coro(parser) > if null $P0 goto L2 > diag($P0) > push result, $P0 > goto L1 > L2: > .return (result) > .end >
See http://trac.parrot.org/parrot/ticket/1550 > > François > >> Any idea or help is welcome. >> >> François >> > _______________________________________________ http://lists.parrot.org/mailman/listinfo/parrot-dev
