Example #1
0
        void Start()
        {
            foreach (var name in SGA.MembAC(typeof(Transform), "p", SuggestionTree.MembK.Any()).Select(mi => mi.Name))
            {
                Debug.Log(name);
            }

            // ----------------------------------------

            var GE = new GrammarEntry()
            {
                StartProd      = TestGrammar.StartProd,
                TR_constructor = (nn) => new StartTU((TestGrammar.StartNode)nn)
            };
            var TLHS = new TranslateLHS()
            {
                preCH_LHS = null,
                scope     = new CH_closedScope()
            };
            var compilat = TranslateEntry.TranslateFully(">> :Transform ..position ", GE, TLHS);
            var MM       = new MemMapper();
            var res      = Evaluate.Eval(compilat, MM);

            Analyz0r.A.JsonifyEval(compilat, MM);
            Analyz0r.A.JsonifyCompilat(compilat);
            Debug.Log("DIIIIIIIIIIIIIIIInGs" + string.Join("--", res.values.Select(_ => _.ToString()).ToArray()));
        }
Example #2
0
        public static void Test4_still_fanning_and_analyz0r(bool analyz0r = false)
        {
            var lhsCH = new TypedSingleCH <TestcasesLHSType>();

            var FanGE = new GrammarEntry {
                StartProd      = MG.Fan,
                TR_constructor = (nnode) => new FanTU(new adapter_preCH(lhsCH), (MG.FanNode)nnode)
            };
            var trslLHS = new TranslateLHS {
                preCH_LHS = new adapter_preCH(lhsCH),
                scope     = new CH_closedScope()
            };

            var compilat = TranslateEntry.TranslateFully_incomplete_tolerant(" { ..intMem1 -> x <- @4 ->x2  , ..intMem2  <- $x2 }  ", FanGE, trslLHS);

            if (analyz0r)
            {
                Analyz0r.A.JsonifyCompilat(compilat, "_Test4_still_fanning");
            }

            var MM         = new MemMapper();
            var LHS_column = MM.get(lhsCH);

            LHS_column.AddVal(new TestcasesLHSType());
            LHS_column.AddVal(new TestcasesLHSType());
            LHS_column.AddVal(new TestcasesLHSType());
            Evaluate.Eval(compilat, MM);

            if (analyz0r)
            {
                Analyz0r.A.JsonifyEval(compilat, MM, "_Test4_still_fanning");
            }
        }
Example #3
0
        public static ShellCommon.EVAL_Resp EVAL_stateless(ShellCommon.EVAL_Req eval_req, bool analyz0r = false)
        {
            // fetch evaluation entry from the current junkjard that is EvaluatorTests_and_random_fux0ring.cs

            GrammarEntry GE = new GrammarEntry {
                StartProd      = MG.ProvStart,
                TR_constructor = NN => new TranslateAndEval.ProvStartTU((MG.ProvStartNode)NN)
            };

            TranslateLHS TLHS = new TranslateLHS {
                preCH_LHS = null,
                scope     = new TranslateAndEval.CH_closedScope()
            };
            Compilat compilat;

            try {
                compilat = TranslateEntry.TranslateFully_incomplete_tolerant(eval_req.expr, GE, TLHS);
            } catch (Exception e) {
                return(new ShellCommon.EVAL_Resp {
                    success = false,
                    msg = "translate ERROR : " + e.Message + "\n" + e.StackTrace,
                    result = new SObject[0]
                });
            }

            if (analyz0r)
            {
                Analyz0r.A.JsonifyCompilat(compilat);
            }

            var MM = new TranslateAndEval.MemMapper();

            TranslateAndEval.Column resultColumn;
            try {
                resultColumn = Evaluate.Eval(compilat, MM);
            } catch (Exception e) {
                return(new ShellCommon.EVAL_Resp {
                    success = false,
                    msg = "eval ERROR : " + e.Message + "\n" + e.StackTrace,
                    result = new SObject[0]
                });
            }

            try {
                if (analyz0r)
                {
                    Analyz0r.A.JsonifyEval(compilat, MM);
                }
            } catch (Exception) {}   // TODO - write a message to the file about how this crashed

            var resp = new ShellCommon.EVAL_Resp {
                success = true,
                msg     = "OK",
                result  = resultColumn.values.ToArray()     // <- current serialization (ShellNetworkGlue.cs) simply does a ToString() for all Objects
            };

            return(resp);
        }
Example #4
0
        public static void Test2()
        {
            CH_closedScope sc = DummyInstances.DummyScope();
            string         expr_l = "..str", expr_r = " -> foo ";
            string         expr = expr_l + expr_r;

            Tok[] strippedToks = TranslateEntry.LexxAndStripWS(expr);
            var   NN           = TranslateEntry.Scope(strippedToks, DummyInstances.GE_TestStartRX, DummyInstances.DummyTransLHS);
        }
Example #5
0
    public static Column Eval_incomplete_tolerant(string strExpr, GrammarEntry GE, TranslateLHS trans_LHS, MemMapper MM, out CH_closedScope scope_out)
    {
        var compilat = TranslateEntry.TranslateFully_incomplete_tolerant(strExpr, GE, trans_LHS);

        scope_out = compilat.deltaScope.close();

        #if todo_fixme             // external refs in the scopes still need implementation ( done . todo plug this shit in )
        foreach (var sc_ref in compilat.ownDecls)
        {
            scope_out = (ClosedScope)scope_out.decl(sc_ref);
        }
        #endif
        compilat.run(MM);  // atm the MM keeps references on tmp columns around forever - some pruning mechanism is needed
        VBoxTU last_VBT = compilat.VBoxTrs.Last();
        return(MM.getGen(last_VBT.CH_out));
    }
Example #6
0
        public static ShellCommon.TYPEINFO_Resp TYPEINFO(ShellCommon.TYPEINFO_Req req)
        {
            // only do this for requests that are valid to be exectuted -> no relaxed grammar

            // thus, most of this is copypasta from Operations_EVAL.cs

            GrammarEntry GE = new GrammarEntry {
                StartProd      = MG.ProvStart,
                TR_constructor = NN => new TranslateAndEval.ProvStartTU((MG.ProvStartNode)NN)
            };

            TranslateLHS TLHS = new TranslateLHS {
                preCH_LHS = null,
                scope     = new TranslateAndEval.CH_closedScope()
            };
            Compilat compilat;

            try {
                compilat = TranslateEntry.TranslateFully_incomplete_tolerant(req.expression, GE, TLHS);
            } catch (Exception e) {
                return(new ShellCommon.TYPEINFO_Resp {
                    success = false,
                    msg = e.Message,
                    // defaults to make serialization easier -- little use in specifying a contract here, as this is likely to change anyway
                    members = new System.Type[0]
                });
            }

            var result_type = compilat.VBoxTrs.Last().CH_out.ttuple.PayT;  // out-Type of last column

            var memIs = result_type
                        .GetMembers()
                        .Where(x => x.MemberType == System.Reflection.MemberTypes.Field || x.MemberType == System.Reflection.MemberTypes.Property)
                        .ToArray();



            return(new ShellCommon.TYPEINFO_Resp {
                success = true,
                msg = "",
                expr_unity_type = result_type,
                unique = true,                      // FIXME : todo
                members = memIs
            });
        }
Example #7
0
        public static void GreenCameraTest()
        {
        #if NetworklessShell
            Console.WriteLine(" --- GreenCameraTest() ---");
            var go_foo_cam = new GameObject();
            go_foo_cam.AddComponent <Camera>();
            go_foo_cam.GetComponent <Camera>().name = "foo";

            var go_other_cam = new GameObject();
            go_other_cam.AddComponent <Camera>();

            Resources.roots = new [] { go_foo_cam, go_other_cam };


            var query = ">> :Camera .%projectionMatrix <- @[[1,1,1,1],[2,2,2,2],[3,3,3,3],[4,4,4,4]]";

            var GramE = new GrammarEntry {
                StartProd      = MG.ProvStart,
                TR_constructor = (prov_start_node) => new ProvStartTU((MG.ProvStartNode)prov_start_node)
            };
            var transl_LHS = new TranslateLHS {
                preCH_LHS = null,
                scope     = new CH_closedScope()
            };

            var compilat1 = TranslateEntry.TranslateFully_incomplete_tolerant(query, GramE, transl_LHS);

            var MM  = new MemMapper();
            var res = Evaluate.Eval(compilat1, MM);

            Console.WriteLine(res);
            var query2    = ">> :Camera {.name == @\"foo\"} .projectionMatrix <- @[[1,1,1,1],[2,2,2,2],[3,3,3,3],[4,4,4,4]]";
            var compilat2 = TranslateEntry.TranslateFully_incomplete_tolerant(query2, GramE, transl_LHS);

            Analyz0r.A.JsonifyCompilat(compilat2, "_GreenCam_with_fan");

            var res2 = Evaluate.Eval(compilat2, MM);
            Console.WriteLine(res2);

            Analyz0r.A.JsonifyEval(compilat2, MM, "_GreenCam_with_fan");

            Console.WriteLine(" --- GreenCameraTest() done ---");
        #endif
        }
Example #8
0
    public static NamedNode GetAST_ptokBase(IEnumerable <PTokBase> toksBase)
    {
        var Stripped = toksBase.Where(tok => tok is PTok).Select(tok => (PTok)tok);

        /*
         * todo : this version of scope throws on incomplete parse - should be allowed for interactive
         * also : how to deal with cursor pos beyond the end of an incomplete parse ? ( analog problem to synced walking for Colorize() in the console )
         */
        GrammarEntry GE = new GrammarEntry {
            StartProd = MGRX.ProvStartRX,

            /*
             *  preCH_in :
             *  the first mandatory SG operator acts on an implicit instance of a dummy type ( the PhantomRoot )
             */
            TR_constructor = (NN) => new ProvStartTU_RX((MainGrammarRX.ProvStartNodeRX)NN)
        };
        TranslateLHS TR_lhs = new TranslateLHS {
            preCH_LHS = null,   //new adapter_preCH ( new TypedSingleCH<GameObject>() ) ,
            scope     = new CH_closedScope()
        };

        return(TranslateEntry.ScopePartial(Stripped, GE, TR_lhs));
    }
Example #9
0
        public static ParserComb.NamedNode LexxAndParse(string arg, ParserComb.Parser <Tok> .PI startProd)
        {
            var parse_matches = TestMG1.RUN_with_rest(startProd, TranslateEntry.LexxAndStripWS(arg));

            return(parse_matches.First().N);
        }
        public void setTranslationValues()
        {
            TranslationEntry.Clear();
            foreach (var k in TransResult.results)
            {
                if (k.lexicalEntries != null)
                {
                    foreach (var i in k.lexicalEntries)
                    {
                        var trans_item = new TranslateEntry();
                        trans_item.Type         = i.lexicalCategory;
                        trans_item.Examples     = "Examples: \n\n";
                        trans_item.Translations = "Translations: \n\n";
                        if (i.entries != null)
                        {
                            foreach (var j in i.entries)
                            {
                                if (j.senses != null)
                                {
                                    foreach (var y in j.senses)
                                    {
                                        if (y.translations != null)
                                        {
                                            foreach (var x in y.translations)
                                            {
                                                if (!trans_item.Translations.Contains(x.text))
                                                {
                                                    trans_item.Translations += x.text + "\n";
                                                }
                                            }
                                        }
                                        if (y.examples != null)
                                        {
                                            foreach (var example in y.examples)
                                            {
                                                if (example.translations != null)
                                                {
                                                    trans_item.Examples += example.text + "\n" + example.translations.ElementAt(0).text + "\n\n";
                                                }
                                            }
                                        }
                                        if (y.subsenses != null)
                                        {
                                            foreach (var x in y.subsenses)
                                            {
                                                if (x.translations != null)
                                                {
                                                    foreach (var trans in x.translations)
                                                    {
                                                        if (!trans_item.Translations.Contains(trans.text))
                                                        {
                                                            trans_item.Translations += trans.text + "\n";
                                                        }
                                                    }
                                                }
                                                if (x.examples != null)
                                                {
                                                    foreach (var example in x.examples)
                                                    {
                                                        if (example.translations != null)
                                                        {
                                                            trans_item.Examples += example.text + "\n" + example.translations.ElementAt(0).text + "\n\n";
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }

                        TranslationEntry.Add(trans_item);
                    }
                }
            }
        }