public CTGestureParserExpression ReduceDefinition(CTGestDef def) { var expr = new CTGestureParserExpression(); foreach (var t in def.expression.Tokens()) { if (t.tokenType == CTGestParserTokenType.def) { var replacementDef = definitions[t.name]; expr += ReduceDefinition(replacementDef); } else { expr += t; } } return expr; }
public CTGestureParserGraphNode(CTGestureParserGraphNode parent = null) { this.parent = parent; branches = new List<CTGestureParserGraphNode>(); expr = new CTGestureParserExpression(); }
public CTGestureParserGraphNode AddBranch(CTGestureParserExpression expression) { // if you are trying to chain on to a terminal, back track and chain from there. // this happens with subcommands if (this.nodeType == CTGestParserGraphNodeType.terminal) { return parent.AddBranch(expression); } foreach (var b in branches) { if (b.expr.Equals(expression)) { return b; } } branches.Add(new CTGestureParserGraphNode(this) { expr = expression, }); return branches.Last(); }
public void AddExpression(CTGestureParserExpression expr) { current = current.AddBranch(expr); }