|
Softpanorama |
May the source be with you, but remember the KISS principle ;-)
|
System programmers and complier writes use coroutines for a long time. Most compilers separate lexical and syntax analysis and the most natural way of communicate between them is to use a co-routine linkage. In the most common scenario parser can call lexer for more tokens (look ahead) and then ask to proceed from the token that was last retrieved before look-ahead. The simplest implementation of co-routines in C+= is to use threads. For example in Solaris one can use POSIX threads and in Windows "fibers"( user threads that are not preemptively scheduled). for details see the paper DDJ CROSS-PLATFORM COROUTINES IN C++ by George F. Frazier:
Coroutines are a natural solution to parsing problems used by assembly-language programmers. George presents a cross-platform coroutine technique for C++. Additional resources include cppco.txt (listings) and cppco.zip (source code).
There are also libraries that provide this extension.
Recommended Links
DDJ CROSS-PLATFORM COROUTINES IN C++ by George F. Frazier
A Portable C++ Library for Coroutine Sequencing - Keld Helsgaun Mail
Programmers Heaven - C - C++ Zone - Various Source - CCL110JF.ZIP Download page Class Coroutine: an abstract base class for DOS coroutines.
C++ Library Reference- 2 - The Coroutine Library
Coroutine examples from ch 2 course notes. in CS 342 Control Structures
Copyright © 1996-2007 by Dr. Nikolai Bezroukov. www.softpanorama.org was created as a service to the UN Sustainable Development Networking Programme (SDNP) in the author free time. Submit comments This document is an industrial compilation designed and created exclusively for educational use and is placed under the copyright of the Open Content License(OPL). Original materials copyright belong to respective owners. Quotes are made for educational purposes only in compliance with the fair use doctrine.
Standard disclaimer: The statements, views and opinions presented on this web page are those of the author and are not endorsed by, nor do they necessarily reflect, the opinions of the author present and former employers, SDNP or any other organization the author may be associated with. We do not warrant the correctness of the information provided or its fitness for any purpose.
Last modified: February 28, 2008