{
/// <summary>
/// Prefix from the output indicating the class of result. According to the documentation, these are:
- ///
- /// result-class ==> "done" | "running" | "connected" | "error" | "exit"
+ ///
+ /// result-class ==> "done" | "running" | "connected" | "error" | "exit" | "stopped"
/// </summary>
public enum ResultClass
{
running,
connected,
error,
- exit
+ exit,
+ stopped
}
public class ResultValue
throw new MIResultFormatException(name, this);
}
+ public ResultListValue FindResultListValue(string name)
+ {
+ var c = Find(name);
+ if (c is ResultListValue)
+ {
+ return c as ResultListValue;
+ }
+ throw new MIResultFormatException(name, this);
+ }
+
public bool TryFind<T>(string name, out T result) where T : ResultValue
{
if (Contains(name))
return Content.Count(c => c.Name == name);
}
+ public ResultValue FindWith(string name, string value)
+ {
+ for (int i = 0; i < Length; i++)
+ if (Content[i].Value.Find(name).ToString() == value)
+ return Content[i].Value;
+ throw new MIResultFormatException(name, this);
+ }
+
public override string ToString()
{
StringBuilder outList = new StringBuilder();
private string _resultString;
/// <summary>
- /// result-record ==> result-class ( "," result )*
+ /// result-record ==> result-class ( "," result )*
/// </summary>
/// <param name="output"></param>
public Results ParseCommandOutput(string output)
{
+ string token = ParseToken(ref output);
+ output = output.Remove(0, 1); // Remove first char (^, *, e.t.c)
_resultString = output.Trim();
int comma = _resultString.IndexOf(',');
Results results;
return results;
}
+ private string ParseToken(ref string output)
+ {
+ if (char.IsDigit(output, 0))
+ {
+ int i;
+ for (i = 1; i < output.Length; i++)
+ {
+ if (!char.IsDigit(output, i))
+ break;
+ }
+ if (i < output.Length)
+ {
+ string token = output.Substring(0, i);
+ output = output.Substring(i);
+ return token;
+ }
+ }
+ return null;
+ }
+
public Results ParseResultList(string listStr, ResultClass resultClass = ResultClass.None)
{
_resultString = listStr.Trim();
}
/// <summary>
- /// GDB (on x86) sometimes returns a tuple list in a context requiring a tuple (<MULTIPLE> breakpoints).
+ /// GDB (on x86) sometimes returns a tuple list in a context requiring a tuple (<MULTIPLE> breakpoints).
/// The grammer does not allow this, but we recognize it and accept it only in the special case when it is contained
/// in a result value.
/// tuplelist -- tuple ("," tuple)*
case "connected": return ResultClass.connected;
case "error": return ResultClass.error;
case "exit": return ResultClass.exit;
+ case "stopped": return ResultClass.stopped;
default:
{
Debug.Fail("unexpected result class");
}
/// <summary>
- /// tuple ==> "{}" | "{" result ( "," result )* "}"
+ /// tuple ==> "{}" | "{" result ( "," result )* "}"
/// </summary>
/// <returns>if one tuple found a TupleValue, otherwise a ValueListValue of TupleValues</returns>
private ResultValue ParseResultTuple(Span input, out Span rest)
}
/// <summary>
- /// tuple ==> "{}" | "{" result ( "," result )* "}"
+ /// tuple ==> "{}" | "{" result ( "," result )* "}"
/// </summary>
private TupleValue ParseTuple(Span input, out Span rest)
{
}
/// <summary>
- /// list ==> "[]" | "[" value ( "," value )* "]" | "[" result ( "," result )* "]"
+ /// list ==> "[]" | "[" value ( "," value )* "]" | "[" result ( "," result )* "]"
/// </summary>
private ResultValue ParseList(Span input, out Span rest)
{
}
/// <summary>
- /// list ==> "[" value ( "," value )* "]"
+ /// list ==> "[" value ( "," value )* "]"
/// </summary>
private ValueListValue ParseValueList(Span input, out Span rest)
{
}
/// <summary>
- /// list ==> "[" result ( "," result )* "]"
+ /// list ==> "[" result ( "," result )* "]"
/// </summary>
private ResultListValue ParseResultList(Span input, out Span rest)
{