Click here to Skip to main content
15,881,803 members
Articles / Programming Languages / C#

Visual AST for ANTLR Generated Parser Output

Rate me:
Please Sign up or sign in to vote.
4.92/5 (14 votes)
17 May 2012CPOL13 min read 90.3K   2.2K   41  
Build a visual AST from ANTLR parser
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace EntMapping
{
    public class Sampler
    {
        public string GetSample()
        {
            StringBuilder input = new StringBuilder();
            input.Append("Invoice <- Order ;");
            input.AppendLine();
            input.Append("InvoiceDate = Order.OrderDate + 30 ;");
            input.AppendLine();
            input.Append("InvoiceNo = GetNextInvoiceNo() ;");
            input.AppendLine();
            input.Append("Freight = Order.TotalCBM * 1.5 + Order.TotalWeight * 2.2;");
            input.AppendLine();
            input.Append("ShipVia = IF(Order.IsLocal, \"Express\", \"Mail\") ;");
            input.AppendLine();
            return input.ToString();
        }
    }
}

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 Code Project Open License (CPOL)


Written By
Founder Software Force
Hong Kong Hong Kong
I am always interested in finding innovative ways for building better applications and founded a technology company since 2003. Welcome to exchange any idea with you and if I am not too busy before deadline of projects, I will reply your emails. Also, if you willing to pay for consulting works and customized software development, you can leave me message.

Comments and Discussions