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

WWW DSL using Irony - Part 1

Rate me:
Please Sign up or sign in to vote.
5.00/5 (9 votes)
1 Jun 2009CPOL4 min read 31.7K   236   30  
A Domain Specific Language for WWW operations created with Irony.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Irony.Compiler;
using Irony.Runtime;
using System.Threading;
using Irony.Compiler.AST;

namespace WWWDSL
{
    public class GotoJumpException : Exception
    {   
        public Token LabelId { get; private set; }

        public GotoJumpException(Token label)
        {
            LabelId = label;
        }
    }

    public class LabelNode : AstNode
    {
        public LabelNode(NodeArgs args) : base(args)
        {
        }
    }

    public class GotoJumpNode : AstNode
    {
        private Token labelNode_;

        public GotoJumpNode(NodeArgs args, AstNode labelNode)
            : base(args)
        {
            ChildNodes.Clear();

            labelNode_ = (Token)labelNode;
            AddChild("label", labelNode_);
        }

        protected override void DoEvaluate(EvaluationContext context)
        {
            throw new GotoJumpException(labelNode_);
        }
    }
}

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
Poland Poland
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions