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) 2003 Charles W. Rapp. 17' All Rights Reserved. 18' 19' Contributor(s): 20' 21' Function 22' Main 23' 24' Description 25' This routine starts the finite state machine running. 26' 27' RCS ID 28' $Id: AppClass.vb,v 1.1 2005/05/28 18:15:21 cwrapp Exp $ 29' 30' CHANGE LOG 31' $Log: AppClass.vb,v $ 32' Revision 1.1 2005/05/28 18:15:21 cwrapp 33' Added VB.net examples 1 - 4. 34' 35' Revision 1.0 2004/05/30 21:12:11 charlesr 36' Initial revision 37' 38 39Public NotInheritable Class AppClass 40 41 '----------------------------------------------------------- 42 ' Member data. 43 ' 44 45 ' The class' associated finite state machine. 46 Private _fsm As AppClassContext 47 48 ' Set this flag to true if the given string is accepted by 49 ' the FSM. 50 Private _isAcceptable As Boolean 51 52 '----------------------------------------------------------- 53 ' Member methods. 54 ' 55 56 Public Sub New() 57 58 _isAcceptable = False 59 _fsm = New AppClassContext(Me) 60 61 ' Uncomment to turn on debug output. 62 ' _fsm.DebugFlag = True 63 End Sub 64 65 Public Function CheckString(ByVal s As String) As Boolean 66 67 Dim i As Integer 68 Dim c As Char 69 70 i = 0 71 While i < s.Length 72 c = s.Chars(i) 73 74 If c = "0"c _ 75 Then 76 _fsm.Zero() 77 ElseIf c = "1"c _ 78 Then 79 _fsm.One() 80 Else 81 _fsm.Unknown() 82 End If 83 84 i += 1 85 End While 86 87 _fsm.EOS() 88 89 Return _isAcceptable 90 End Function 91 92 Public Sub Acceptable() 93 94 _isAcceptable = True 95 End Sub 96 97 Public Sub Unacceptable() 98 99 _isAcceptable = False 100 End Sub 101 102End Class 103