Example #1
0
        public static IContentNode CreateValue(this DslToken token)
        {
            switch (token.TokenType)
            {
            case TokenType.DateTime: return(new ContentDateTime(DateTime.Parse(token.Value, null, DateTimeStyles.RoundtripKind)));

            case TokenType.String: return(new ContentText(token.Value.Substring(1, token.Value.Length - 2)));

            case TokenType.Number: return(new ContentNumber(decimal.Parse(token.Value)));

            case TokenType.Null: return(ContentNull.Singleton);

            case TokenType.TrueLiteral: return(new ContentBoolean(true));

            case TokenType.FalseLiteral: return(new ContentBoolean(false));

            default: throw new ParserException($"Unexpected token", token);
            }
        }
Example #2
0
 public ParserException(string message, DslToken token)
     : base($"{message}{(token == null? string.Empty : $"(at character {token.Match.StartIndex}" )})")
Example #3
0
 ConstantExpression CreateConstant(DslToken token)
 {
     return(new ConstantExpression(token.CreateValue()));
 }
Example #4
0
 public static bool IsConstant(this DslToken token)
 {
     return(ConstantTokens.Contains(token.TokenType));
 }