コード例 #1
0
ファイル: Parser.cs プロジェクト: Woodamsc/KSP_Konsole
 public Parser(Konsole caller)
 {
     _konsole = caller;
       _last_result = new None();
       _stacked_input_queue = new Stack<Queue<Lexicon>>();
       _commands[""] = blank;
       _commands["dv"] = dv;
       _commands["if"] = ifCond;
       _commands["add"] = math;
       _commands["sub"] = math;
       _commands["div"] = math;
       _commands["mul"] = math;
       _commands["#ans"] = getLastAns;
       _commands["mass"] = mass;
       _commands["type"] = type;
       _commands["echo"] = echo;
       _commands["exec"] = playerExecute;
       _commands["etype"] = evaluatedType;
       _commands["mtype"] = multipleType;
       _commands["lthan"] = equality;
       _commands["gthan"] = equality;
       _commands["equal"] = equality;
       _commands["massT"] = massTotal;
       _commands["crewco"] = crewCount;
       _commands["airpress"]	= airPressure;
       _vessel = FlightGlobals.ActiveVessel;
 }
コード例 #2
0
ファイル: Parser.cs プロジェクト: Woodamsc/KSP_Konsole
        public Lexicon parseAndExecute(string input)
        {
            addInput(input);
              Lexicon firstLex = nextLexicon();

              if (firstLex.Type != DataTypes.Command) {
            _last_result = new Error(firstLex.getValueAsString() + " is not a command");
              } else {
            _last_result = execute(firstLex);
              }
              emptyScope(); // We're exiting this scope, so clear the queue and pop the stack
              return _last_result;
        }
コード例 #3
0
ファイル: Parser.cs プロジェクト: Woodamsc/KSP_Konsole
 private Lexicon execute(Lexicon nextLex)
 {
     if (nextLex.Type == DataTypes.Function) {
     addInput(nextLex.getValueAsString());
     Lexicon result = execute(nextLexicon());
     return result;
       } else {
     while (nextLex.Type == DataTypes.Command) {
       Command cmd = (Command)nextLex;
       nextLex = _commands[cmd.Value](cmd);
     }
       }
       return nextLex;
 }