Click here to Skip to main content
15,896,269 members
Articles / Programming Languages / C#

State of the Art Expression Evaluation

Rate me:
Please Sign up or sign in to vote.
4.94/5 (212 votes)
17 Nov 2007MIT20 min read 645K   15K   437  
A tutorial on how to realize an expression evaluator in CSharp with ANTLR
using System;

namespace Evaluant.Calculator.Domain
{
	public class Value : LogicalExpression
	{
        public Value(string text, ValueType type)
        {
            this.text = text;
            this.type = type;
        }

		private string text;
		
		public string Text
		{
			get { return text; }
			set { text = value; }
		}

        private ValueType type;

        public ValueType Type
		{
			get { return type; }
			set { type = value; }
		}

        public override void Accept(LogicalExpressionVisitor visitor)
        {
            visitor.Visit(this);
        }
    }

	public enum ValueType
	{
		Integer,
		String,
		DateTime,
		Float,
		Boolean
	}
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The MIT License


Written By
Software Developer (Senior) Microsoft
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions