Ejemplo n.º 1
0
        public static string GetEnumerationValue(this StepSyntax syntax)
        {
            if (syntax.SyntaxType != StepSyntaxType.Enumeration)
            {
                ReportError("Expected enumeration value", syntax);
            }

            return(((StepEnumerationValueSyntax)syntax).Value);
        }
Ejemplo n.º 2
0
        public static double GetRealVavlue(this StepSyntax syntax)
        {
            if (syntax.SyntaxType != StepSyntaxType.Real)
            {
                ReportError("Expected real value", syntax);
            }

            return(((StepRealSyntax)syntax).Value);
        }
Ejemplo n.º 3
0
        public static int GetIntegerValue(this StepSyntax syntax)
        {
            if (syntax.SyntaxType != StepSyntaxType.Integer)
            {
                ReportError("Expected integer value", syntax);
            }

            return(((StepIntegerSyntax)syntax).Value);
        }
Ejemplo n.º 4
0
        public static StepSyntaxList GetValueList(this StepSyntax syntax)
        {
            if (syntax.SyntaxType != StepSyntaxType.List)
            {
                ReportError("Expected list value", syntax);
            }

            return((StepSyntaxList)syntax);
        }
Ejemplo n.º 5
0
        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));
            }
        }
Ejemplo n.º 6
0
        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
            }
        }
Ejemplo n.º 7
0
        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
            }
        }
Ejemplo n.º 8
0
 private static void ReportError(string message, StepSyntax location)
 {
     ReportError(message, location.Line, location.Column);
 }
Ejemplo n.º 9
0
 public static string GetConcatenatedStringValue(this StepSyntax syntax)
 {
     return(string.Join(string.Empty, syntax.GetValueList().Values.Select(v => v.GetStringValue())));
 }