Пример #1
0
        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);
        }
Пример #2
0
 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;
         }
     }
 }
Пример #3
0
 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);
 }
Пример #4
0
 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();
 }
Пример #5
0
 public Range(TokenList.Token start, TokenList.Token step)
 {
     this.start = start == null ? null : (VariableInteger)start.getVariable();
     this.step  = step == null ? null : (VariableInteger)step.getVariable();
 }
Пример #6
0
 public Explicit(TokenList.Token single)
 {
     sequence.Add((VariableInteger)single.getVariable());
 }