state-machine

LL top-down parser, from CST to AST

房东的猫 提交于 2020-05-28 08:43:35
问题 I am currently learning about syntax analysis, and more especially, top-down parsing. I know the terminology and the difference with bottom-up LR parsers, and since top-down LL parsers are easier to implement by hand, I am looking forward to make my own. I have seen two kinds of approach: The recursive-descent one using a collection of recursive functions. The stack-based and table-driven automaton as shown here on Wikipedia. I am more interested by the latter, for its power and its

Why cant we use IteratorStateMachineAttribute in C#?

不打扰是莪最后的温柔 提交于 2020-02-02 06:05:31
问题 I did a Go To Definition ( F12 ) on a class I was trying to derive from and I noticed that one of the methods was marked with AsyncStateMachineAttribute . Which in turn inherits StateMachineAttribute . I was curious and decide to read up on this attribute and all its derivates on MSDN. That led me to this and I came across this statement: You can't use IteratorStateMachineAttribute to test whether a method is an iterator method in C#. Because that statement is made to stand out, there must be

converting a*b* regular expression to finite state machine

只谈情不闲聊 提交于 2020-01-26 04:31:04
问题 How can I convert the regular expression a*b* to a finite state machine? I am just starting out, and have no idea how to start. 回答1: Think about it. a*b* means a 0 or more times then b 0 or more times. Building a state transition table... Transitions 0 - empty 1 - next a 2 - next b 3 - next not ( a or b ) State / Transitions S | T | S S | 0 | Y S | 1 | a S | 2 | b S | 3 | N a | 0 | Y a | 1 | a a | 2 | b a | 3 | N b | 0 | Y b | 1 | N b | 2 | b b | 3 | N States S - start Y - end - matches N -

Why does this take so long to match? Is it a bug?

≡放荡痞女 提交于 2020-01-25 20:51:09
问题 I need to match certain URLs in web application, i.e. /123,456,789 , and wrote this regex to match the pattern: r'(\d+(,)?)+/$' I noticed that it does not seem to evaluate, even after several minutes when testing the pattern: re.findall(r'(\d+(,)?)+/$', '12345121,223456,123123,3234,4523,523523') The expected result would be that there were no matches. This expression, however, executes almost immediately (note the trailing slash): re.findall(r'(\d+(,)?)+/$', '12345121,223456,123123,3234,4523

State machines in C

*爱你&永不变心* 提交于 2020-01-22 04:28:05
问题 What is the best way to write a state machine in C? I usually write a big switch-case statement in a for(;;), with callbacks to re-enter the state machine when an external operation is finished. Do you know a more efficient way? 回答1: I like the Quantum Leaps approach. The current state is a pointer to a function that takes an event object as argument. When an event happens, just call the state function with that event; The function can then do its work and transition to another state by just

How to prevent specific $state from refreshing when another $state updates

随声附和 提交于 2020-01-15 11:48:13
问题 https://plnkr.co/edit/bOZW1a9u62W1QA6cYjYj?p=preview Expected After Login all $states initialize, then after clicking a Ticker button, the only $states that should re-init are ticker , tags and social , but not feed . Results After Login all $states initialize, then after clicking a Ticker button all $states re-initialized. The feed should not. How should the dashboard and feed module be architected to prevent this? At the moment I have the <feed-module></feed-module> inside the dashboard

node.js with a statemachine

这一生的挚爱 提交于 2020-01-02 04:29:10
问题 I understand that node.js is a single thread and is a single process in the memory, I'm working on a project employing state machine and wondering how that will work in this context. I'm feeling the states will be shared across users because it's a single thread or a single process. Calling out for directions/advices. let's say I've state A, state B, state C Application can only transition in this sequence, A -> B -> C Initial state is A, user 1 requests and as a result the state machine

Emitting signals from class, if transition in QStateMachine was successful

旧巷老猫 提交于 2020-01-01 18:55:07
问题 My problem is the following: I need to create class, which contains QStateMachine instance. This class should have slots through which you could "ask" state machine to make transition to another state. And if transition was successful, my class should emit signal about it. How would I implement this? Class should have ability to emit certain signals according to certain slot invoke. Here is a small example of class: class MyClass : public QObject { Q_OBJECT public: explicit MyClass(QObject

How do I create dynamic definitions for state machine based on user defined data in DB

柔情痞子 提交于 2020-01-01 17:09:14
问题 I am trying to write an application that will allow users to manage workflows using the State Machine gem but I am not sure how to proceed in allowing users to define their own state machines using the State Machine gem for ruby. In the dynamic definitions portion of the gem documentation it says that I should be able to do this by replacing code like this below with a data source. def transitions [ {:parked => :idling, :on => :ignite}, {:idling => :first_gear, :first_gear => :second_gear,

How to perform FST (Finite State Transducer) composition

我怕爱的太早我们不能终老 提交于 2020-01-01 02:34:09
问题 Consider the following FSTs : T1 0 1 a : b 0 2 b : b 2 3 b : b 0 0 a : a 1 3 b : a T2 0 1 b : a 1 2 b : a 1 1 a : d 1 2 a : c How do I perform the composition operation on these two FSTs (i.e. T1 o T2) I saw some algorithms but couldn't understand much. If anyone could explain it in a easy way it would be a major help. Please note that this is NOT a homework. The example is taken from the lecture slides where the solution is given but I couldn't figure out how to get to it. 回答1: Since you