public SourceContext To(StateWalker otherWalker) { TokenWalker other = new TokenWalker(this); otherWalker(other); return(this.To(other)); }
public void Parse(ref Node node, TokenWalker walker, out ParseResultHistory resultHistory) { StateWalker walk = null; resultHistory = new ParseResultHistory(); try { this.ParseNode(ref node, out walk, walker, resultHistory); } catch (Success) { walk(walker); if (node is null) { throw new FailedParsingNodeException("Success, but result node is empty"); } } catch (Failure) { throw new FailedParsingNodeException($"Failed parsing node"); } }
public MainViewModel(KeyHooker hookerKey, MouseHooker hookerMouse, KeySenderInput keySenderInput, MouseSenderInput mouseSenderInput) { mHookerKey = hookerKey; mHookerKey.SetHook(); mHookerMouse = hookerMouse; mHookerMouse.SetHook(); mKeySenderInput = keySenderInput; mMouseSenderInput = mouseSenderInput; mStopMacroBranch = new Branch<IInput>(mInputEqualityComparer); mMacrosModeBranch = new Branch<IInput>(mInputEqualityComparer); Settings.Default.Setting = Settings.Default.Setting ?? new AppSettings(mInputEqualityComparer); AppSettings settings = Settings.Default.Setting; mTreeRoot = settings.TreeRoot; mTreeSequence = settings.TreeSequence; MacrosCollection = settings.MacrosCollection; StopMacroCollection = settings.SequenceStopMacro; MacrosModeCollection = settings.SequenceMacrosMode; SequenceCollection = settings.Sequence; MacroCollection = settings.Macro; mSequenceReader = new HookNotRepeatReader(mHookerKey, SequenceCollection); ObservableCollection<IInput> tempCollection = new ObservableCollection<IInput>(MacroCollection.Cast<IInput>()); tempCollection.CollectionChanged += ReadMacro_CollectionChanged; mMacroReader = new MultiHookNotRepeatReader(new List<IHooker> { mHookerKey, mHookerMouse }, tempCollection); mStopMacroReader = new HookNotRepeatReader(mHookerKey, StopMacroCollection); mMacrosModeReader = new HookNotRepeatReader(mHookerKey, MacrosModeCollection); RecordSequenceCommand = new RelayCommand(RecordSequence); RecordMacroCommand = new RelayCommand(RecordMacro); CreateMacrosCommand = new RelayCommand(CreateMacros); CleanRowsSequenceCommand = new RelayCommand(CleanSequence); CleanRowsMacroCommand = new RelayCommand(CleanMacro); CleanRowsMacrosCommand = new RelayCommand(CleanMacros); DeleteRowSequenceCommand = new RelayCommand<IInput>(RemoveSequence); DeleteRowMacroCommand = new RelayCommand<InputDelay>(RemoveMacro); DeleteRowMacrosCommand = new RelayCommand<Macros>(RemoveMacros); StopRecordStopMacroCommand = new RelayCommand(StopRecordStopMacro); StartRecordStopMacroCommand = new RelayCommand(StartRecordStopMacro); StartRecordMacrosModeCommand = new RelayCommand(StartRecordMacrosMode); StopRecordMacrosModeCommand = new RelayCommand(StopRecordMacrosMode); SetDefaultDelayCommand = new RelayCommand(SetDefaultDelay); StopAllRecordCommand = new RelayCommand(StopAllRecord); mCancellationState = new CancelState<IInput>(mInputEqualityComparer); StateWalker<IInput> machineWalker = new StateWalker<IInput>(mTreeRoot); mHookerKey.Hooked += arg => { State<IInput> currentState = machineWalker.WalkStates(arg); return currentState is FunctionState<IInput> ? (bool)((FunctionState<IInput>)currentState).ExecuteFunction() : currentState is CancellationFunctionState<IInput> ? (bool)((CancellationFunctionState<IInput>)currentState).ExecuteFunction(mCancellationState.CancelToken) : true; }; }