public TokenList execute(List <TokenList.Token> replacements) { TokenList output = new TokenList(); TokenList.Token t = tokens.getFirst(); while (t != null) { if (t.word != null) { bool matched = false; for (int i = 0; i < inputs.Count; i++) { if (inputs[i].Equals(t.word)) { output.insert(output.last, replacements[i].copy()); matched = true; break; } } if (!matched) { output.insert(output.last, t.copy()); } } else { output.insert(output.last, t.copy()); } t = t.next; } return(output); }
public Explicit(TokenList.Token start, TokenList.Token end) { TokenList.Token t = start; while (true) { sequence.Add((VariableInteger)t.getVariable()); if (t == end) { break; } else { t = t.next; } } }
public Combined(TokenList.Token start, TokenList.Token end) { TokenList.Token t = start; do { if (t.getVariable().getType() == VariableType.SCALAR) { sequences.Add(new Explicit(t)); } else if (t.getVariable().getType() == VariableType.INTEGER_SEQUENCE) { sequences.Add(((VariableIntegerSequence)t.getVariable()).sequence); } else { throw new InvalidOperationException("Unexpected token type"); } t = t.next; } while (t != null && t.previous != end); }
public For(TokenList.Token start, TokenList.Token step, TokenList.Token end) { this.start = (VariableInteger)start.getVariable(); this.step = step == null ? null : (VariableInteger)step.getVariable(); this.end = (VariableInteger)end.getVariable(); }
public Range(TokenList.Token start, TokenList.Token step) { this.start = start == null ? null : (VariableInteger)start.getVariable(); this.step = step == null ? null : (VariableInteger)step.getVariable(); }
public Explicit(TokenList.Token single) { sequence.Add((VariableInteger)single.getVariable()); }