public static Get ( String input, kOS.ExecutionContext context ) : |
||
input | String | |
context | kOS.ExecutionContext | |
return |
public static Command Get(String input, ExecutionContext context)
{
input = input.Trim();//.Replace("\n", " ");
foreach (var kvp in CommandRegistry.Bindings)
{
Match match = Regex.Match(input, kvp.Key, RegexOptions.IgnoreCase);
if (match.Success)
{
var command = (Command)Activator.CreateInstance(kvp.Value, match, context);
return command;
}
}
throw new kOSException("Syntax Error.", context);
}
Command::Get ( String input, kOS.ExecutionContext context, int line ) : |
public void Run(File file) { this.file = file; State = ExecutionState.WAIT; int lineNumber = 0; foreach (String line in file) { commandBuffer += line; string cmd; while (parseNext(ref commandBuffer, out cmd)) { try { Command cmdObj = Command.Get(cmd, this); cmdObj.LineNumber = lineNumber; commands.Add(cmdObj); } catch (kOSException e) { StdOut("Error on line " + lineNumber + ": " + e.Message); State = ExecutionState.DONE; return; } } lineNumber++; accumulator++; } }