Click here to Skip to main content
15,894,017 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 PostDataItemNode : AstNode
    {
        private AstNode paramNode_;
        private AstNode valueNode_;

        public PostDataItemNode(NodeArgs args, AstNode paramNode, AstNode valueNode)
            : base(args)
        {
            ChildNodes.Clear();

            paramNode_ = paramNode;
            if (paramNode_ is VarRefNode)
            {
                paramNode_.Flags |= AstNodeFlags.AllocateSlot | AstNodeFlags.NotRValue;
            }
            AddChild("param", paramNode_);

            valueNode_ = valueNode;
            if (valueNode_ is VarRefNode)
            {
                valueNode_.Flags |= AstNodeFlags.AllocateSlot | AstNodeFlags.NotRValue;
            }
            AddChild("value", valueNode_);
        }

        protected override void DoEvaluate(EvaluationContext context)
        {
            paramNode_.Evaluate(context);
            string left = (string)context.CurrentResult;
            valueNode_.Evaluate(context);
            string right = (string)context.CurrentResult;
            context.CurrentResult = left + "=" + right;
        }
    }
}

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