Exemplo n.º 1
0
        protected override object ReallyDoEvaluate(ScriptThread thread)
        {
            Context.CurrentAct = actnumber;

            var tw = thread.tc().Writer;
            tw.WriteLine();
            tw.Write((Context.CurrentAct+":").PadRight(Constant.COMMENT_COLUMN));
            tw.WriteLine(AstNode2.ToString(thread));

            return this;
        }
Exemplo n.º 2
0
        protected override object ReallyDoEvaluate(Irony.Interpreter.ScriptThread thread)
        {
            var sw = thread.tc().Writer;

            sw.WriteLine("/*********************************************************************");
            sw.WriteLine(" *   This C# program was generated by Shakespeare2CS by James Curran *");
            sw.WriteLine(" *   based on spl2c, the Shakespeare to C                            *");
            sw.WriteLine(" *          converter by Jon Åslund and Karl Hasselström.            *");
            sw.WriteLine(" *********************************************************************/");
            sw.WriteLine();
            sw.WriteLine("using System;");
            sw.WriteLine("using Shakespeare.Support;");
            sw.WriteLine();
            sw.WriteLine("namespace Shakespeare.Program");
            sw.WriteLine("{");
            sw.WriteLine("\tclass Program");
            sw.WriteLine("\t{");
            sw.WriteLine("\t\tstatic void Main(string[] args)");
            sw.WriteLine("\t\t{");
            sw.WriteLine("\t\t\tvar script = new Script();");
            sw.WriteLine("\t\t\tscript.Action();");
            sw.WriteLine("\t\t}");
            sw.WriteLine("\t}");
            sw.WriteLine();
            sw.WriteLine("\t\tclass Script : Dramaturge");
            sw.WriteLine("\t\t{");
            sw.WriteLine();
            sw.WriteLine("\t\tpublic Script()");
            sw.WriteLine("\t\t : base(Console.In, Console.Out)");
            sw.WriteLine("\t\t{ }");
            sw.WriteLine();
            sw.WriteLine("\t\tpublic void Action()");
            sw.WriteLine("\t\t{");

            AstNode1.Evaluate(thread);              // Title
            sw.WriteLine();
            var cdl = AstNode2 as CharacterDeclarationListNode;

            foreach (var ch in cdl.Characters)
            {
                ch.Evaluate(thread);
            }

            sw.WriteLine();
            AstNode3.Evaluate(thread);

            sw.WriteLine("\t\t}");
            sw.WriteLine("\t}");
            sw.WriteLine("}");
            sw.Flush();
            sw.Close();
            return(sw);
        }
Exemplo n.º 3
0
        protected override object ReallyDoEvaluate(Irony.Interpreter.ScriptThread thread)
        {
            var sw = thread.tc().Writer;

            sw.WriteLine("/********************************************************************");
            sw.WriteLine(" *   This C program was generated by spl2c, the Shakespeare to C    *");
            sw.WriteLine(" *          converter by Jon Åslund and Karl Hasselström.           *");
            sw.WriteLine(" ********************************************************************/");
            sw.WriteLine("");
            sw.WriteLine("/* libspl definitions and function prototypes */");
            sw.WriteLine("#include \"spl.h\"");
            sw.WriteLine("");
            sw.WriteLine("int main(void)");
            sw.WriteLine("{");
            AstNode1.Evaluate(thread);  // Title
            sw.WriteLine();
            var cdl = AstNode2 as CharacterDeclarationListNode;

            foreach (var ch in cdl.Characters)
            {
                sw.WriteLine(ch.Declaration);
            }

            sw.WriteLine("\tint comp1, comp2;");
            sw.WriteLine("\tglobal_initialize();");
            foreach (var ch in cdl.Characters)
            {
                sw.WriteLine(ch.Initialization);
            }

            sw.WriteLine();
            sw.WriteLine();
            AstNode3.Evaluate(thread);
            sw.WriteLine("\treturn 0;");
            sw.WriteLine("}");
            sw.Flush();
            sw.Close();
            return(sw);
        }
Exemplo n.º 4
0
 protected override object ReallyDoEvaluate(ScriptThread thread)
 {
     var tw = thread.tc().Writer;
     tw.WriteLine("/********************************************************************");
     tw.WriteLine("*");
     tw.WriteLine("{0,64}", Child1.Token.Text.ToUpper());
     tw.WriteLine("*");
     tw.WriteLine("*********************************************************************/");
     return this;
 }
Exemplo n.º 5
0
 protected override object ReallyDoEvaluate(ScriptThread thread)
 {
     var tw = thread.tc().Writer;
     if (AstNode1 is CharacterNode)
         return (AstNode1.Evaluate(thread) as string) +".Value";
     else if (AstNode1 is ConstantNode)
         return AstNode1.Evaluate(thread);
     else if (AstNode1 is PronounNode)
     {
         return String.Format("ValueOf({0},{1})", Location.Line, AstNode1.Evaluate(thread) as string);
     }
     else if (AstNode1 is BinaryOperatorNode)
     {
         return string.Format(AstNode1.ToString(), Location.Line, AstNode2.Evaluate(thread) as string, AstNode3.Evaluate(thread) as string);
     }
     else if (AstNode1 is UnaryOperatorNode)
     {
         AstNode1.Evaluate(thread);
         return string.Format((AstNode1 as UnaryOperatorNode).FormatString, AstNode2.Evaluate(thread) as string);
     }
     else
     {
         // error
     }
     return this;
 }
Exemplo n.º 6
0
        protected override object ReallyDoEvaluate(ScriptThread thread)
        {
            if (AstNode1 is UnconditionalSentenceNode)
                AstNode1.Evaluate(thread);
            else
            {
                var tw = thread.tc().Writer;
                tw.WriteLine("\t\tif({0}) {{", AstNode1.ToString(thread));
                AstNode2.Evaluate(thread);
                tw.WriteLine("\t\t}");
            }

            return base.ReallyDoEvaluate(thread);
        }
Exemplo n.º 7
0
        protected override object ReallyDoEvaluate(ScriptThread thread)
        {
            if (AstNode1 is SecondPersonNode)
            {
                var tw = thread.tc().Writer;
                if (AstNode2 is BeNode)
                {
                    if (AstNode3 is ConstantNode)
                        tw.WriteLine("\t\tAssign({0}, {1});", Location.Line, AstNode3.Evaluate(thread) as string);
                    else    // SECOND_PERSON BE Equality Value StatementSymbol
                        tw.WriteLine("\t\tAssign({0}, {1});", Location.Line, AstNode4.Evaluate(thread) as string);

                }
                else if (AstNode2 is UnarticulatedConstantNode)
                {
                    tw.WriteLine("\t\tAssign({0}, {1});", Location.Line,  AstNode2.Evaluate(thread) as string);

                }
            }

            return base.ReallyDoEvaluate(thread);
        }
Exemplo n.º 8
0
        protected override object ReallyDoEvaluate(ScriptThread thread)
        {
            var tw = thread.tc().Writer;
            tw.WriteLine("\t\tPush({0}, {1});", Location.Line, AstNode2.ToString(thread));

            return this;
        }
Exemplo n.º 9
0
 protected override object ReallyDoEvaluate(ScriptThread thread)
 {
     var tw = thread.tc().Writer;
     Context.CurrentScene = Context.CurrentAct + "_" + scenenumber;
     tw.WriteLine("{0}{1}", (Context.CurrentScene + ":").PadRight(Constant.COMMENT_COLUMN), AstNode2.ToString(thread));
     return this;
 }
Exemplo n.º 10
0
 protected override object ReallyDoEvaluate(ScriptThread thread)
 {
     var tw = thread.tc().Writer;
     if (AstNode1 is NothingNode)
         return "0";
     else  // astNode1 is Article, FirstPErson, SecondPerson, thirdPerson
         return AstNode2.Evaluate(thread);
 }
Exemplo n.º 11
0
 protected override object ReallyDoEvaluate(ScriptThread thread)
 {
     var tw = thread.tc().Writer;
     tw.WriteLine("\t\tCharacter\t{0} = InitializeCharacter({2},\"{0}\");\t\t{1}", AstNode1.ToString(thread), AstNode2.ToString(thread), Location.Line);
     return this;
 }
Exemplo n.º 12
0
        protected override object ReallyDoEvaluate(ScriptThread thread)
        {
            var tw = thread.tc().Writer;
            if (AstNode2 is SceneRomanNode)
                tw.WriteLine("\t\tgoto {0}_{1};", Context.CurrentAct, AstNode2.ToString().str2varname());
            else
                tw.WriteLine("\t\tgoto {0};", AstNode2.ToString().str2varname());

            return this;
        }
Exemplo n.º 13
0
 protected override object ReallyDoEvaluate(ScriptThread thread)
 {
     var tw = thread.tc().Writer;
     tw.WriteLine();
     tw.WriteLine("\tactivate_character({0}, {1});", Location.Line, AstNode1.ToString(thread));
     AstNode2.Evaluate(thread);
     return this;
 }
Exemplo n.º 14
0
 protected override object ReallyDoEvaluate(ScriptThread thread)
 {
     var tw = thread.tc().Writer;
     if (AstNode1 is OpenYourNode)
     {
         if (String2 == "heart (Keyword)")
         {
             tw.WriteLine("\t\tIntOutput({0});", Location.Line);
         }
         else  // Open Your Mind
         {
             tw.WriteLine("\t\tCharInput({0});", Location.Line);
         }
     }
     else if (String1 == "speak")
     {
         tw.WriteLine("\t\tCharOutput({0});", Location.Line);
     }
     else if (String1 == "listen to")
     {
             tw.WriteLine("\t\tIntInput({0});", Location.Line);
     }
     return base.ReallyDoEvaluate(thread);
 }
Exemplo n.º 15
0
        protected override object ReallyDoEvaluate(ScriptThread thread)
        {
            var charList = new List<CharacterNode>();
            var tw = thread.tc().Writer;
            if (Exist1)
            {
                if (AstNode1 is CharacterNode)
                    charList.Add(AstNode1 as CharacterNode);
                else
                    (AstNode1 as CharacterListNode).Fill(charList);

                foreach (var chr in charList)
                {
                    tw.WriteLine("\t\tExitScene({0}, {1});", Location.Line, chr);
                    Context.ActiveCharacters.Remove(chr);
                }
            }
            else
            {
                tw.WriteLine("\t\tExitSceneAll({0});", Location.Line);
                Context.ActiveCharacters.Clear();
            }

            return this;
        }
Exemplo n.º 16
0
        protected override object ReallyDoEvaluate(ScriptThread thread)
        {
            var tw = thread.tc().Writer;
            var cn = TreeNode.ChildNodes;
            if (Child1.AstNode is CharacterListNode)
                cn = Child1.ChildNodes;

            foreach (var ch in cn)
            {
                tw.WriteLine("\t\tEnterScene({0}, {1});", Location.Line, ch.AstNode.ToString().str2varname());
                Context.ActiveCharacters.Add(ch.AstNode as CharacterNode);
            }
            return base.ReallyDoEvaluate(thread);
        }
Exemplo n.º 17
0
 protected override object ReallyDoEvaluate(ScriptThread thread)
 {
     var tw = thread.tc().Writer;
     tw.Write(format, Location.Line, AstNode2.ToString(thread), AstNode3.ToString(thread));
     return this;
 }
Exemplo n.º 18
0
 protected override object ReallyDoEvaluate(ScriptThread thread)
 {
     var tw = thread.tc().Writer;
     tw.WriteLine("\t\tPop({0});", Location.Line);
     return this;
 }
Exemplo n.º 19
0
        protected override object ReallyDoEvaluate(ScriptThread thread)
        {
            var tw = thread.tc().Writer;
            tw.WriteLine("\t\tComp1 = {0};", AstNode2.ToString(thread));
            tw.WriteLine("\t\tComp2 = {0};", AstNode4.ToString(thread));
            tw.WriteLine("\t\tTruthFlag = {0};", AstNode3.ToString(thread));

            return base.ReallyDoEvaluate(thread);
        }
Exemplo n.º 20
0
 protected override object ReallyDoEvaluate(ScriptThread thread)
 {
     var tw = thread.tc().Writer;
     if (AstNode1 is NegativeNounNode)
         return "(-1)";
     else // astnode1 is NegativeAdjective or astnode1 is neutralAdjective
         return string.Format("2*{0}", AstNode2.ToString(thread));
 }