public void DFA_triggers_actions_correctly() { // Given alphabet const int A = 0; const int B = 1; // Given actions const int Action0 = 1001; const int Action1 = 1002; const int Action2 = 1003; GivenRegularExpression( AstNode.Or( AstNode.Cat( CharSetNode.Create(A), // 0 ActionNode.Create(Action0)), // 1 AstNode.Cat( // CharSetNode.Create(A), // 2 CharSetNode.Create(B), // 3 CharSetNode.Create(B), // 4 ActionNode.Create(Action1) // 5 ), AstNode.Cat( RepeatNode.ZeroOrMore(CharSetNode.Create(A)), // 6 RepeatNode.OneOrMore(CharSetNode.Create(B)), // 7, 8 ActionNode.Create(Action2)) // 9 )); CreateDfa(); DfaShouldTriggerAction(Action0, A); DfaShouldTriggerAction(Action1, A, B, B); DfaShouldTriggerAction(Action2, A, B); DfaShouldTriggerAction(Action2, A, B, B, B); }
public void dfa_provides_correct_serialization_information() { // Given alphabet const int A = 0; const int B = 1; // Given actions const int Action0 = 1001; const int Action1 = 1002; const int Action2 = 1003; GivenRegularExpression( AstNode.Or( AstNode.Cat( CharSetNode.Create(A), ActionNode.Create(Action0)), AstNode.Cat( CharSetNode.Create(A), CharSetNode.Create(B), CharSetNode.Create(B), ActionNode.Create(Action1) ), AstNode.Cat( RepeatNode.ZeroOrMore(CharSetNode.Create(A)), RepeatNode.OneOrMore(CharSetNode.Create(B)), ActionNode.Create(Action2)) )); CreateDfa(); var output = new StringBuilder(); serialization.Print(output); // DUBUG: Console.WriteLine(output); }
public Piece OneOrMore(Piece atom) { return(new Piece { Node = RepeatNode.OneOrMore(atom.Node) }); }
public SreExpr OneOrMore(OpenSreExpr items) { return(new SreExpr { Node = RepeatNode.OneOrMore(items.Node) }); }