I agree, all you need is generators - that they are implemented with coroutines is immaterial.
Take a look at this, and substitute the yield() function for crReturn(). https://www.chiark.greenend.org.uk/~sgtatham/coroutines.html > On Nov 18, 2024, at 10:54 AM, roger peppe <rogpe...@gmail.com> wrote: > > Interesting! Thanks for sharing. > > This is related to something that I've been planning to explore for a while > now: using iterators themselves and their associated coroutines accessed via > `iter.Pull`, to do parsing. That is, instead of gaining access to the > underlying coroutine machinery by use of "go:linkname", perhaps we can get a > bunch of the same advantages by using the more structured form already > provided by the standard library. > > I suspect that the feedback from parser to scanner you describe can be > implemented by allowing the parser to invoke methods on the iteration values > (tokens) returned by the scanner. > > I wonder if the result might actually be nicer (easier to understand and > better structured) than the direct use of coroutines, which personally I find > quite hard to "get". > > rog. > > On Mon, 18 Nov 2024 at 02:53, Romain Doumenc <romain@trout.software> wrote: >> Hi everyone, >> >> I took some time over the past weeks to experiment with the coroutine >> switching capabilities in the runtime – in this case for parsing. >> I find this new API extremely useful, and started seeing quite a few places >> in the code base I maintain to simplify some complicated, synchronized, >> stateful machines. >> >> The document is at: >> https://trout-software.notion.site/Parsing-with-Coroutines-13bf9f8a093980d7a0fcf41b81594677 >> >> I hope it is useful for others also interested in experimenting >> -- >> Romain >> >> -- >> You received this message because you are subscribed to the Google Groups >> "golang-nuts" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to golang-nuts+unsubscr...@googlegroups.com >> <mailto:golang-nuts+unsubscr...@googlegroups.com>. >> To view this discussion visit >> https://groups.google.com/d/msgid/golang-nuts/d095a5d6-679f-4c13-82d3-7acf07cf9996n%40googlegroups.com >> >> <https://groups.google.com/d/msgid/golang-nuts/d095a5d6-679f-4c13-82d3-7acf07cf9996n%40googlegroups.com?utm_medium=email&utm_source=footer>. > > > -- > You received this message because you are subscribed to the Google Groups > "golang-nuts" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to golang-nuts+unsubscr...@googlegroups.com > <mailto:golang-nuts+unsubscr...@googlegroups.com>. > To view this discussion visit > https://groups.google.com/d/msgid/golang-nuts/CAJhgacjwXX6EeRt5%2BzDhy_15wXyvNxHv8CAfLvu0nTz1w2KJPQ%40mail.gmail.com > > <https://groups.google.com/d/msgid/golang-nuts/CAJhgacjwXX6EeRt5%2BzDhy_15wXyvNxHv8CAfLvu0nTz1w2KJPQ%40mail.gmail.com?utm_medium=email&utm_source=footer>. -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion visit https://groups.google.com/d/msgid/golang-nuts/3AA3318C-2F6E-4683-AE15-14436008F925%40ix.netcom.com.