public void Parse(Context context)
 {
     name = context.CurrentToken();
     context.SkipToken(name);
     if (!name.Equals("go") && !name.Equals("right") && !name.Equals("left"))
     {
         throw new ParseException(name + " is undefined");
     }
 }
 public override void Parse(Context context)
 {
     while (true)
     {
         if (context.CurrentToken() == null)
         {
             throw new InvalidCastException();
         }
         else if (context.CurrentToken().Equals("end"))
         {
             context.SkipToken("end");
             break;
         }
         else
         {
             Node commandNode = new CommandNode();
             commandNode.Parse(context);
             _list.Add(commandNode);
         }
     }
 }
Esempio n. 3
0
 public void Parse(Context context)
 {
     while (true)
     {
         if (context.CurrentToken() == null)
         {
             throw new ParseException("Missing 'end'");
         }
         else if (context.CurrentToken().Equals("end"))
         {
             context.SkipToken("end");
             break;
         }
         else
         {
             INode commandNode = new CommandNode();
             commandNode.Parse(context);
             list.Add(commandNode);
         }
     }
 }
Esempio n. 4
0
 public void Parse(Context context)
 {
     if (context.CurrentToken().Equals("repeat"))
     {
         node = new RepeatCommandNode();
         node.Parse(context);
     }
     else
     {
         node = new PrimitiveCommandNode();
         node.Parse(context);
     }
 }