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); } }
public ParserException(string message, DslToken token) : base($"{message}{(token == null? string.Empty : $"(at character {token.Match.StartIndex}" )})")
ConstantExpression CreateConstant(DslToken token) { return(new ConstantExpression(token.CreateValue())); }
public static bool IsConstant(this DslToken token) { return(ConstantTokens.Contains(token.TokenType)); }