public void TestSimpleError(string expression, ExpressionErrorKind kind) { //the huge baseOffset can expose parser bugs var expr = ExpressionParser.Parse(expression, ExpressionOptions.Metadata, 1000); AssertSingleErrorKind(expr, kind); }
public void TestSimpleError(string expression, ExpressionErrorKind error) { var expr = ExpressionParser.Parse(expression, ExpressionOptions.Metadata); var err = AssertCast <ExpressionError> (expr); Assert.AreEqual(error, err.Kind); }
public void TestSimpleError(string expression, ExpressionErrorKind error) { //the huge baseOffset can expose parser bugs var expr = ExpressionParser.Parse(expression, ExpressionOptions.Metadata, 1000); var err = AssertCast <ExpressionError> (expr); Assert.AreEqual(error, err.Kind); }
public ExpressionError(int offset, bool wasEOF, ExpressionErrorKind kind, int length, out bool hasError) : base(offset, length) { // this exists so callers don't forget to set it // having this argument has caught a bunch of issues hasError = true; Kind = kind; WasEOF = wasEOF; }
public static string GetMessage(this ExpressionErrorKind errorKind, ValueInfo info, out bool isWarning) { isWarning = false; switch (errorKind) { case ExpressionErrorKind.MetadataDisallowed: return($"{Name()} does not allow metadata"); case ExpressionErrorKind.EmptyListEntry: isWarning = true; return($"Empty list value"); case ExpressionErrorKind.ExpectingItemName: return($"Expecting item name"); case ExpressionErrorKind.ExpectingRightParen: return($"Expecting ')'"); case ExpressionErrorKind.ExpectingRightParenOrPeriod: return($"Expecting ')' or '.'"); case ExpressionErrorKind.ExpectingPropertyName: return($"Expecting property name"); case ExpressionErrorKind.ExpectingMetadataName: return($"Expecting metadata name"); case ExpressionErrorKind.ExpectingMetadataOrItemName: return($"Expecting metadata or item name"); case ExpressionErrorKind.ExpectingRightAngleBracket: return($"Expecting '>'"); case ExpressionErrorKind.ExpectingApos: return($"Expecting single quote"); case ExpressionErrorKind.ExpectingRightParenOrDash: return($"Expecting '-' or ')'"); case ExpressionErrorKind.ItemsDisallowed: return($"{Name()} does not allow metadata"); default: return($"Invalid expression: {errorKind}"); } string Name() => DescriptionFormatter.GetTitleCaseKindName(info); }
public ExpressionError(int offset, bool wasEOF, ExpressionErrorKind kind) : base(offset, wasEOF ? 0 : 1) { Kind = kind; }
public static string GetMessage(this ExpressionErrorKind errorKind, ValueInfo info, out bool isWarning) { isWarning = false; switch (errorKind) { case ExpressionErrorKind.MetadataDisallowed: return($"{Name ()} does not allow metadata"); case ExpressionErrorKind.EmptyListEntry: isWarning = true; return($"Empty list value"); case ExpressionErrorKind.ExpectingItemName: return($"Expecting item name"); case ExpressionErrorKind.ExpectingRightParen: return($"Expecting ')'"); case ExpressionErrorKind.ExpectingRightParenOrPeriod: return($"Expecting ')' or '.'"); case ExpressionErrorKind.ExpectingPropertyName: return($"Expecting property name"); case ExpressionErrorKind.ExpectingMetadataName: return($"Expecting metadata name"); case ExpressionErrorKind.ExpectingMetadataOrItemName: return($"Expecting metadata or item name"); case ExpressionErrorKind.ExpectingRightAngleBracket: return($"Expecting '>'"); case ExpressionErrorKind.ExpectingRightParenOrDash: return($"Expecting '-' or ')'"); case ExpressionErrorKind.ItemsDisallowed: return($"{Name ()} does not allow metadata"); case ExpressionErrorKind.ExpectingMethodOrTransform: return($"Expecting item function or transform"); case ExpressionErrorKind.ExpectingMethodName: return("Expecting method name"); case ExpressionErrorKind.ExpectingLeftParen: return("Expecting '('"); case ExpressionErrorKind.ExpectingRightParenOrComma: return("Expecting ')' or ','"); case ExpressionErrorKind.ExpectingRightParenOrValue: return("Expecting ',' or value"); case ExpressionErrorKind.ExpectingValue: return("Expecting value"); case ExpressionErrorKind.CouldNotParseNumber: return("Invalid numeric value"); case ExpressionErrorKind.IncompleteValue: return("Incomplete value"); case ExpressionErrorKind.ExpectingBracketColonColon: return("Expecting ']::'"); case ExpressionErrorKind.ExpectingClassName: return("Expecting class name"); case ExpressionErrorKind.ExpectingClassNameComponent: return("Incomplete class name"); case ExpressionErrorKind.IncompleteString: return("Incomplete string"); case ExpressionErrorKind.IncompleteProperty: return("Incomplete property"); default: return($"Invalid expression: {errorKind}"); } string Name() => DescriptionFormatter.GetTitleCaseKindName(info); }
static void AssertSingleErrorKind(ExpressionNode n, ExpressionErrorKind kind) => Assert.AreEqual(kind, AssertSingleError <ExpressionError> (n).Kind);
public IncompleteExpressionError(int offset, bool wasEOF, ExpressionErrorKind kind, ExpressionNode incompleteNode) : base(offset, wasEOF? 0 : 1, kind) { IncompleteNode = incompleteNode; }
IncompleteExpressionError(int offset, int length, bool wasEOF, ExpressionErrorKind kind, ExpressionNode incompleteNode, out bool hasError) : base(offset, wasEOF, kind, length, out hasError) { IncompleteNode = incompleteNode; incompleteNode.SetParent(this); }
public IncompleteExpressionError(int offset, bool wasEOF, ExpressionErrorKind kind, ExpressionNode incompleteNode, out bool hasError) : this(incompleteNode.Offset, Math.Max(incompleteNode.Length, offset - incompleteNode.Offset), wasEOF, kind, incompleteNode, out hasError) { }
public IncompleteExpressionError(bool wasEOF, ExpressionErrorKind kind, ExpressionNode incompleteNode, out bool hasError) : this(incompleteNode.Offset, incompleteNode.Length, wasEOF, kind, incompleteNode, out hasError) { }
public ExpressionError(int offset, ExpressionErrorKind kind, out bool hasError) : this(offset, false, kind, out hasError) { }
public ExpressionError(int offset, bool wasEOF, ExpressionErrorKind kind, out bool hasError) : this(offset, wasEOF, kind, wasEOF ? 0 : 1, out hasError) { }
public ExpressionError(int offset, ExpressionErrorKind kind) : this(offset, false, kind) { }
public IncompleteExpressionError(int offset, bool wasEOF, ExpressionErrorKind kind, ExpressionNode incompleteNode) : base(offset, wasEOF, kind) { IncompleteNode = incompleteNode; incompleteNode.SetParent(this); }
public ExpressionError(int offset, int length, ExpressionErrorKind kind) : base(offset, length) { Kind = kind; }