public static string GetEnumerationValue(this StepSyntax syntax) { if (syntax.SyntaxType != StepSyntaxType.Enumeration) { ReportError("Expected enumeration value", syntax); } return(((StepEnumerationValueSyntax)syntax).Value); }
public static StepSyntaxList GetValueList(this StepSyntax syntax) { if (syntax.SyntaxType != StepSyntaxType.List) { ReportError("Expected list value", syntax); } return((StepSyntaxList)syntax); }
public static double GetRealVavlue(this StepSyntax syntax) { if (syntax.SyntaxType != StepSyntaxType.Real) { ReportError("Expected real value", syntax); } return(((StepRealSyntax)syntax).Value); }
public static int GetIntegerValue(this StepSyntax syntax) { if (syntax.SyntaxType != StepSyntaxType.Integer) { ReportError("Expected integer value", syntax); } return(((StepIntegerSyntax)syntax).Value); }
public static DateTime GetDateTimeValue(this StepSyntax syntax) { var str = syntax.GetStringValue(); DateTime result; if (DateTime.TryParseExact(str, DateTimeFormat, CultureInfo.InvariantCulture, DateTimeStyles.RoundtripKind, out result)) { return(result); } else { return(DateTime.Parse(str, CultureInfo.InvariantCulture, DateTimeStyles.AssumeLocal)); } }
public static string GetStringValue(this StepSyntax syntax) { switch (syntax.SyntaxType) { case StepSyntaxType.Omitted: return(string.Empty); case StepSyntaxType.String: return(((StepStringSyntax)syntax).Value); default: ReportError("Expected string value", syntax); return(null); // this will never get here because `ReportError` throws } }
public static bool GetBooleanValue(this StepSyntax syntax) { switch (syntax.GetEnumerationValue().ToUpperInvariant()) { case "T": case "TRUE": return(true); case "F": case "FALSE": return(false); default: ReportError("Expected boolean value", syntax); return(false); // unreachable } }
private static void ReportError(string message, StepSyntax location) { ReportError(message, location.Line, location.Column); }
public static string GetConcatenatedStringValue(this StepSyntax syntax) { return(string.Join(string.Empty, syntax.GetValueList().Values.Select(v => v.GetStringValue()))); }