示例#1
0
        internal static Parser AddDebugPrinter(this Parser parser)
        {
            DebugPrint.Text.Clear();

            parser.AddBlock <DebugPrint>("text_print");
            return(parser);
        }
示例#2
0
        public ActionResult XmlData(string xmlModel)
        {
            // TODO:
            // Réception d'un fichier ZIP avec à l'intérieur, le fichier xml du scénario, les fichiers ppt, avi, mp4, mp3, etc...

            // A partir d'ici, tout ce qui suit est du code à déporter dans une autre classe
            // il devra être executé sur une action reçu depuis SignalR
            // Create a parser
            var parser = new Parser();

            // Add the standard blocks to the parser
            //parser.AddStandardBlocks();

            // Add custom blocs to the parser
            parser.AddBlock <Scene>("scene");
            parser.AddBlock <SceneActions>("sceneactions");
            parser.AddBlock <PowerPoint>("powerpoint");
            parser.AddBlock <Audio>("audio");
            parser.AddBlock <Video>("video");
            parser.AddBlock <Display>("display");
            parser.AddBlock <Sound>("sound");

            // parse the xml file to create a workspace
            var workspace = parser.Parse(xmlModel);

            // run the workspace
            var output = workspace.Evaluate();

            return(Json(new { success = true }));
        }
示例#3
0
        public static Parser AddStandardBlocks(this Parser parser)
        {
            parser.AddBlock <ControlsRepeatExt>("controls_repeat_ext");
            parser.AddBlock <ControlsIf>("controls_if");
            parser.AddBlock <ControlsWhileUntil>("controls_whileUntil");
            parser.AddBlock <ControlsFlowStatement>("controls_flow_statements");
            parser.AddBlock <ControlsForEach>("controls_forEach");
            parser.AddBlock <ControlsFor>("controls_for");

            parser.AddBlock <LogicCompare>("logic_compare");
            parser.AddBlock <LogicBoolean>("logic_boolean");
            parser.AddBlock <LogicNegate>("logic_negate");
            parser.AddBlock <LogicOperation>("logic_operation");
            parser.AddBlock <LogicNull>("logic_null");
            parser.AddBlock <LogicTernary>("logic_ternary");

            parser.AddBlock <MathArithmetic>("math_arithmetic");
            parser.AddBlock <MathNumber>("math_number");
            parser.AddBlock <MathSingle>("math_single");
            parser.AddBlock <MathSingle>("math_trig");
            parser.AddBlock <MathRound>("math_round");
            parser.AddBlock <MathConstant>("math_constant");
            parser.AddBlock <MathNumberProperty>("math_number_property");
            parser.AddBlock <MathOnList>("math_on_list");
            parser.AddBlock <MathConstrain>("math_constrain");
            parser.AddBlock <MathModulo>("math_modulo");

            parser.AddBlock <TextBlock>("text");
            parser.AddBlock <TextPrint>("text_print");
            parser.AddBlock <TextPrompt>("text_prompt_ext");
            parser.AddBlock <TextLength>("text_length");
            parser.AddBlock <TextIsEmpty>("text_isEmpty");
            parser.AddBlock <TextTrim>("text_trim");
            parser.AddBlock <TextCaseChange>("text_changeCase");
            parser.AddBlock <TextAppend>("text_append");
            parser.AddBlock <TextJoin>("text_join");
            parser.AddBlock <TextIndexOf>("text_indexOf");

            parser.AddBlock <VariablesGet>("variables_get");
            parser.AddBlock <VariablesSet>("variables_set");

            parser.AddBlock <ColourPicker>("colour_picker");
            parser.AddBlock <ColourRandom>("colour_random");
            parser.AddBlock <ColourRgb>("colour_rgb");
            parser.AddBlock <ColourBlend>("colour_blend");

            parser.AddBlock <ProceduresDef>("procedures_defnoreturn");
            parser.AddBlock <ProceduresDef>("procedures_defreturn");
            parser.AddBlock <ProceduresCallNoReturn>("procedures_callnoreturn");
            parser.AddBlock <ProceduresCallReturn>("procedures_callreturn");
            parser.AddBlock <ProceduresIfReturn>("procedures_ifreturn");

            parser.AddBlock <ListsSplit>("lists_split");
            parser.AddBlock <ListsCreateWith>("lists_create_with");
            parser.AddBlock <ListsLength>("lists_length");
            parser.AddBlock <ListsRepeat>("lists_repeat");
            parser.AddBlock <ListsIsEmpty>("lists_isEmpty");
            parser.AddBlock <ListsGetIndex>("lists_getIndex");
            parser.AddBlock <ListsSetIndex>("lists_setIndex");
            parser.AddBlock <ListsIndexOf>("lists_indexOf");

            return(parser);
        }
示例#4
0
 public BlocklyInterpreter()
 {
     _parser = new Parser();
     _parser.AddStandardBlocks();
     _parser.AddBlock <RespondBlock>("RESPOND");
 }