4
I Use This!
Activity Not Available

News

Analyzed about 1 year ago. based on code collected about 1 year ago.
Posted over 9 years ago by rivantsov
I don't think it's a right approach. You are thinking about interrupting computation in the middle, taking all active call stacks and persisting them, to load back at later time and continue execution as nothing happened. Something like Hibernate ... [More] option in OS shutdown. While it's doable theoretically, but this is a huuuge challenge. But I don't think it's even needed. Workflow is a state machine, with state persisting at every step, like after transitions from state to state. Transitions happen when certain evaluation code is invoked after something happened (like user approved some doc), and WF state changes. It is immediately persisted, the state shifts to new "position", and new evaluation methods are invoked. The evaluation methods are atomic, they are executed and then system goes to sleep, until next external signal or timer tick. The operations can shut down in any moment (better after a little wait to let active evaluations complete), and can be restarted later - after workflow state is reloaded from database. I understand what trick you have in mind: Coding entire workflow as one continuous method that calls some "waitForSignal" method to pause. The workflow state is encoded in the current execution position plus all local variables. So you do not declare explicit state object that is persisted, but rather want Runtime to persist the execution stack. While this sounds nice, there are 2 problems: first, implementation is extremely challenging; second - even if you succeed, the way the workflow is stored is bad - it is a black box, you cannot easily query the current state in database. This is a mistake they made in WF - they serialize the whole state as a blob. Nice, but what about visibility? ! A running system might have hundreds of workflows (instances) in progress, and manager should be able to see the states of all of them - how many docs are stuck (waiting for smth), and where. If workflow states are just blobs - you're in trouble. It's up to a programmer to implement another mechanism to store 'visible' state - Tokens, flows, token locations, local conditions (results of actions like approved/rejected) etc. But if you have this second 'visible' storage (which is in fact relational, a few tables would make it) - if you have this then you don't need this blob serialization nonsense. So I suggest to rethink the approach [Less]
Posted over 9 years ago by rivantsov
that's because STATEMENT definition does not allow an empty line as a statement. I line-based languages, an empty line is an (Empty) statement, and it should be in the rules. Add it there
Posted over 9 years ago by nekomatic
What I'm looking for is rather a pause->persist->restore->resume scenario rather than serialisation..
Posted over 9 years ago by dhoepelman
So (de)serialization. Irony doesn't have the specific .NET serialization attributes/methods, but think about it: serialization is converting a object to a byte[] or string representation. What is a string representation of the Irony Parse Tree / ... [More] AST? The original parsed string! Thus parsing is more or less the same operation as deserialization. If you can keep the original parse string around you can store that, or you could implement a "pretty-printer", which converts a parse tree / AST to a string formula, akin to serialization. [Less]
Posted over 9 years ago by nekomatic
The system I'm thinking about apart from using the code to perform relatively fast operations (like simple math, string operations, xml transformations etc.) needs to allow delegation of some tasks to a specialised external service ie. to analyse ... [More] content of a large file, or simply schedule a task for a person, then collect the result data. Such operation may take hours or days and I would not like to keep this thread in memory for all that time - I may want to pause all threads to shut the system down for maintenance then resume from the last 'snapshot', I may also want to free resources for other threads while long external task is running, simply I want to pause it just to see the state of variables, or make it possible for another machine to pick the thread up when the long running task completes. In theory most of my requirements could be fulfilled by a WWF or a BPML software, but what I need is to be able to code the workflow rather than draw lines and join boxes.. eventually I could just grab the AST and transform into WWF XAML, however I find this way not very elegant.. Thanks [Less]
Posted over 9 years ago by Normski99
Hi Roman I forgot to mention, excellent work. Just wish there was a little more docs. :) I've amended the code to take into account of Newline this below the core of the if/else and statement block, the grammar loads ok without any warnings but if ... [More] can't parse nested if/else. The syntax highlight erseems to parse the section in bold and I get the error. (5:5 )Syntax error, expected: END, LET, PRINT __ IF X > 1 THEN begin LET X = 1 let x = 1 if__ x > 1 then begin let x= 1 end end // Grammar STATEMENT_LIST.Rule = MakePlusRule(STATEMENT_LIST, NewLine,STATEMENT); STATEMENTS.Rule = STATEMENT | "BEGIN" + NewLine + STATEMENT_LIST + NewLine + "END" + NewLine; ELSE.Rule = Empty | PreferShiftHere() + "else" + STATEMENTS; IF.Rule = "if" + EXPR + "then" + NewLine + STATEMENTS + PreferShiftHere() + ELSE; STATEMENT.Rule = ASSIGN_STMT | PRINT_STMT; LINE_CONTENT.Rule = Empty | IF | STATEMENT_LIST + NewLine; var LINES = new NonTerminal("LINES"); LINES.Rule = MakePlusRule(LINES, NewLine, LINE_CONTENT); this.Root = LINES; [Less]
Posted over 9 years ago by dhoepelman
Serialization maybe?
Posted over 9 years ago by rivantsov
I don't see where are delimiters (NewLine) ? You should put them in your grammar rules, most likely as extra parameter in MakePlusRule calls for Statements, StatementList nonterminals. Another thing, might be related to conflict - LINE and LINE_CONTENT are equivalent, get rid of one of them, duplicates like these can cause conflicts
Posted over 9 years ago by rivantsov
what exactly do you mean by persistence in runtime?!
Posted over 9 years ago by Normski99
I've strimmed the code done to it's basic level just to process statments and if's So even with this code I have Shift-reduce conflict. State S6, lookaheads [LET PRINT]. Selected shift as preferred action. I'm at a loss it make be this because of ... [More] these 2 lines to add multi code lines? var LINES = new NonTerminal("LINES"); LINES.Rule = MakePlusRule(LINES, LINE); //////////////////////////////////////////////////////////////////////////////////////////////// var EXPR = new NonTerminal("EXPRESSION"); var number = new NumberLiteral("number"); var stringLiteral = new StringLiteral("String_Literal", "\"", StringOptions.AllowsDoubledQuote); var variable = new IdentifierTerminal("Variable"); var BINARY_EXPR = new NonTerminal("BINARY_EXPR"); var BINARY_OP = new NonTerminal("BINARY_OP", "operator"); var UNARY_EXPR = new NonTerminal("UNARY_EXPR"); var SIGN = new NonTerminal("SIGN"); var ASSIGN_STMT = new NonTerminal("ASSIGN_STMT"); var STATEMENT_LIST = new NonTerminal("STATEMENT_LIST"); var PRINT_STMT = new NonTerminal("PRINT_STMT"); var PRINT_ARG = new NonTerminal("PRINT_ARG"); var LET = ToTerm("LET"); var EXPR_LIST = new NonTerminal("EXPRESSION_LIST"); var ARG_LIST = new NonTerminal("ARG_LIST"); var comma = ToTerm(","); var STATEMENT = new NonTerminal("STATEMENT"); var PRINT_LIST = new NonTerminal("PRINT_LIST"); var LINE_CONTENT = new NonTerminal("LINE_CONTENT"); var END = ToTerm("END"); var STATEMENTS = new NonTerminal("STATEMENTS"); var IF = new NonTerminal("IF"); var ELSE = new NonTerminal("ELSE"); EXPR.Rule = number | variable | stringLiteral | BINARY_EXPR | "(" + EXPR + ")" | UNARY_EXPR; BINARY_EXPR.Rule = EXPR + BINARY_OP + EXPR; UNARY_EXPR.Rule = SIGN + EXPR; SIGN.Rule = ToTerm("-") | "+"; ASSIGN_STMT.Rule = LET + variable + "=" + EXPR; BINARY_OP.Rule = ToTerm("+") | "^" | "-" | "*" | "/" | "=" | "<=" | ">=" | "<" | ">" | "<>" | "and" | "or" | "matches"; RegisterOperators(60, "^"); RegisterOperators(50, "*", "/"); RegisterOperators(40, "+", "-"); RegisterOperators(30, "=", "<=", ">=", "<", ">", "<>"); RegisterOperators(20, "and", "or", "matches"); EXPR_LIST.Rule = MakeStarRule(EXPR_LIST, EXPR); ARG_LIST.Rule = MakePlusRule(ARG_LIST, comma, EXPR); STATEMENT_LIST.Rule = MakePlusRule(STATEMENT_LIST, STATEMENT); // IF / ELSE OPTIONAL COMPOUND STATEMENTS.Rule = STATEMENT | "BEGIN" + STATEMENT_LIST + "END"; //ELSE.Rule = Empty | PreferShiftHere() + "ELSE" + STATEMENTS; IF.Rule = "if" + EXPR + "then" + STATEMENTS + PreferShiftHere() + "else" + STATEMENTS + "end"; // A statement can be one of a number of types STATEMENT.Rule = ASSIGN_STMT | PRINT_STMT; PRINT_STMT.Rule = ToTerm("PRINT") + PRINT_LIST; PRINT_LIST.Rule = MakeStarRule(PRINT_LIST, null, PRINT_ARG); PRINT_ARG.Rule = EXPR; LINE_CONTENT.Rule = IF | STATEMENT_LIST; var LINE = new NonTerminal("LINES"); LINE.Rule = LINE_CONTENT; var LINES = new NonTerminal("LINES"); LINES.Rule = MakePlusRule(LINES, LINE); this.Root = LINES; [Less]