예제 #1
0
 public void OnCompile(CompilerFuzzy compile)
 {
     if (compile.Syn.GraphsSyntactic != null && compile.Syn.GraphsSyntactic.Count > 0)
     {
         Draw(compile.Syn.GraphsSyntactic[0]);
     }
 }
 public void OnCompile(CompilerFuzzy compile)
 {
     if (compile.Syn is SyntacticAnalysisLR1)
     {
         DrawAutoma((compile.Syn as SyntacticAnalysisLR1).Automa);
     }
 }
        public UCGraphSynToCode(CompilerFuzzy comp)
        {
            this.comp = comp;
            InitializeComponent();
            //this.richTextBoxCodeIn.Text = "get dog ball";////"x=x";"dog get ball";
            this.richTextBoxCodeIn.Text = "dog get ball";////"x=x";"dog get ball";
            //this.richTextBoxCodeIn.Text = "can people";////"x=x";"dog get ball";

            this.Dock = DockStyle.Fill;
            // try
            {
                richTextBoxCodeIn_TextChanged(null, null);
            }
            //catch (Exception ex)
            { }
        }
예제 #4
0
 public UCGraphSyn(CompilerFuzzy compile)
     : this(new Graph <Symbol, double>())
 {
     compile.OnCompile += OnCompile;
 }
 public void OnCompile(CompilerFuzzy compile)
 {
     this.lex = compile.Lex;
     Atualizar();
 }
 public UCGraphLex(CompilerFuzzy compile)
     : this(compile.Lex)
 {
     compile.OnCompile += OnCompile;
 }
 public UCAutomaSyn(CompilerFuzzy compile) : this(compile.Syn)
 {
     compile.OnCompile += OnCompile;
 }
예제 #8
0
        static ExampleAnimals()
        {
            try
            {
                CompilerXmlParser parserXml = new CompilerXmlParser(".\\Examples\\ExampleAnimals1.xml");

                DicCompileExample = new Dictionary <string, Func <Container, string> >();

                //DicCompileExample.Add("Object", c => string.Format("com o objeto {0}", c["ball"].Value));

                //DicCompileExample.Add("Main",
                //        c => c.Count > 1 ? string.Format("Você mandou o {0} realizar a ação de {1}  com o objeto {2}",
                //            c["animal"].Value, c["action"].Value, c["object"].Value) : "");


                DicCompileExample.Add("A", c => string.Format("Você mandou o {0}", c["animal"].Value));

                DicCompileExample.Add("B", c => string.Format("realizar a ação de {0}", c["action"].Value));

                DicCompileExample.Add("C", c => string.Format("com o objeto {0}", c["object"].Value));

                DicCompileExample.Add("D", c => String.Format("{0} {1}", DicCompileExample["B"](c["b"]), DicCompileExample["C"](c["c"])));

                DicCompileExample.Add("Main", c => String.Format("{0} {1}", DicCompileExample["A"](c["a"]), DicCompileExample["D"](c["d"])));

                DicCompileExample.Add("Main1", c => String.Format("{0} {1}", DicCompileExample["E"](c["e"]), DicCompileExample["D"](c["d"])));



                parserXml.Compiler.DicCompile = DicCompileExample;

                parserXml.Compiler.Compile("dog get ball");



                ExampleAnimals.Compiler = parserXml.Compiler;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }

            //            //LR(1)
            //            //0. S
            //            //0 → S$
            //            //1. S → V = E
            //            //2. S → E
            //            //3. E → V
            //            //4. V → x
            //            //5. V → ∗E
            //            List<RecognitionToken> recs = new List<RecognitionToken>();
            //            var dog = new RecognitionToken(1, "dog", "dog", "#7bf6b6");
            //            var cat = new RecognitionToken(2, "cat", "cat", "#7bf6b6");

            //            var get = new RecognitionToken(3, "get", "get", "#f28686");
            //            var sleep = new RecognitionToken(4, "sleep", "sleep", "#fbdb65");

            //            var ball = new RecognitionToken(5, "ball", "ball", "#fbdb65");


            //            recs.Add(dog);
            //            recs.Add(cat);
            //            recs.Add(get);
            //            recs.Add(sleep);
            //            recs.Add(ball);

            //            Grammar grammar = new Grammar();
            //            var catSymbol = new Symbol(1, "cat", true);
            //            catSymbol.SetCustomValue("RecToken", cat);

            //            var dogSymbol = new Symbol(2, "dog", true);
            //            dogSymbol.SetCustomValue("RecToken", dog);

            //            var getSymbol = new Symbol(3, "get", true);
            //            getSymbol.SetCustomValue("RecToken", get);

            ////rabbit
            ////parrot
            ////pick up
            ////to eat
            ////drop
            ////to sleep
            ////feed
            ////ball
            ////toy

            //            var sleepSymbol = new Symbol(4, "sleep", true);
            //            sleepSymbol.SetCustomValue("RecToken", sleep);

            //            var ballSymbol = new Symbol(5, "ball", true);
            //            ballSymbol.SetCustomValue("RecToken", ball);


            //            var s = new Symbol(6, "S", false);
            //            var animal = new Symbol(7, "Animal", false);
            //            var action = new Symbol(8, "Action", false);
            //            var obj = new Symbol(9, "Obj", false);

            //            grammar.Terminals.AddRange(new SymbolList(catSymbol, dogSymbol, getSymbol, sleepSymbol, ballSymbol));

            //            grammar.Variables.AddRange(new SymbolList(s, animal, action, obj));
            //            grammar.VariableStart = s;
            //            //grammar.AddRole(s, animal, action);
            //            grammar.AddRule(s, animal, action, obj);
            //            grammar.Rules[0].Pertinence = 1;
            //            grammar.AddRule(s, animal, action).Parent = grammar.Rules[0];
            //            grammar.Rules[1].Pertinence = 1;
            //            grammar.AddRule(s, action).Parent = grammar.Rules[0];
            //            grammar.Rules[2].Pertinence = 0.8;

            //            grammar.AddRule(animal, dogSymbol);
            //            grammar.AddRule(animal, catSymbol);

            //            grammar.AddRule(action, getSymbol);

            //            grammar.AddRule(obj, ballSymbol);

            //            //var ruleV = grammar.AddRole(V, x);
            //            // grammar.AddRole(V1, equal).Parent = ruleV;

            //            ExampleAnimals.Compiler = new Compiler(recs, grammar);
        }
 public void OnCompile(CompilerFuzzy compile)
 {
     syn = compile.Syn;
     Atualizar();
 }
 public UCTableSyn(CompilerFuzzy compile)
     : this(compile.Syn)
 {
     compile.OnCompile += OnCompile;
 }
예제 #11
0
 public void OnCompile(CompilerFuzzy compile)
 {
     syn = compile.Syn;
     Atualizar();
 }
예제 #12
0
 public UCTableSyn(CompilerFuzzy compile)
     : this(compile.Syn)
 {
     compile.OnCompile += OnCompile;
 }