1# 2# The contents of this file are subject to the Mozilla Public 3# License Version 1.1 (the "License"); you may not use this file 4# except in compliance with the License. You may obtain a copy of 5# the License at http://www.mozilla.org/MPL/ 6# 7# Software distributed under the License is distributed on an "AS 8# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or 9# implied. See the License for the specific language governing 10# rights and limitations under the License. 11# 12# The Original Code is State Machine Compiler (SMC). 13# 14# The Initial Developer of the Original Code is Charles W. Rapp. 15# Portions created by Charles W. Rapp are 16# Copyright (C) 2000 - 2005 Charles W. Rapp. 17# All Rights Reserved. 18# 19# Contributor(s): 20# Port to Python by Francois Perrad, francois.perrad@gadz.org 21# 22# Function 23# Main 24# 25# Description 26# This routine starts the finite state machine running. 27# 28# RCS ID 29# $Id: AppClass.py,v 1.2 2005/06/03 19:58:28 cwrapp Exp $ 30# 31# CHANGE LOG 32# $Log: AppClass.py,v $ 33# Revision 1.2 2005/06/03 19:58:28 cwrapp 34# Further updates for release 4.0.0 35# 36# Revision 1.1 2005/05/28 17:48:29 cwrapp 37# Added Python examples 1 - 4 and 7. 38# 39# 40 41import AppClass_sm 42 43class AppClass: 44 45 def __init__(self): 46 self._fsm = AppClass_sm.AppClass_sm(self) 47 self._is_acceptable = False 48 49 # Uncomment to see debug output. 50 #self._fsm.setDebugFlag(True) 51 52 def CheckString(self, string): 53 for c in string: 54 if c == '0': 55 self._fsm.Zero() 56 elif c == '1': 57 self._fsm.One() 58 else: 59 self._fsm.Unknown() 60 self._fsm.EOS() 61 return self._is_acceptable 62 63 def Acceptable(self): 64 self._is_acceptable = True 65 66 def Unacceptable(self): 67 self._is_acceptable = False 68