[Bio] / smc / stripper.py Repository:
ViewVC logotype

View of /smc/stripper.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (download) (as text) (annotate)
Fri Sep 26 19:36:17 2003 UTC (16 years, 1 month ago) by park
Branch: MAIN
CVS Tags: HEAD
Extend to generate Python statemachines.
   o  smc  < foo.sm   makes c++
   o  smc -c < foo.sm makes c++
   o  smc -p < foo.sm makes python

The yacc is written (originally) to call GenStateMap when the
end of the document is hit.  We make GenStateMap call
generator which is a ptr to function.  We set the fn
to call in main via command line opts.

#!/usr/bin/python

#----------------------------------------------------------

#    Main Module 

#

#         python version of stripper.cc

#          September, 2003

#-----------------------------------------------------------


import sys
import string
from stripFSM import *


if __name__ == "__main__":

	myStripper = StripFSM()
	myStripper.SetStreams(sys.stdin, sys.stdout)
	while (1):
	    oneCh = myStripper.ReadChar()

	    if (oneCh == ""):
	        break
            elif oneCh == '/':
                myStripper.Slash()
            elif oneCh == '*':
                myStripper.Star()
            elif oneCh == '\n':
                myStripper.EOL()
            else:
                myStripper.Other()

	
"""
// $Id: stripper.py,v 1.1 2003/09/26 19:36:17 park Exp $
//
// This program implements a C++ comment stripper
// using the State Map Parser.
//
#include <iostream.h>
#include <stdlib.h>
#include "stripFSM.h"

main()
{
	StripFSM myStripper;
	myStripper.SetStreams(cin,cout);

	while (cin)
		switch(myStripper.ReadChar())
		{
		    case EOF: exit(0); break;
			case '/': myStripper.Slash(); break;
			case '*': myStripper.Star(); break;
			case '\n': myStripper.EOL(); break;
			default: myStripper.Other(); break;
		}
}
"""

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3