示例#1
0
        private void DrawReduction(StringBuilder tree, GOLD.Reduction reduction, int indent)
        {
            int n;
            string indentText = "";

            for (n = 1; n <= indent; n++)
                indentText += "| ";

            for (n = 0; n < reduction.Count(); n++)
            {
                switch (reduction[n].Type())
                {
                    case GOLD.SymbolType.Nonterminal:
                        GOLD.Reduction branch = (GOLD.Reduction)reduction[n].Data;

                        tree.AppendLine(indentText + "+-" + branch.Parent.Text(false));
                        DrawReduction(tree, branch, indent + 1);
                        break;

                    default:
                        string leaf = (string)reduction[n].Data;

                        tree.AppendLine(indentText + "+-" + leaf);
                        break;
                }
            }
        }
        public object Execute(GOLD.Reduction node)
        {
            Console.WriteLine(Environment.NewLine + "(VVV) Program Line (VVV)" + Environment.NewLine);

            // Itt vagy Expression, vagy Statement, vagy CommentLine vagy semmi !!!
            try {
                string type = Regex.Replace(node[0].Parent.ToString(), "[^0-9a-zA-Z]+", "");
                Enums.eNonTerminals ntt = (Enums.eNonTerminals)Enum.Parse(typeof(Enums.eNonTerminals), type);

                switch (ntt)
                {
                    case Enums.eNonTerminals.Expression:
                        var returnValue = Context.NonTerminalContext.Execute(ntt, (GOLD.Reduction)node[0].Data);
                        Console.WriteLine("################################################################");
                        Console.WriteLine("# Programline value: " + returnValue + "\ttype: " + returnValue.GetType());
                        Console.WriteLine("################################################################" + Environment.NewLine);
                        return returnValue;

                    default:
                        throw new NotImplementedException();
                }
            }
            catch (Exception)
            {
                string EMPTY = "Empty ProgramLine";
                return EMPTY;
            }
        }
示例#3
0
        public Results(AnalyseType analyser, bool errors, string failMessage, GOLD.Reduction root)
        {
            InitializeComponent();
            this.ShowInTaskbar = true;
            this.Title = analyser == AnalyseType.lexical
                ? "Lexical analyzer results"
                : "Syntax analyzer results";

            if (errors)
                txtTree.Text = String.Format("An error occured while trying to parse code.\n{0}", failMessage);
            else
            {
                _root = root;

                switch (analyser)
                {
                    case (AnalyseType.lexical):
                        ShowTokens();
                        break;
                    case (AnalyseType.syntax):
                        ShowParseTree();
                        break;
                    default:
                        break;
                }
            }
        }
示例#4
0
        public object Execute(GOLD.Reduction node)
        {
            string DEBUG = "DEBUG - Container";
            List<string> _operand = null;

            // lehet List vagy ID
            switch (node[0].Type())
            {
                case SymbolType.Nonterminal: // Nemterminálisok vizsgálata
                    
                    string type = Regex.Replace(node[0].Parent.ToString(), "[^0-9a-zA-Z]+", "");
                    Enums.eNonTerminals ntt = (Enums.eNonTerminals)Enum.Parse(typeof(Enums.eNonTerminals), type);

                    _operand = (List<string>) Context.NonTerminalContext.Execute(ntt, (GOLD.Reduction)node[0].Data);

                    return _operand;

                case SymbolType.Error:
                    Console.WriteLine("ERROR in Logical_Engine.Classes.Processor.ProcessTree");
                    break;

                default:
                    // Terminálisok vizsgálata - itt egy ID
                    List<string> retVal = new List<string>();
                    retVal.Add(node[0].Data as string);
                    return retVal;
            }

            return DEBUG;
        }
示例#5
0
        public object Execute(GOLD.Reduction node)
        {

            if (node.Count() == 2)
            {
                // ID [szóköz] Indexer
                string _operator = null;
                object _operand = null;

                for (int i = 0; i < node.Count(); i++)
                {
                    switch (node[i].Type())
                    {
                        case SymbolType.Nonterminal: // Nemterminálisok vizsgálata

                            string type = Regex.Replace(node[i].Parent.ToString(), "[^0-9a-zA-Z]+", "");
                            Enums.eNonTerminals ntt = (Enums.eNonTerminals)Enum.Parse(typeof(Enums.eNonTerminals), type);

                            _operand = Context.NonTerminalContext.Execute(ntt, (GOLD.Reduction)node[i].Data);
                            break;

                        case SymbolType.Error:
                            Console.WriteLine("ERROR in Logical_Engine.Classes.Processor.ProcessTree");
                            break;

                        default:
                            // Terminálisok vizsgálata - itt maga az ID
                            _operator = node[i].Data as string;
                            break;
                    }
                }

                string _path = _operator + ":" + _operand.ToString();

                if (_operator != null)
                    _operand = Operation(_operand, _operator, null);
                Console.WriteLine("Element value: " + _operand + "\ttype: " + _operand.GetType());
                return _path;
            }
            else
            {
                // egy nem terminális van, azt kell lebontani, majd
                // értékadás/másolás
                try
                {
                    return node[0].Data.ToString();
                }
                catch (InvalidCastException ice)
                {
                    Console.WriteLine(ice.Message);
                }
                catch (Exception exc)
                {
                    Console.WriteLine(exc.Message);
                }
            }
            return null;
        }
示例#6
0
        public string DrawReductionTree(GOLD.Reduction root)
        {
            StringBuilder tree = new StringBuilder();

            tree.AppendLine("+-" + root.Parent.Text(false));
            DrawReduction(tree, root, 1);

            return tree.ToString();
        }
示例#7
0
        /// <summary>
        /// A parszolási fa generálását elindító rekurziós fej
        /// </summary>
        /// <param name="Root">A lebontási fa gyökéreleme</param>
        /// <returns>a lebontási fa tagoltan, szöveg formátumban</returns>
        private string DrawReductionTree(GOLD.Reduction Root)
        {
            //This procedure starts the recursion that draws the parse tree.
            StringBuilder tree = new StringBuilder();

            tree.AppendLine("Non Terminal\t+-" + Root.Parent.Text(false));
            DrawReduction(tree, Root, 1);

            return tree.ToString();
        }
示例#8
0
        public object Execute(GOLD.Reduction node)
        {
            string DEBUG = "DEBUG - Items";
            object _item = null, _operator = null;
            object _items = null;   /// TODO: Meg kell oldani a lista kezelését, egyelőre még a lista is egy item jellegű objektum (akár listaelemek konkatenációjából álló string)

            if (node.Count() == 3)
            {// <Item> ',' <Items>
                for (int i=0; i<node.Count(); i++)
                {
                    switch (node[i].Type())
                    {
                        case GOLD.SymbolType.Nonterminal: // Nemterminálisok vizsgálata

                            string type = Regex.Replace(node[i].Parent.ToString(), "[^0-9a-zA-Z]+", "");
                            Enums.eNonTerminals ntt = (Enums.eNonTerminals)Enum.Parse(typeof(Enums.eNonTerminals), type);

                            if (_item == null)
                            {
                                _item = Context.NonTerminalContext.Execute(ntt, (GOLD.Reduction)node[i].Data);
                            }
                            else if (_items == null)
                            {
                                _items = Context.NonTerminalContext.Execute(ntt, (GOLD.Reduction)node[i].Data);
                            }

                            break;

                        case GOLD.SymbolType.Error:
                            Console.WriteLine("ERROR in Logical_Engine.Classes.Processor.ProcessTree");
                            break;

                        default:
                            // Terminálisok vizsgálata - itt egy vessző
                            _operator = node[i].Data as string;
                            break;
                    }
                }

                object returnValue = _item.ToString() + "," + _items.ToString();
                return returnValue;

            }
            else if (node.Count() == 1)
            {// <Item>
                string type = Regex.Replace(node[0].Parent.ToString(), "[^0-9a-zA-Z]+", "");
                Enums.eNonTerminals ntt = (Enums.eNonTerminals)Enum.Parse(typeof(Enums.eNonTerminals), type);

                object returnValue = Context.NonTerminalContext.Execute(ntt, (GOLD.Reduction)node[0].Data);
                return returnValue;
            }

            Console.WriteLine(DEBUG);
            return DEBUG;
        }
        public static UIGroup FromReduction(GOLD.Reduction r)
        {
            UIGroup result = new UIGroup();
            // <Object> ::= BeginLiteral <Content> EndLiteral
            var content = (List<UINode>)r.get_Data(1);
            var sharedProps = content.FirstOrDefault(x => x.Name == "SetSharedProperties");

            result.SharedProperties = sharedProps;
            result.Children = content.Where(x => x != sharedProps).ToList();

            return result;
        }
 public void Add(GOLD.Token gt)
 {
     Node node = new Node();
     node.Data = gt;
     try
     {
         Elements.Add(node);
     }catch (Exception exc)
     {
         Console.WriteLine(exc);
     }
     DefinedList.CompositionList.Add(null);
 }
示例#11
0
        public object Execute(GOLD.Reduction node)
        {
            object _operand = null;

            string type = Regex.Replace(node[1].Parent.ToString(), "[^0-9a-zA-Z]+", "");
            Enums.eNonTerminals ntt = (Enums.eNonTerminals)Enum.Parse(typeof(Enums.eNonTerminals), type);

            _operand = Context.NonTerminalContext.Execute(ntt, (GOLD.Reduction)node[1].Data);

            List<string> returnValue = (List<string>) Operation(null, _operand.ToString(), null);

            return returnValue;
        }
示例#12
0
        private void button_Copy2_Click(object sender, RoutedEventArgs e)
        {
            GOLD emas = new GOLD()
            {
                TYPE           = ttype.Text,
                UNIT           = tunit.Text,
                SELLING_PRICE  = Convert.ToInt32(tselling.Text),
                PURCHASE_PRICE = Convert.ToInt32(tpurchase.Text)
            };

            db.GOLDs.Add(emas);
            db.SaveChanges();
            Home.datagrid.ItemsSource = db.GOLDs.ToList();
            this.Hide();
        }
示例#13
0
        public object Execute(GOLD.Reduction node)
        {
            List<string> _operand = null;

            try { 

                // lehet List vagy ID
                switch (node[1].Type())
                {
                    case SymbolType.Nonterminal: // Nemterminálisok vizsgálata

                        string type = Regex.Replace(node[1].Parent.ToString(), "[^0-9a-zA-Z]+", "");
                        Enums.eNonTerminals ntt = (Enums.eNonTerminals)Enum.Parse(typeof(Enums.eNonTerminals), type);

                        _operand = (List<string>)Context.NonTerminalContext.Execute(ntt, (GOLD.Reduction)node[1].Data);

                        return _operand;

                    case SymbolType.Error:
                        break;

                    default:
                        // Terminálisok vizsgálata - itt egy StringLiteral vagy null
                        try
                        {
                            List<string> retVal = new List<string>();
                            string returnValue = node[1].Data.ToString();
                            returnValue = Regex.Replace(returnValue, "\"", "");
                            retVal.Add(returnValue);
                            return retVal;
                        }
                        catch (Exception)
                        {
                            return null;
                        }
                    
                }
            }
            catch (Exception)   // nincs where feltétel megadva
            {
                return null;
            }
            return null;
        }
        public object Execute(GOLD.Reduction node)
        {
            List<string> container = null;
            List<string> whereClosure = null;
            List<string> orderByClosure = null;

            List<string> retVal;

            for (int i = 2; i < node.Count(); i++)
            {
                string type = Regex.Replace(node[i].Parent.ToString(), "[^0-9a-zA-Z]+", "");
                Enums.eNonTerminals ntt = (Enums.eNonTerminals)Enum.Parse(typeof(Enums.eNonTerminals), type);

                if (container == null)
                {
                    // egyelőre használaton kívül van, valamint ezt lehet, hogy projekt specifikusan át kell írni nyelvtan szinten is
                    container = (List<string>) Context.NonTerminalContext.Execute(ntt, (GOLD.Reduction)node[i].Data);
                }
                else if (whereClosure == null)
                {
                    whereClosure = (List<string>) Context.NonTerminalContext.Execute(ntt, (GOLD.Reduction)node[i].Data);
                }
                else if (orderByClosure == null)
                {
                    orderByClosure = (List<string>) Context.NonTerminalContext.Execute(ntt, (GOLD.Reduction)node[i].Data);
                }
            }

            ///Amennyiben a szervertől valamiért csak egy obj jönne vissza, azt is listába kell rakni, mert a GetExpression mindenképp listval tér vissza
            object SO = SpecialOperation(container, whereClosure, orderByClosure);
            if (SO is List<string>)
            {
                retVal = (List<string>)SO;
                return retVal;
            }
            else
            {
                retVal = new List<string>();
                retVal.Add(SO as string);
                return retVal;
            }
        }
示例#15
0
        private void UpdateGold()
        {
            GOLD updategold = (from g in db.GOLDs
                               where g.ID == id
                               select g).Single();

            ttype.Text     = "" + updategold.TYPE;
            tunit.Text     = "" + updategold.UNIT;
            tselling.Text  = "" + updategold.SELLING_PRICE;
            tpurchase.Text = "" + updategold.PURCHASE_PRICE;

            updategold.TYPE           = ttype.Text;
            updategold.UNIT           = tid.Text;
            updategold.SELLING_PRICE  = Convert.ToInt32(tselling.Text);
            updategold.PURCHASE_PRICE = Convert.ToInt32(tpurchase.Text);

            db.SaveChanges();
            Home.datagrid.ItemsSource = db.GOLDs.ToList();
            this.Hide();
        }
示例#16
0
        private void Recursion(GOLD.Reduction reduction)
        {
            for (int i = 0; i < reduction.Count(); i++)
            {
                switch (reduction[i].Type())
                {
                    case GOLD.SymbolType.Nonterminal:
                        GOLD.Reduction branch = (GOLD.Reduction)reduction[i].Data;
                        Recursion(branch);
                        break;
                    default:
                        _tokensXmlWriter.WriteStartElement("token");

                        var reduct = reduction[i] as GOLD.Token;
                        _tokensXmlWriter.WriteAttributeString("line", reduct.Position().Line.ToString());
                        _tokensXmlWriter.WriteAttributeString("position", reduct.Position().Column.ToString());
                        _tokensXmlWriter.WriteAttributeString("type", reduct.Parent.Name());
                        _tokensXmlWriter.WriteAttributeString("value", reduct.Data.ToString());

                        _tokensXmlWriter.WriteEndElement();
                        break;
                }
            }
        }
 /// <summary>
 /// A megfelelő nemterminálishoz tartozó lefutási függvény hívását vezérlő eljárás
 /// </summary>
 /// <param name="type">Az eljárást végző nemterminális</param>
 /// <param name="node">Adott levél a parszolási fában</param>
 /// <returns>Az adott nemterminális által, az adott levélhez kiértékelt objektum</returns>
 public static object Execute (Enums.eNonTerminals type, GOLD.Reduction node)
 {
     return _strategies[type].Execute(node);
 }
示例#18
0
        public object Execute(GOLD.Reduction node)
        {
            if (node.Count() == 3)
            {
                // van operátor és két operandus, először a két nem terminálist bontom, majd a terminálisként adott operátorral
                // elvégzem a megfelelő műveletet és értéket adok/másolom

                string _operator = null;
                object _operand1 = null
                    , _operand2 = null
                    ;

                for (int i = 0; i < node.Count(); i++)
                {
                    switch (node[i].Type())
                    {
                        case GOLD.SymbolType.Nonterminal: // Nemterminálisok vizsgálata

                            string type = Regex.Replace(node[i].Parent.ToString(), "[^0-9a-zA-Z]+", "");
                            Enums.eNonTerminals ntt = (Enums.eNonTerminals)Enum.Parse(typeof(Enums.eNonTerminals), type);

                            if (_operand1 == null)
                            {
                                _operand1 = Context.NonTerminalContext.Execute(ntt, (GOLD.Reduction)node[i].Data);
                            }
                            else
                            {
                                _operand2 = Context.NonTerminalContext.Execute(ntt, (GOLD.Reduction)node[i].Data);
                            }

                            break;

                        case GOLD.SymbolType.Error:
                            Console.WriteLine("ERROR in Logical_Engine.Classes.Processor.ProcessTree");
                            break;

                        default:
                            // Terminálisok vizsgálata - itt operátor jel
                            _operator = node[i].Data as string;
                            break;
                    }
                }

                if (_operator != null)
                    _operand1 = Operation(_operand1, _operator, _operand2);
                Console.WriteLine("Expression value: " + _operand1 + "\ttype: " + _operand1.GetType());
                return _operand1;

            }
            else
            {
                // egy nem terminális van, azt kell lebontani, majd
                // értékadás/másolás
                string type = Regex.Replace(node[0].Parent.ToString(), "[^0-9a-zA-Z]+", "");
                Enums.eNonTerminals ntt = (Enums.eNonTerminals)Enum.Parse(typeof(Enums.eNonTerminals), type);

                object returnValue = Context.NonTerminalContext.Execute(ntt, (GOLD.Reduction)node[0].Data);
                Console.WriteLine("Expression value: " + returnValue + "\ttype: " + returnValue.GetType());
                return returnValue;
            }
        }
 protected abstract object CreateObjectFor(GOLD.Engine.Reduction r);
示例#20
0
        private object CreateNewObject(GOLD.Reduction r)
        {
            object result = null;

            switch ((ProductionIndex)r.Parent.TableIndex()) {
                case ProductionIndex.Nl_Newline:
                    // <nl> ::= NewLine <nl>
                    break;

                case ProductionIndex.Nl_Newline2:
                    // <nl> ::= NewLine
                    break;

                case ProductionIndex.Regform_Pipepipe:
                    // <regForm> ::= <regForm> '||' <regFormSeq>
                    result = new UnionFormula((RegularFormula)r[0].Data, (RegularFormula)r[2].Data);
                    break;

                case ProductionIndex.Regform:
                    // <regForm> ::= <regFormSeq>
                    result = r[0].Data;
                    break;

                case ProductionIndex.Regformseq_Dot:
                    // <regFormSeq> ::= <regFormSeq> '.' <regFormValue>
                    result = new SequenceFormula((RegularFormula)r[0].Data, (RegularFormula)r[2].Data);
                    break;

                case ProductionIndex.Regformseq:
                    // <regFormSeq> ::= <regFormValue>
                    result = r[0].Data;
                    break;

                case ProductionIndex.Regformvalue_Identifier:
                    // <regFormValue> ::= Identifier <Multiplier>
                    result = new SingleAction((string)r[0].Data, (string)r[1].Data);
                    break;

                case ProductionIndex.Regformvalue_Not:
                    // <regFormValue> ::= not <regForm>
                    result = new NegateAction((RegularFormula)r[1].Data);
                    break;

                case ProductionIndex.Regformvalue_Lparen_Rparen:
                    // <regFormValue> ::= '(' <regForm> ')' <Multiplier>
                    if ((string)r[3].Data != "")
                        return new NestedFormula((RegularFormula)r[1].Data, (string)r[3].Data);
                    else // small optimization
                        result = r[1].Data;
                    break;

                case ProductionIndex.Multiplier_Plus:
                    // <Multiplier> ::= '+'
                    result = "+";
                    break;

                case ProductionIndex.Multiplier_Times:
                    // <Multiplier> ::= '*'
                    result = "*";
                    break;

                case ProductionIndex.Multiplier:
                    // <Multiplier> ::=
                    result = "";
                    break;

                case ProductionIndex.Muform_Identifier:
                    // <muForm> ::= Identifier
                    result = new Proposition((string)r[0].Data);
                    break;

                case ProductionIndex.Muform_Variable:
                    // <muForm> ::= Variable
                    result = new Variable((string)r[0].Data);
                    break;

                case ProductionIndex.Muform_Lparen_Pipepipe_Rparen:
                    // <muForm> ::= '(' <muForm> '||' <muForm> ')'
                    result = new Disjunction((MuFormula)r[1].Data, (MuFormula)r[3].Data);
                    break;

                case ProductionIndex.Muform_Lparen_Ampamp_Rparen:
                    // <muForm> ::= '(' <muForm> '&&' <muForm> ')'
                    result = new Conjunction((MuFormula)r[1].Data, (MuFormula)r[3].Data);
                    break;

                case ProductionIndex.Muform_Lt_Gt:
                    // <muForm> ::= '<' <regForm> '>' <muForm>
                    result = new Diamond((RegularFormula)r[1].Data, (MuFormula)r[3].Data);
                    break;

                case ProductionIndex.Muform_Lbracket_Rbracket:
                    // <muForm> ::= '[' <regForm> ']' <muForm>
                    result = new Box((RegularFormula)r[1].Data, (MuFormula)r[3].Data);
                    break;

                case ProductionIndex.Muform_Mu_Variable_Dot:
                    // <muForm> ::= mu Variable '.' <muForm>
                    result = new Mu(new Variable((string)r[1].Data), (MuFormula)r[3].Data);
                    break;

                case ProductionIndex.Muform_Nu_Variable_Dot:
                    // <muForm> ::= nu Variable '.' <muForm>
                    result = new Nu(new Variable((string)r[1].Data), (MuFormula)r[3].Data);
                    break;

                case ProductionIndex.Muform_Not:
                    // <muForm> ::= not <muForm>
                    result = new Negation((MuFormula)r[1].Data);
                    break;

                case ProductionIndex.Muform_Lparen_Rparen:
                    result = r[1].Data as MuFormula;
                    break;

                case ProductionIndex.Line_Commentl:
                    // <Line> ::= CommentL <nl>
                    break;

                case ProductionIndex.Line:
                    // <Line> ::= <muForm> <nl>
                    var form = (MuFormula)r[0].Data;
                    FormulaRewriter.ResetFreeVars();
                    form = FormulaRewriter.Rewrite(form);
                    form.SetParents(null /* root has no parent */);
                    formulas.Add(form);
                    break;

                case ProductionIndex.Line2:
                    // <Line> ::= <nl>
                    break;

                case ProductionIndex.Lines:
                    // <Lines> ::= <Line> <Lines>
                    break;

                case ProductionIndex.Lines2:
                    // <Lines> ::=
                    break;

            } //switch

            return result;
        }
示例#21
0
        /// <summary>
        /// A lebontási fa egyes leveleihez tartozó értékek adott szintnek megfelelő szöveges reprezentációját végzi tagolási eljárásokkal egybekötve
        /// </summary>
        /// <param name="tree">A visszatérési szöveget tároló StringBuilder objektum</param>
        /// <param name="reduction">Egy adott levelet reprezentáló GOLD.Reduction típus</param>
        /// <param name="indent">Az adott mélység számban kifejezve</param>
        /// <remarks>
        /// A függvény csupán a szöveges formátumú lebontási fa reprezentációját hivatott létrehozni
        /// </remarks>
        private void DrawReduction(StringBuilder tree, GOLD.Reduction reduction, int indent)
        {
            //This is a simple recursive procedure that draws an ASCII version of the parse
            //tree

            int n;
            string indentText = "";

            for (n = 1; n <= indent; n++)
            {
                indentText += "| ";
            }

            //=== Display the children of the reduction
            for (n = 0; n < reduction.Count(); n++)
            {
                switch (reduction[n].Type())
                {
                    case GOLD.SymbolType.Nonterminal:
                        GOLD.Reduction branch = (GOLD.Reduction)reduction[n].Data;

                        tree.AppendLine("Non Terminal\t" + indentText + "+-" + branch.Parent.Text(false));
                        DrawReduction(tree, branch, indent + 1);
                        break;

                    default:
                        string leaf = (string)reduction[n].Data;
                        tree.AppendLine("Terminal\t\t" + indentText + " + -" + leaf);
                        break;
                }
            }
        }
示例#22
0
        public object Execute(GOLD.Reduction node)
        {
            if (node.Count() == 3)
            {
                // zárójel és benne egy expression van
                // az expressiont kiértékelem és azzal majd valamit kezdek

                string  _operator1 = null
                    ,   _operator2 = null
                    ;
                object _operand = null;

                for (int i = 0; i < node.Count(); i++)
                {
                    switch (node[i].Type())
                    {
                        case GOLD.SymbolType.Nonterminal: // Nemterminálisok vizsgálata

                            string type = Regex.Replace(node[i].Parent.ToString(), "[^0-9a-zA-Z]+", "");
                            Enums.eNonTerminals ntt = (Enums.eNonTerminals)Enum.Parse(typeof(Enums.eNonTerminals), type);
                            
                            _operand = Context.NonTerminalContext.Execute(ntt, (GOLD.Reduction)node[i].Data);
                            
                            break;

                        case GOLD.SymbolType.Error:
                            Console.WriteLine("ERROR in Logical_Engine.Classes.Processor.ProcessTree");
                            break;

                        default:
                            // Terminálisok vizsgálata - itt operátor jel
                            if (_operator1 == null)
                            {
                                _operator1 = node[i].Data as string;
                            }
                            else
                            {
                                _operator2 = node[i].Data as string;
                            }
                            break;
                    }
                }

                if (_operator1 == null && _operator2 == null)
                    throw new OperationCanceledException("Missing bracket(s)");
                Console.WriteLine("Factor value: " + _operand + "\ttype: " + _operand.GetType());
                return _operand;
            }
            else if (node.Count() == 2)
            {
                // valamilyen operátor és egy nem terminális
                // kiértékelem a nem terminálist, majd alkalmazom az operátor által megszabott műveletet
                string _operator = null;
                object _operand = null;

                for (int i = 0; i < node.Count(); i++)
                {
                    switch (node[i].Type())
                    {
                        case GOLD.SymbolType.Nonterminal: // Nemterminálisok vizsgálata

                            string type = Regex.Replace(node[i].Parent.ToString(), "[^0-9a-zA-Z]+", "");
                            Enums.eNonTerminals ntt = (Enums.eNonTerminals)Enum.Parse(typeof(Enums.eNonTerminals), type);
                            
                            _operand = Context.NonTerminalContext.Execute(ntt, (GOLD.Reduction)node[i].Data);

                            break;

                        case GOLD.SymbolType.Error:
                            Console.WriteLine("ERROR in Logical_Engine.Classes.Processor.ProcessTree");
                            break;

                        default:
                            // Terminálisok vizsgálata - itt operátor jel
                            _operator = node[i].Data as string;
                            break;
                    }
                }

                if (_operator != null)
                    _operand = Operation(_operand, _operator, null);
                Console.WriteLine("Factor value: " + _operand + "\ttype: " + _operand.GetType());
                return _operand;
            }
            else
            {
                // egy nem terminális van, azt kell lebontani, majd
                // értékadás/másolás
                object returnValue = null;
                try
                {
                    if (node[0].Parent.ToString().Equals("NumberLiteral"))
                    {
                        returnValue = Int32.Parse(node[0].Data.ToString());
                        Console.WriteLine("Factor value: " + returnValue + "\ttype: " + returnValue.GetType());
                        return Int32.Parse(node[0].Data.ToString());
                    }
                    else if (node[0].Parent.ToString().Equals("RealLiteral"))
                    {
                        returnValue = float.Parse(node[0].Data.ToString());
                        Console.WriteLine("Factor value: " + returnValue + "\ttype: " + returnValue.GetType());
                        return float.Parse(node[0].Data.ToString());
                    }
                    else if (node[0].Parent.ToString().Equals("StringLiteral"))
                    {
                        returnValue = node[0].Data.ToString();
                        Console.WriteLine("Factor value: " + returnValue + "\ttype: " + returnValue.GetType());
                        return node[0].Data.ToString();
                    }
                    else if (node[0].Parent.ToString().Equals("BooleanLiteral"))
                    {
                        if (node[0].Data.ToString().Equals("true") || node[0].Data.ToString().Equals("yes"))
                        {
                            return true;
                        }
                        else
                        {
                            return false;
                        }
                    }
                    else if (node[0].Parent.ToString().Equals("<Chain>"))
                    {
                        string type = Regex.Replace(node[0].Parent.ToString(), "[^0-9a-zA-Z]+", "");
                        Enums.eNonTerminals ntt = (Enums.eNonTerminals)Enum.Parse(typeof(Enums.eNonTerminals), type);
                        try
                        {
                            returnValue = Context.NonTerminalContext.Execute(ntt, (GOLD.Reduction)node[0].Data);
                            returnValue = ServiceHandler.ServiceHandler.getData(returnValue as string);
                            int s;
                            if (int.TryParse(returnValue.ToString(), out s))
                            {
                                return s;
                            }

                            float t;
                            if (float.TryParse(returnValue.ToString(), out t))
                            {
                                return t;
                            }

                            if (returnValue.ToString().Contains("."))
                            {
                                string[] u = returnValue.ToString().Split('.');
                                if (u.Length == 4)
                                {
                                    try
                                    {
                                        return new DateTime(Int32.Parse(u[0]), Int32.Parse(u[1]), Int32.Parse(u[2]));
                                    }
                                    catch(Exception exc)
                                    {
                                        Console.WriteLine(exc.Message);
                                        string ERROR = "ERROR";
                                        return ERROR;
                                    }
                                }
                            }
                        }
                        catch (Exception exc)
                        {
                            Console.WriteLine(exc.Message);
                            string ERROR = "ERROR";
                            return ERROR;
                        }

                        Console.WriteLine("Factor value: " + returnValue + "\ttype: " + returnValue.GetType());
                        return returnValue;
                        
                    }
                    else if (node[0].Parent.ToString().Equals("<DateTimeLiteral>"))
                    {
                        string type = Regex.Replace(node[0].Parent.ToString(), "[^0-9a-zA-Z]+", "");
                        Enums.eNonTerminals ntt = (Enums.eNonTerminals)Enum.Parse(typeof(Enums.eNonTerminals), type);
                        try
                        {
                            returnValue = Context.NonTerminalContext.Execute(ntt, (GOLD.Reduction)node[0].Data);
                        }
                        catch (Exception Exc)
                        {
                            Console.WriteLine(Exc.Message);
                            string ERROR = "ERROR";
                            return ERROR;
                        }
                        return returnValue;
                    }
                    else
                    {
                        throw new Exception("Literal define error - Luna_interpreter.Model.Structure.Classes.Factor.Execute");
                    }
                }
                catch(InvalidCastException ice)
                {
                    Console.WriteLine(ice.Message);
                }
                catch (Exception exc)
                {
                    Console.WriteLine(exc.Message);
                }
            }
            Console.WriteLine(Environment.NewLine + "(AAA) Factor (AAA)" + Environment.NewLine);
            return null;
        }
示例#23
0
        private object CreateNewObject(GOLD.Reduction r)
        {
            object result = r;

            switch ((ProductionIndex)r.Parent.TableIndex())
            {
                case ProductionIndex.Objects:
                    var newResult = new List<UINode>();
                    newResult.Add((UINode)r.get_Data(0));
                    newResult.AddRange((List<UINode>)r.get_Data(1));
                    result = newResult;
                    program = result;
                    // <Objects> ::= <Object> <Objects>
                    break;

                case ProductionIndex.Objects2:
                    // <Objects> ::= <Object>
                    var newResult2 = new List<UINode>();
                    newResult2.Add((UINode)r.get_Data(0));
                    result = newResult2;
                    program = result;
                    break;

                case ProductionIndex.Object_Beginliteral_Endliteral:
                    // <Object> ::= BeginLiteral <Content> EndLiteral
                    result = UIGroup.FromReduction(r);
                    break;

                case ProductionIndex.Object:
                    // <Object> ::= <Start Tag>
                    result = r.get_Data(0);
                    break;

                case ProductionIndex.Object2:
                    // <Object> ::= <Unary Tag>
                    break;

                case ProductionIndex.Starttag_Lt_Id_Gt:
                    // <Start Tag> ::= '<' ID <OptionalID> <Attributes> '>'
                    var node = new UINode();
                    node.Name = (string)r.get_Data(1);
                    node.ID = (string)r.get_Data(2);
                    var atts = (List<KeyValuePair<string, string>>)r.get_Data(3);
                    foreach (var att in atts)
                    {
                        node[att.Key] = att.Value;
                    }
                    result = node;
                    break;

                case ProductionIndex.Endtag_Ltdiv_Id_Gt:
                    // <End Tag> ::= '</' ID '>'
                    break;

                case ProductionIndex.Unarytag_Lt_Id_Divgt:
                    // <Unary Tag> ::= '<' ID <OptionalID> <Attributes> '/>'
                    break;

                case ProductionIndex.Optionalid_Stringliteral:
                    // <OptionalID> ::= StringLiteral
                    result = GetStringLiteral((string)r.get_Data(0));
                    break;

                case ProductionIndex.Optionalid:
                    // <OptionalID> ::=
                    result = null;
                    break;

                case ProductionIndex.Content:
                    // <Content> ::= <Objects>
                    var newResult3 = new List<UINode>();
                    newResult3.AddRange((List<UINode>)r.get_Data(0));
                    result = newResult3;
                    break;

                case ProductionIndex.Content2:
                    // <Content> ::= <Text>
                    var newResult4 = new List<UINode>();
                    newResult4.Add((UINode)r.get_Data(0));
                    result = newResult4;
                    break;

                case ProductionIndex.Attributes:
                    // <Attributes> ::= <Attribute> <Attributes>
                    var attributeList = new List<KeyValuePair<string, string>>();
                    attributeList.Add((KeyValuePair<string, string>)r.get_Data(0));
                    if (r.Count() > 1)
                    {
                        attributeList.AddRange((List<KeyValuePair<string, string>>)r.get_Data(1));
                    }
                    result = attributeList;
                    break;

                case ProductionIndex.Attributes2:
                    // <Attributes> ::=
                    result = new List<KeyValuePair<string, string>>();
                    break;

                case ProductionIndex.Attribute_Id_Eq_Stringliteral:
                    // <Attribute> ::= ID '=' StringLiteral
                    result = new KeyValuePair<string, string>((string)r.get_Data(0), GetStringLiteral((string)r.get_Data(2)));
                    break;

                case ProductionIndex.Attribute_Id_Eq_Id:
                    // <Attribute> ::= ID '=' ID
                    result = new KeyValuePair<string, string>((string)r.get_Data(0), (string)r.get_Data(2));
                    break;

                case ProductionIndex.Text:
                    // <Text> ::= <Text> <Word>
                    break;

                case ProductionIndex.Text2:
                    // <Text> ::= <Word>
                    break;

                case ProductionIndex.Word_Id:
                    // <Word> ::= ID
                    break;

                case ProductionIndex.Word_Eq:
                    // <Word> ::= '='
                    break;

                case ProductionIndex.Word_Charname:
                    // <Word> ::= CharName
                    break;

                case ProductionIndex.Word_Charnumber:
                    // <Word> ::= CharNumber
                    break;

            }  //switch

            return result;
        }
示例#24
0
        private object CreateNewObject(GOLD.Reduction r)
        {
            object result = null;
            int pointerCount;
            switch ((ProductionIndex)r.Parent.TableIndex())
            {
                case ProductionIndex.Decls:
                    // <Decls> ::= <Decl> <Decls>
                    var declarationHead = r.GetData(0) as DeclarationStatement;
                    var declarationTail = r.GetData(1) as List<DeclarationStatement>;
                    declarationTail.InsertNotNull(0, declarationHead);
                    return declarationTail;

                case ProductionIndex.Decls2:
                    // <Decls> ::=
                    return new List<DeclarationStatement>();

                case ProductionIndex.Decl:
                    // <Decl> ::= <Func Decl>
                    return r.GetData(0);

                case ProductionIndex.Decl2:
                    // <Decl> ::= <Func Proto>
                    return r.GetData(0);

                case ProductionIndex.Decl3:
                    // <Decl> ::= <Struct Decl>
                    return r.GetData(0);

                case ProductionIndex.Decl4:
                    // <Decl> ::= <Union Decl>
                    return r.GetData(0);

                case ProductionIndex.Decl5:
                    // <Decl> ::= <Enum Decl>
                    return r.GetData(0);

                case ProductionIndex.Decl6:
                    // <Decl> ::= <Var Decl>
                    return r.GetData(0);

                case ProductionIndex.Decl7:
                    // <Decl> ::= <Typedef Decl>
                    return r.GetData(0);

                case ProductionIndex.Funcproto_Lparen_Rparen_Semi:
                    // <Func Proto> ::= <Func ID> '(' <Types> ')' ';'
                    break;

                case ProductionIndex.Funcproto_Lparen_Rparen_Semi2:
                    // <Func Proto> ::= <Func ID> '(' <Params> ')' ';'
                    break;

                case ProductionIndex.Funcproto_Lparen_Rparen_Semi3:
                    // <Func Proto> ::= <Func ID> '(' ')' ';'
                    break;

                case ProductionIndex.Funcdecl_Lparen_Rparen:
                    // <Func Decl> ::= <Func ID> '(' <Params> ')' <Block>
                    var function = r.GetData(0) as FunctionDeclaration;
                    function.Parameters = r.GetData(2) as List<Parameter>;
                    function.Block = r.GetData(4) as BlockStatement;
                    return function;

                case ProductionIndex.Funcdecl_Lparen_Rparen2:
                    // <Func Decl> ::= <Func ID> '(' <Id List> ')' <Struct Def> <Block>
                    throw new NotImplementedException();

                case ProductionIndex.Funcdecl_Lparen_Rparen3:
                    // <Func Decl> ::= <Func ID> '(' ')' <Block>
                    function = r.GetData(0) as FunctionDeclaration;
                    function.Block = r.GetData(3) as BlockStatement;
                    return function;

                case ProductionIndex.Params_Comma:
                    // <Params> ::= <Param> ',' <Params>
                    var paramHead = r.GetData(0) as Parameter;
                    var paramTail = r.GetData(2) as List<Parameter>;
                    paramTail.InsertNotNull(0,paramHead);
                    return paramTail;

                case ProductionIndex.Params:
                    // <Params> ::= <Param>
                    return new List<Parameter>() { r.GetData(0) as Parameter };

                case ProductionIndex.Param_Const_Id:
                    // <Param> ::= const <Type> Id
                    break;

                case ProductionIndex.Param_Id:
                    // <Param> ::= <Type> Id
                    return new Parameter(r.GetData(0) as IRType, r.GetData(1).ToString());

                case ProductionIndex.Types_Comma:
                    // <Types> ::= <Type> ',' <Types>
                    var typeHead = r.GetData(0) as IRType;
                    var typeTail = r.GetData(2) as List<IRType>;
                    typeTail.InsertNotNull(0, typeHead);

                    return typeTail;

                case ProductionIndex.Types:
                    // <Types> ::= <Type>
                    return new List<IRType> { r.GetData(0) as IRType};

                case ProductionIndex.Idlist_Id_Comma:
                    // <Id List> ::= Id ',' <Id List>
                    var idHead = r.GetData(0).ToString();
                    var idTail = r.GetData(2) as List<string>;
                    idTail.InsertNotNull(0, idHead);
                    return idTail;

                case ProductionIndex.Idlist_Id:
                    // <Id List> ::= Id
                    var idList = r.GetData(0).ToString();
                    return new List<string>() { idList };

                case ProductionIndex.Funcid_Id:
                    // <Func ID> ::= <Type> Id
                    return new FunctionDeclaration(r.GetData(0) as IRType, r.GetData(1).ToString());

                case ProductionIndex.Funcid_Id2:
                    // <Func ID> ::= Id
                    //return new Function(r.GetData(0).ToString());
                    throw new NotImplementedException("<Func ID> ::= Id");

                case ProductionIndex.Typedefdecl_Typedef_Id_Semi:
                    // <Typedef Decl> ::= typedef <Type> Id ';'
                    break;

                case ProductionIndex.Structdecl_Struct_Id_Lbrace_Rbrace_Semi:
                    // <Struct Decl> ::= struct Id '{' <Struct Def> '}' ';'
                    return new StructDeclaration(r.GetData(0).ToString(), r.GetData(3) as List<IdDeclarationStatement>);

                case ProductionIndex.Uniondecl_Union_Id_Lbrace_Rbrace_Semi:
                    // <Union Decl> ::= union Id '{' <Struct Def> '}' ';'
                    return new UnionDeclaration(r.GetData(1).ToString(), r.GetData(3) as List<IdDeclarationStatement>);

                case ProductionIndex.Structdef:
                    // <Struct Def> ::= <Var Decl> <Struct Def>
                     var declarationstm = r.GetData(0) as List<IdDeclarationStatement>;
                     var structdeftail = r.GetData(1) as List<IdDeclarationStatement>;
                     declarationstm.AddRange(structdeftail);
                     return declarationstm;

                case ProductionIndex.Structdef2:
                    // <Struct Def> ::= <Var Decl>
                    declarationstm = r.GetData(0) as List<IdDeclarationStatement>;
                    return declarationstm;

                case ProductionIndex.Vardecl_Semi:
                    // <Var Decl> ::= <Mod> <Type> <Var> <Var List> ';'
                    var baseType = r.GetData(1) as IRType;
                    var partialDeclaration = r.GetData(2) as PartialIdDeclarationStatement;
                    var varList = r.GetData(3) as List<VarItem>;
                    var idDeclaration = partialDeclaration.DeclarationStatement;
                    var partialType = baseType;
                    if (partialDeclaration.ArrayType != null )
                    {
                        partialDeclaration.ArrayType.Type = partialType;
                        partialType = partialDeclaration.ArrayType;
                    }
                    idDeclaration.Type = partialType;
                    idDeclaration.Modifier = r.GetData(0) as Modifier;
                    var idDeclarationList = new List<IdDeclarationStatement>() { idDeclaration };

                    foreach (var varItem in varList)
                    {
                        IRType baseVarItemType = baseType;
                        pointerCount = Convert.ToInt32(varItem.Pointers);
                        for (int i = 0; i < pointerCount; i++)
                        {
                            baseVarItemType = new PointerType(baseVarItemType);
                        }
                        if (varItem.PartialIdDeclaration.ArrayType != null)
                        {
                            varItem.PartialIdDeclaration.ArrayType.Type = baseVarItemType;
                            baseVarItemType = varItem.PartialIdDeclaration.ArrayType;
                        }
                        varItem.PartialIdDeclaration.DeclarationStatement.Type = baseVarItemType;
                        idDeclarationList.Add(varItem.PartialIdDeclaration.DeclarationStatement);
                    }
                    return idDeclarationList;

                case ProductionIndex.Vardecl_Semi2:
                    // <Var Decl> ::= <Type> <Var> <Var List> ';'
                    baseType = r.GetData(0) as IRType;
                    partialDeclaration = r.GetData(1) as PartialIdDeclarationStatement;
                    varList = r.GetData(2) as List<VarItem>;
                    idDeclaration = partialDeclaration.DeclarationStatement;
                    partialType = baseType;
                    if (partialDeclaration.ArrayType != null )
                    {
                        partialDeclaration.ArrayType.Type = partialType;
                        partialType = partialDeclaration.ArrayType;
                    }
                    idDeclaration.Type = partialType;
                    idDeclarationList = new List<IdDeclarationStatement>() { idDeclaration };

                    foreach (var varItem in varList)
                    {
                        IRType baseVarItemType = baseType;
                        pointerCount = Convert.ToInt32(varItem.Pointers);
                        for (int i = 0; i < pointerCount; i++)
                        {
                            baseVarItemType = new PointerType(baseVarItemType);
                        }
                        if (varItem.PartialIdDeclaration.ArrayType != null)
                        {
                            varItem.PartialIdDeclaration.ArrayType.Type = baseVarItemType;
                            baseVarItemType = varItem.PartialIdDeclaration.ArrayType;
                        }
                        varItem.PartialIdDeclaration.DeclarationStatement.Type = baseVarItemType;
                        idDeclarationList.Add(varItem.PartialIdDeclaration.DeclarationStatement);
                    }
                    return idDeclarationList;

                case ProductionIndex.Vardecl_Semi3:
                    // <Var Decl> ::= <Mod> <Var> <Var List> ';'
                    throw new NotImplementedException("<Var Decl> ::= <Mod> <Var> <Var List> ");

                case ProductionIndex.Var_Id:
                    // <Var> ::= Id <Array>
                    var arrayType = r.GetData(1) as ArrayType;
                    var id = r.GetData(0).ToString();
                    idDeclaration = new IdDeclarationStatement(id);
                    partialDeclaration = new PartialIdDeclarationStatement(idDeclaration, arrayType);
                    return partialDeclaration;

                case ProductionIndex.Var_Id_Eq:
                    // <Var> ::= Id <Array> '=' <Op If>
                    arrayType = r.GetData(1) as ArrayType;
                    var assigment = r.GetData(3) as Expression;
                    id = r.GetData(0).ToString();
                    idDeclaration = new IdDeclarationStatement(id,assigment);
                    partialDeclaration = new PartialIdDeclarationStatement(idDeclaration, arrayType);
                    return partialDeclaration;

                case ProductionIndex.Array_Lbracket_Rbracket:
                    // <Array> ::= '[' <Expr> ']'
                   var sizeExpression = r.GetData(1) as DecValue;
                    return new ArrayType(Convert.ToInt64(sizeExpression.Value));

                case ProductionIndex.Array_Lbracket_Rbracket2:
                    // <Array> ::= '[' ']'
                    return new ArrayType();

                case ProductionIndex.Array:
                    // <Array> ::=
                    return null;

                case ProductionIndex.Varlist_Comma:
                    // <Var List> ::= ',' <Var Item> <Var List>
                    var varItemHead = r.GetData(1) as VarItem;
                    var varItemTail = r.GetData(2) as List<VarItem>;
                    varItemTail.InsertNotNull(0, varItemHead);
                    return varItemTail;

                case ProductionIndex.Varlist:
                    // <Var List> ::=
                    return new List<VarItem>();

                case ProductionIndex.Varitem:
                    // <Var Item> ::= <Pointers> <Var>
                    var pointers = Convert.ToInt32(r.GetData(0));
                    var var = r.GetData(1) as PartialIdDeclarationStatement;
                    return new VarItem( pointers,  var);

                case ProductionIndex.Mod_Extern:
                    // <Mod> ::= extern no extern no
                    break;//ver que pedo con la excepcion

                case ProductionIndex.Mod_Static:
                    // <Mod> ::= static
                    return new StaticModifier();

                case ProductionIndex.Mod_Register:
                    // <Mod> ::= register
                    return new RegisterModifier();

                case ProductionIndex.Mod_Auto:
                    // <Mod> ::= auto
                    return new AutoModifier();

                case ProductionIndex.Mod_Volatile:
                    // <Mod> ::= volatile no volatile no
                    break; //ver que pedo con la excepcion

                case ProductionIndex.Mod_Const:
                    // <Mod> ::= const
                    return new ConstModifier();

                case ProductionIndex.Enumdecl_Enum_Id_Lbrace_Rbrace_Semi:
                    // <Enum Decl> ::= enum Id '{' <Enum Def> '}' ';'
                    return new EnumDeclaration(r.GetData(1).ToString(), r.GetData(3) as List<EnumValue>);

                case ProductionIndex.Enumdef_Comma:
                    // <Enum Def> ::= <Enum Val> ',' <Enum Def>
                    var enumHead = r.GetData(0) as EnumValue;
                    var enumTail = r.GetData(2) as List<EnumValue>;
                    enumTail.InsertNotNull(0, enumHead);

                    return enumTail;

                case ProductionIndex.Enumdef:
                    // <Enum Def> ::= <Enum Val>
                    return new List<EnumValue> {r.GetData(0) as EnumValue};

                case ProductionIndex.Enumval_Id:
                    // <Enum Val> ::= Id
                    return r.GetData(0);

                case ProductionIndex.Enumval_Id_Eq_Octliteral:
                    // <Enum Val> ::= Id '=' OctLiteral
                    return new EnumValue(r.GetData(0).ToString(), Convert.ToInt32(r.GetData(2).ToString(), 8));

                case ProductionIndex.Enumval_Id_Eq_Hexliteral:
                    // <Enum Val> ::= Id '=' HexLiteral
                    return new EnumValue(r.GetData(0).ToString(), Convert.ToInt32(r.GetData(2).ToString(), 16));

                case ProductionIndex.Enumval_Id_Eq_Decliteral:
                    // <Enum Val> ::= Id '=' DecLiteral
                    return new EnumValue(r.GetData(0).ToString(), Convert.ToInt32(r.GetData(2).ToString(), 10));

                case ProductionIndex.Type:
                    // <Type> ::= <Base> <Pointers>
                    baseType = r.GetData(0) as IRType;
                    pointerCount = Convert.ToInt32(r.GetData(1));
                    for (int i = 0; i < pointerCount; i++)
                    {
                        baseType = new PointerType(baseType);
                    }
                    return baseType;

                case ProductionIndex.Base:
                    // <Base> ::= <Sign> <Scalar>
                    if (r.GetData(0).ToString() == "unsigned")
                    {
                        if ( r.GetData(1) is IntType )
                        {
                            return new UnsignedIntType();
                        }
                        else if (r.GetData(1) is ShortType)
                        {
                            return new UnsignedShortType();
                        }
                        else if (r.GetData(1) is LongType)
                        {
                            return new UnsignedLongType();
                        }
                        else if (r.GetData(1) is ShortIntType)
                        {
                            return new UnsignedShortIntType();
                        }
                        else if (r.GetData(1) is FloatType)
                        {
                            return new UnsignedFloatType();
                        }
                        else if (r.GetData(1) is LongIntType)
                        {
                            return new UnsignedLongIntType();
                        }
                        else if (r.GetData(1) is DoubleType)
                        {
                            return new UnsignedDoubleType();
                        }

                    }
                    return r.GetData(1);

                case ProductionIndex.Base_Struct_Id:
                    // <Base> ::= struct Id
                    return new StructType(r.GetData(1).ToString());//Crear una clase para definir el tipo inferido del struct

                case ProductionIndex.Base_Struct_Lbrace_Rbrace:
                    // <Base> ::= struct '{' <Struct Def> '}'
                    return new StructType(r.GetData(2) as List<DeclarationStatement>);

                case ProductionIndex.Base_Union_Id:
                    // <Base> ::= union Id
                    return new UnionType(r.GetData(1).ToString());//Crear una clase para definir el tipo inferido del union

                case ProductionIndex.Base_Union_Lbrace_Rbrace:
                    // <Base> ::= union '{' <Struct Def> '}'
                    return new UnionType(r.GetData(2) as List<DeclarationStatement>);

                case ProductionIndex.Base_Enum_Id:
                    // <Base> ::= enum Id
                    return new EnumType(r.GetData(1).ToString());

                case ProductionIndex.Sign_Signed:
                    // <Sign> ::= signed
                    return r.GetData(0);

                case ProductionIndex.Sign_Unsigned:
                    // <Sign> ::= unsigned
                    return r.GetData(0);

                case ProductionIndex.Sign:
                    // <Sign> ::=
                    return 0;

                case ProductionIndex.Scalar_Char:
                    // <Scalar> ::= char
                    return new CharType();

                case ProductionIndex.Scalar_Int:
                    // <Scalar> ::= int
                    return new IntType();

                case ProductionIndex.Scalar_Short:
                    return new ShortType();

                case ProductionIndex.Scalar_Long:
                    // <Scalar> ::= long
                    return new LongType();

                case ProductionIndex.Scalar_Short_Int:
                    //<Scalar> ::= short int
                    return new ShortIntType();

                case ProductionIndex.Scalar_Long_Int:
                    return new LongIntType();

                case ProductionIndex.Scalar_Float:
                    return new FloatType();

                case ProductionIndex.Scalar_Double:
                    return new DoubleType();

                case ProductionIndex.Scalar_Void:
                    return new VoidType();

                case ProductionIndex.Pointers_Times:
                    // <Pointers> ::= '*' <Pointers>
                    return Convert.ToInt32(r.GetData(1)) + 1;

                case ProductionIndex.Pointers:
                    // <Pointers> ::=
                    return 0;

                case ProductionIndex.Stm:
                    // <Stm> ::= <Var Decl>
                    return r.GetData(0);

                case ProductionIndex.Stm_Id_Colon:
                    // <Stm> ::= Id ':'
                    return r.GetData(0).ToString(); //labelstatement class missing

                case ProductionIndex.Stm_If_Lparen_Rparen:
                    // <Stm> ::= if '(' <Expr> ')' <Stm>
                    var ifDeclaration = new IfStatement(r.GetData(2) as Expression, r.GetData(4) as Statement);
                    return ifDeclaration;

                case ProductionIndex.Stm_If_Lparen_Rparen_Else:
                    // <Stm> ::= if '(' <Expr> ')' <Then Stm> else <Stm>
                    ifDeclaration = new IfStatement(r.GetData(2) as Expression, r.GetData(4) as Statement, r.GetData(6) as Statement);
                    return ifDeclaration;

                case ProductionIndex.Stm_While_Lparen_Rparen:
                    // <Stm> ::= while '(' <Expr> ')' <Stm>
                    var whileDeclaration = new WhileStatement(r.GetData(2) as Expression, r.GetData(4) as Statement);
                    return whileDeclaration;

                case ProductionIndex.Stm_For_Lparen_Semi_Semi_Rparen:
                    // <Stm> ::= for '(' <Arg> ';' <Arg> ';' <Arg> ')' <Stm>
                    var forDeclaration = new ForStatement(r.GetData(2) as Expression, r.GetData(4) as Expression, r.GetData(6) as Expression,
                                                         r.GetData(8) as Statement);
                    return forDeclaration;

                case ProductionIndex.Stm2:
                    // <Stm> ::= <Normal Stm>
                    return r.GetData(0);

                case ProductionIndex.Thenstm_If_Lparen_Rparen_Else:
                    // <Then Stm> ::= if '(' <Expr> ')' <Then Stm> else <Then Stm>
                    ifDeclaration = new IfStatement(r.GetData(2) as Expression, r.GetData(4) as Statement, r.GetData(6) as Statement);
                    return ifDeclaration;

                case ProductionIndex.Thenstm_While_Lparen_Rparen:
                    // <Then Stm> ::= while '(' <Expr> ')' <Then Stm>
                    whileDeclaration = new WhileStatement(r.GetData(2) as Expression, r.GetData(4) as Statement);
                    return whileDeclaration;

                case ProductionIndex.Thenstm_For_Lparen_Semi_Semi_Rparen:
                    // <Then Stm> ::= for '(' <Arg> ';' <Arg> ';' <Arg> ')' <Then Stm>
                    forDeclaration = new ForStatement(r.GetData(2) as Expression, r.GetData(4) as Expression, r.GetData(6) as Expression,
                                                      r.GetData(8) as Statement);
                    return forDeclaration;

                case ProductionIndex.Thenstm:
                    // <Then Stm> ::= <Normal Stm>
                    return r.GetData(0);

                case ProductionIndex.Normalstm_Do_While_Lparen_Rparen:
                    // <Normal Stm> ::= do <Stm> while '(' <Expr> ')'
                    var doDeclaration = new DoStatement(r.GetData(1) as Statement, r.GetData(4) as Expression);
                    return doDeclaration;

                case ProductionIndex.Normalstm_Switch_Lparen_Rparen_Lbrace_Rbrace:
                    // <Normal Stm> ::= switch '(' <Expr> ')' '{' <Case Stms> '}'
                    var switchDeclaration = new SwitchStatement(r.GetData(2) as Expression, r.GetData(5) as List<DefaultCaseStatement>);
                    return switchDeclaration;

                case ProductionIndex.Normalstm:
                    // <Normal Stm> ::= <Block>
                    return r.GetData(0);

                case ProductionIndex.Normalstm_Semi:
                    // <Normal Stm> ::= <Expr> ';'
                    var expressionStatement = new ExpressionStatement(r.GetData(0) as Expression);
                    return expressionStatement;

                case ProductionIndex.Normalstm_Goto_Id_Semi:
                    // <Normal Stm> ::= goto Id ';'
                    return new GoToIdStatement(); //guardar el id

                case ProductionIndex.Normalstm_Break_Semi:
                    // <Normal Stm> ::= break ';'
                    return new BreakStatement();

                case ProductionIndex.Normalstm_Continue_Semi:
                    // <Normal Stm> ::= continue ';'
                    return new ContinueStatement();

                case ProductionIndex.Normalstm_Return_Semi:
                    // <Normal Stm> ::= return <Expr> ';'
                    return new ReturnStatement(r.get_Data(1) as Expression);

                case ProductionIndex.Normalstm_Semi2:
                    // <Normal Stm> ::= ';'
                    return new NoOpExpression();

                case ProductionIndex.Arg:
                    // <Arg> ::= <Expr>
                    return r.GetData(0);

                case ProductionIndex.Arg2:
                    // <Arg> ::=
                    return new NoOpExpression();

                case ProductionIndex.Casestms_Case_Colon:
                    // <Case Stms> ::= case <Value> ':' <Stm List> <Case Stms>
                    var caseStatementHead = new CaseStatement(r.GetData(1) as ValueExpression, r.GetData(3) as List<Statement>);
                    var caseStatementTail = r.GetData(4) as List<DefaultCaseStatement>;
                    caseStatementTail.InsertNotNull(0, caseStatementHead);
                    return caseStatementTail;

                case ProductionIndex.Casestms_Default_Colon:
                    // <Case Stms> ::= default ':' <Stm List>
                    return new List<DefaultCaseStatement>() { new DefaultCaseStatement(r.GetData(2) as List<Statement>) };

                case ProductionIndex.Casestms:
                    // <Case Stms> ::=
                    return new List<DefaultCaseStatement>();

                case ProductionIndex.Block_Lbrace_Rbrace:
                    // <Block> ::= '{' <Stm List> '}'
                    return new BlockStatement(r.GetData(1) as List<Statement>);

                case ProductionIndex.Stmlist:
                    // <Stm List> ::= <Stm> <Stm List>
                    var statemetListTail = r.GetData(1) as List<Statement>;
                    var declList = r.GetData(0) as List<IdDeclarationStatement>;
                    if (declList != null)
                    {
                        var statementList = new List<Statement>();
                        foreach (var dec in declList)
                        {
                            statementList.AddNotNull(dec);
                        }
                        foreach (var TailItem in statemetListTail)
                        {
                            statementList.AddNotNull(TailItem);
                        }
                        return statementList;
                    }
                    statemetListTail.InsertNotNull(0, r.GetData(0) as Statement);
                    return statemetListTail;

                case ProductionIndex.Stmlist2:
                    // <Stm List> ::=
                    return new List<Statement>();

                case ProductionIndex.Expr_Comma:
                    // <Expr> ::= <Expr> ',' <Op Assign>
                    var expr = r.GetData(0) as ExpressionList;
                    if (expr != null)
                    {
                        return new ExpressionList(expr, r.GetData(2) as Expression);
                    }
                    else
                        return new ExpressionList(r.GetData(0) as Expression, r.GetData(2) as Expression);

                case ProductionIndex.Expr:
                    // <Expr> ::= <Op Assign>
                    return r.GetData(0);

                case ProductionIndex.Opassign_Eq:
                    // <Op Assign> ::= <Op If> '=' <Op Assign>
                    return new AssignExpression(left: r.GetData(0) as Expression, right: r.GetData(2) as Expression);

                case ProductionIndex.Opassign_Pluseq:
                    // <Op Assign> ::= <Op If> '+=' <Op Assign>
                    return new AdditionAssignmentExpression(left: r.GetData(0) as Expression, right: r.GetData(2) as Expression);

                case ProductionIndex.Opassign_Minuseq:
                    // <Op Assign> ::= <Op If> '-=' <Op Assign>
                    return new SubtractionAsigExpression(left: r.GetData(0) as Expression, right: r.GetData(2) as Expression);

                case ProductionIndex.Opassign_Timeseq:
                    // <Op Assign> ::= <Op If> '*=' <Op Assign>
                    return new MultiplicationAsigExpression(left: r.GetData(0) as Expression, right: r.GetData(2) as Expression);

                case ProductionIndex.Opassign_Diveq:
                    // <Op Assign> ::= <Op If> '/=' <Op Assign>
                    return new DivisionAsigExpression(left: r.GetData(0) as Expression, right: r.GetData(2) as Expression);

                case ProductionIndex.Opassign_Careteq:
                    // <Op Assign> ::= <Op If> '^=' <Op Assign>
                    return new BitwiseXorAssignmentExpression(left: r.GetData(0) as Expression, right: r.GetData(2) as Expression);

                case ProductionIndex.Opassign_Ampeq:
                    // <Op Assign> ::= <Op If> '&=' <Op Assign>
                    return new BitwiseAndAssignExpression(left: r.GetData(0) as Expression, right: r.GetData(2) as Expression);

                case ProductionIndex.Opassign_Pipeeq:
                    // <Op Assign> ::= <Op If> '|=' <Op Assign>
                    return new BitwiseOrAssigExpression(left: r.GetData(0) as Expression, right: r.GetData(2) as Expression);

                case ProductionIndex.Opassign_Gtgteq:
                    // <Op Assign> ::= <Op If> '>>=' <Op Assign>
                    return new BitwiseRightShiftAssigExpression(left: r.GetData(0) as Expression, right: r.GetData(2) as Expression);

                case ProductionIndex.Opassign_Ltlteq:
                    // <Op Assign> ::= <Op If> '<<=' <Op Assign>
                    return new BitwiseLeftShiftAssigExpression(left: r.GetData(0) as Expression, right: r.GetData(2) as Expression);

                case ProductionIndex.Opassign:
                    // <Op Assign> ::= <Op If>
                    return r.get_Data(0);

                case ProductionIndex.Opif_Question_Colon:
                    // <Op If> ::= <Op Or> '?' <Op If> ':' <Op If>
                    return new TernaryConditional(r.GetData(0) as Expression, r.GetData(2) as Expression, r.GetData(4) as Expression);

                case ProductionIndex.Opif:
                    // <Op If> ::= <Op Or>
                    return r.get_Data(0);

                case ProductionIndex.Opor_Pipepipe:
                    // <Op Or> ::= <Op Or> '||' <Op And>
                    return new LogicalOrExpression(left: r.GetData(0) as Expression, right: r.GetData(2) as Expression);

                case ProductionIndex.Opor:
                    // <Op Or> ::= <Op And>
                    return r.get_Data(0);

                case ProductionIndex.Opand_Ampamp:
                    // <Op And> ::= <Op And> '&&' <Op BinOR>
                    return new LogicAndExpression(left: r.GetData(0) as Expression, right: r.GetData(2) as Expression);

                case ProductionIndex.Opand:
                    // <Op And> ::= <Op BinOR>
                    return r.get_Data(0);

                case ProductionIndex.Opbinor_Pipe:
                    // <Op BinOR> ::= <Op BinOR> '|' <Op BinXOR>
                    return new BitwiseOrExpression(left: r.GetData(0) as Expression, right: r.GetData(2) as Expression);

                case ProductionIndex.Opbinor:
                    // <Op BinOR> ::= <Op BinXOR>
                    return r.get_Data(0);

                case ProductionIndex.Opbinxor_Caret:
                    // <Op BinXOR> ::= <Op BinXOR> '^' <Op BinAND>
                    return new BitwiseXorExpression(left: r.GetData(0) as Expression, right: r.GetData(2) as Expression);

                case ProductionIndex.Opbinxor:
                    // <Op BinXOR> ::= <Op BinAND>
                    return r.get_Data(0);

                case ProductionIndex.Opbinand_Amp:
                    // <Op BinAND> ::= <Op BinAND> '&' <Op Equate>
                    return new BitwiseAndExpression(left: r.GetData(0) as Expression, right: r.GetData(2) as Expression);

                case ProductionIndex.Opbinand:
                    // <Op BinAND> ::= <Op Equate>
                    return r.get_Data(0);

                case ProductionIndex.Opequate_Eqeq:
                    // <Op Equate> ::= <Op Equate> '==' <Op Compare>
                    return new EqualsExpression(left: r.GetData(0) as Expression, right: r.GetData(2) as Expression);

                case ProductionIndex.Opequate_Exclameq:
                    // <Op Equate> ::= <Op Equate> '!=' <Op Compare>
                    return new NotEqualExpression(left: r.GetData(0) as Expression, right: r.GetData(2) as Expression);

                case ProductionIndex.Opequate:
                    // <Op Equate> ::= <Op Compare>
                    return r.get_Data(0);

                case ProductionIndex.Opcompare_Lt:
                    // <Op Compare> ::= <Op Compare> '<' <Op Shift>
                    return new LessThanExpression(left: r.GetData(0) as Expression, right: r.GetData(2) as Expression);

                case ProductionIndex.Opcompare_Gt:
                    // <Op Compare> ::= <Op Compare> '>' <Op Shift>
                    return new GreaterThanExpression(left: r.GetData(0) as Expression, right: r.GetData(2) as Expression);

                case ProductionIndex.Opcompare_Lteq:
                    // <Op Compare> ::= <Op Compare> '<=' <Op Shift>
                    return new LessOrEqualToExpression(left: r.GetData(0) as Expression, right: r.GetData(2) as Expression);

                case ProductionIndex.Opcompare_Gteq:
                    // <Op Compare> ::= <Op Compare> '>=' <Op Shift>
                    return new GreaterOrEqualExpression(left: r.GetData(0) as Expression, right: r.GetData(2) as Expression);

                case ProductionIndex.Opcompare:
                    // <Op Compare> ::= <Op Shift>
                    return r.get_Data(0);

                case ProductionIndex.Opshift_Ltlt:
                    // <Op Shift> ::= <Op Shift> '<<' <Op Add>
                    return new BitwiseLeftShiftExpression(left: r.GetData(0) as Expression, right: r.GetData(2) as Expression);

                case ProductionIndex.Opshift_Gtgt:
                    return new BitwiseRightShiftExpression(left: r.GetData(0) as Expression, right: r.GetData(2) as Expression);

                case ProductionIndex.Opshift:
                    // <Op Shift> ::= <Op Add>
                    return r.get_Data(0);

                case ProductionIndex.Opadd_Plus:
                    // <Op Add> ::= <Op Add> '+' <Op Mult>
                    return new AddExpression(left: r.get_Data(0) as Expression, right: r.get_Data(2) as Expression);

                case ProductionIndex.Opadd_Minus:
                    // <Op Add> ::= <Op Add> '-' <Op Mult>
                    return new SubExpression(left: r.get_Data(0) as Expression, right: r.get_Data(2) as Expression);

                case ProductionIndex.Opadd:
                    // <Op Add> ::= <Op Mult>
                    return r.get_Data(0);

                case ProductionIndex.Opmult_Times:
                    // <Op Mult> ::= <Op Mult> '*' <Op Unary>
                    return new MulExpression(left: r.get_Data(0) as Expression, right: r.get_Data(2) as Expression);

                case ProductionIndex.Opmult_Div:
                    // <Op Mult> ::= <Op Mult> '/' <Op Unary>
                    return new DivisionExpression(left: r.GetData(0) as Expression, right: r.GetData(2) as Expression);

                case ProductionIndex.Opmult_Percent:
                    // <Op Mult> ::= <Op Mult> '%' <Op Unary>
                    return new ModExpression(left: r.GetData(0) as Expression, right: r.GetData(2) as Expression);

                case ProductionIndex.Opmult:
                    // <Op Mult> ::= <Op Unary>
                    return r.get_Data(0);

                case ProductionIndex.Opunary_Exclam:
                    // <Op Unary> ::= '!' <Op Unary>
                    return new NotEqualToExpression(r.GetData(1) as Expression);

                case ProductionIndex.Opunary_Tilde:
                    // <Op Unary> ::= '~' <Op Unary>
                    return new OneComplementExpression(r.get_Data(1) as Expression);

                case ProductionIndex.Opunary_Minus:
                    // <Op Unary> ::= '-' <Op Unary>
                    return new NegateExpression(r.get_Data(1) as Expression);

                case ProductionIndex.Opunary_Times:
                    // <Op Unary> ::= '*' <Op Unary>
                    return new PointerExpression(r.get_Data(1) as Expression);

                case ProductionIndex.Opunary_Amp:
                    // <Op Unary> ::= '&' <Op Unary>
                    return new ReferenceExpression(r.get_Data(1) as Expression);

                case ProductionIndex.Opunary_Plusplus:
                    // <Op Unary> ::= '++' <Op Unary>
                    return new PreIncrementExpression(r.get_Data(1) as Expression);

                case ProductionIndex.Opunary_Minusminus:
                    // <Op Unary> ::= '--' <Op Unary>
                    return new PreDecrementExpression(r.GetData(1) as Expression);

                case ProductionIndex.Opunary_Plusplus2:
                    // <Op Unary> ::= <Op Pointer> '++'
                    return new PostIncrementExpression(r.get_Data(0) as Expression);

                case ProductionIndex.Opunary_Minusminus2:
                    // <Op Unary> ::= <Op Pointer> '--'
                    return new PostDecrementExpression(r.GetData(0) as Expression);

                case ProductionIndex.Opunary_Lparen_Rparen:
                    // <Op Unary> ::= '(' <Type> ')' <Op Unary>
                    break;

                case ProductionIndex.Opunary_Sizeof_Lparen_Rparen:
                    // <Op Unary> ::= sizeof '(' <Type> ')'

                    break;

                case ProductionIndex.Opunary_Sizeof_Lparen_Id_Rparen:
                    // <Op Unary> ::= sizeof '(' Id <Pointers> ')'
                    break;

                case ProductionIndex.Opunary:
                    // <Op Unary> ::= <Op Pointer>
                    return r.get_Data(0);

                case ProductionIndex.Oppointer_Dot:
                    // <Op Pointer> ::= <Op Pointer> '.' <Value>
                    return new PointerReferenceAccessExpr(r.GetData(0) as Expression, r.GetData(2) as Expression);

                case ProductionIndex.Oppointer_Minusgt:
                    // <Op Pointer> ::= <Op Pointer> '->' <Value>
                    return new PointerAccessExpr(r.GetData(0) as Expression, r.GetData(2) as Expression);

                case ProductionIndex.Oppointer_Lbracket_Rbracket:
                    // <Op Pointer> ::= <Op Pointer> '[' <Expr> ']'
                    return new PointerArrayAccessExpr(r.GetData(0) as Expression, r.GetData(2) as Expression);

                case ProductionIndex.Oppointer:
                    // <Op Pointer> ::= <Value>
                    return r.get_Data(0);

                case ProductionIndex.Value_Octliteral:
                    // <Value> ::= OctLiteral
                    return new DecValue(Convert.ToInt32(r.get_Data(0).ToString(),8));

                case ProductionIndex.Value_Hexliteral:
                    // <Value> ::= HexLiteral
                    return new DecValue(Convert.ToInt32(r.GetData(0).ToString(),16));

                case ProductionIndex.Value_Decliteral:
                    // <Value> ::= DecLiteral
                    return new DecValue(Convert.ToInt32(r.get_Data(0)));

                case ProductionIndex.Value_Stringliteral:
                    // <Value> ::= StringLiteral
                    return new StringLiteral(r.GetData(0).ToString());

                case ProductionIndex.Value_Charliteral:
                    // <Value> ::= CharLiteral
                    return new CharLiteral(Convert.ToByte(Convert.ToChar(r.GetData(0))));

                case ProductionIndex.Value_Floatliteral:
                    // <Value> ::= FloatLiteral
                    return new FloatLiteral(Convert.ToDouble(r.GetData(0)));

                case ProductionIndex.Value_Id_Lparen_Rparen:
                    // <Value> ::= Id '(' <Expr> ')'
                    return new FunctionCallExpression(r.GetData(0).ToString(),r.GetData(2) as Expression);

                case ProductionIndex.Value_Id_Lparen_Rparen2:
                    // <Value> ::= Id '(' ')'
                    return new FunctionCallExpression(r.GetData(0).ToString());

                case ProductionIndex.Value_Id:
                    // <Value> ::= Id
                    if (r.GetData(0).ToString() == "true")
                    {
                        return new DecValue(1);
                    }
                    else
                        if (r.GetData(0).ToString() == "false")
                        {
                            return new DecValue(0);
                        }
                        else
                            return new IdValue(r.GetData(0).ToString());

                case ProductionIndex.Value_Lparen_Rparen:
                    // <Value> ::= '(' <Expr> ')'
                    return r.GetData(1) as Expression;

            }  //switch

            return result;
        }
示例#25
0
 public object Execute(GOLD.Reduction node)
 {
     return node[0].Data as string;
 }
示例#26
0
        private void WriteTokensToXML(GOLD.Reduction reduction)
        {
            _tokensXmlWriter = new XmlTextWriter(
                String.Format(@"{0}\{1}", System.IO.Directory.GetCurrentDirectory(), xmlName),
                Encoding.Default);

            _tokensXmlWriter.WriteStartElement("tokens");
            Recursion(reduction);
            _tokensXmlWriter.WriteEndElement();

            _tokensXmlWriter.Close();
        }
示例#27
0
 public string ShowTokens(GOLD.Reduction reduction)
 {
     WriteTokensToXML(reduction);
     return ReadTokensFromXML();
 }
示例#28
0
    private object CreateNewObject(GOLD.Reduction r)
    {
        object result = null;

        switch (r.Parent.TableIndex())
        {
            case (short)ProductionIndex.Program:
                // <PROGRAM> ::= <CLASS> <PROGRAM>
                break;

            case (short)ProductionIndex.Program2:
                // <PROGRAM> ::= <METHOD> <PROGRAM>
                break;

            case (short)ProductionIndex.Program3:
                // <PROGRAM> ::=
                break;

            case (short)ProductionIndex.Access_spec_Private:
                // <ACCESS_SPEC> ::= private
                break;

            case (short)ProductionIndex.Access_spec_Protected:
                // <ACCESS_SPEC> ::= protected
                break;

            case (short)ProductionIndex.Access_spec_Public:
                // <ACCESS_SPEC> ::= public
                break;

            case (short)ProductionIndex.Addop_Plus:
                // <ADDOP> ::= '+'
                break;

            case (short)ProductionIndex.Addop_Minus:
                // <ADDOP> ::= '-'
                break;

            case (short)ProductionIndex.Allocator_New_Lparan_Rparan:
                // <ALLOCATOR> ::= new <TYPE> '(' <ARGLIST> ')'
                break;

            case (short)ProductionIndex.Allocator_New_Lbracket_Rbracket:
                // <ALLOCATOR> ::= new <TYPE> '[' <EXPR> ']'
                break;

            case (short)ProductionIndex.Arglist:
                // <ARGLIST> ::= <EXPRLIST>
                break;

            case (short)ProductionIndex.Arglist2:
                // <ARGLIST> ::=
                break;

            case (short)ProductionIndex.Exprlist:
                // <EXPRLIST> ::= <EXPR>
                break;

            case (short)ProductionIndex.Exprlist_Comma:
                // <EXPRLIST> ::= <EXPR> ',' <EXPRLIST>
                break;

            case (short)ProductionIndex.Assignstmt_Eq:
                // <ASSIGNSTMT> ::= <FACTOR> '=' <EXPR>
                break;

            case (short)ProductionIndex.Bexpr:
                // <BEXPR> ::= <SIMPLEEXPR>
                break;

            case (short)ProductionIndex.Bexpr2:
                // <BEXPR> ::= <SIMPLEEXPR> <RELOP> <SIMPLEEXPR>
                break;

            case (short)ProductionIndex.Block_Begin_End:
                // <BLOCK> ::= <VARDECS> begin <STMTLIST> end
                break;

            case (short)ProductionIndex.Body:
                // <BODY> ::= <SUPER_INIT> <THIS_INIT> <BLOCK>
                break;

            case (short)ProductionIndex.Callstmt_Call:
                // <CALLSTMT> ::= call <FACTOR>
                break;

            case (short)ProductionIndex.Cast_expr_Cast_Lparan_Comma_Rparan:
                // <CAST_EXPR> ::= cast '(' <TYPE> ',' <EXPR> ')'
                break;

            case (short)ProductionIndex.Catch_clause_Catch_Lparan_Id_Rparan:
                // <CATCH_CLAUSE> ::= catch '(' <TYPE> Id ')' <STMTLIST>
                break;

            case (short)ProductionIndex.Cexpr:
                // <CEXPR> ::= <BEXPR>
                break;

            case (short)ProductionIndex.Cexpr_And:
                // <CEXPR> ::= <BEXPR> and <CEXPR>
                break;

            case (short)ProductionIndex.Class_Class_Id_Is_End_Id:
                // <CLASS> ::= class Id <SUPER_CLASS> is <CLASS_MEMBERLIST> end Id
                break;

            case (short)ProductionIndex.Class_memberlist:
                // <CLASS_MEMBERLIST> ::= <CLASS_MEMBER> <CLASS_MEMBERLIST>
                break;

            case (short)ProductionIndex.Class_memberlist2:
                // <CLASS_MEMBERLIST> ::=
                break;

            case (short)ProductionIndex.Class_member:
                // <CLASS_MEMBER> ::= <FIELD_DECL>
                break;

            case (short)ProductionIndex.Class_member2:
                // <CLASS_MEMBER> ::= <METHOD_DECL>
                break;

            case (short)ProductionIndex.Elsepart_Else:
                // <ELSEPART> ::= else <STMTLIST>
                break;

            case (short)ProductionIndex.Elsepart:
                // <ELSEPART> ::=
                break;

            case (short)ProductionIndex.Expr:
                // <EXPR> ::= <CEXPR>
                break;

            case (short)ProductionIndex.Expr_Or:
                // <EXPR> ::= <CEXPR> or <EXPR>
                break;

            case (short)ProductionIndex.Factor_Minus:
                // <FACTOR> ::= '-' <FACTOR>
                break;

            case (short)ProductionIndex.Factor_Not:
                // <FACTOR> ::= not <FACTOR>
                break;

            case (short)ProductionIndex.Factor_Number:
                // <FACTOR> ::= Number
                break;

            case (short)ProductionIndex.Factor_False:
                // <FACTOR> ::= false
                break;

            case (short)ProductionIndex.Factor_True:
                // <FACTOR> ::= true
                break;

            case (short)ProductionIndex.Factor_Null:
                // <FACTOR> ::= null
                break;

            case (short)ProductionIndex.Factor:
                // <FACTOR> ::= <ALLOCATOR>
                break;

            case (short)ProductionIndex.Factor2:
                // <FACTOR> ::= <CAST_EXPR>
                break;

            case (short)ProductionIndex.Factor3:
                // <FACTOR> ::= <VALUE_OR_REF> <MEMBER_PARTLIST>
                break;

            case (short)ProductionIndex.Member_partlist:
                // <MEMBER_PARTLIST> ::= <MEMBER_PART> <MEMBER_PARTLIST>
                break;

            case (short)ProductionIndex.Member_partlist2:
                // <MEMBER_PARTLIST> ::=
                break;

            case (short)ProductionIndex.Field_decl_Id_Semi:
                // <FIELD_DECL> ::= <ACCESS_SPEC> <TYPE> Id <FIELD_DECLLIST> ';'
                break;

            case (short)ProductionIndex.Field_decllist_Comma_Id:
                // <FIELD_DECLLIST> ::= ',' Id <FIELD_DECLLIST>
                break;

            case (short)ProductionIndex.Field_decllist:
                // <FIELD_DECLLIST> ::=
                break;

            case (short)ProductionIndex.Ifstmt_If_Then_End_If:
                // <IFSTMT> ::= if <EXPR> then <STMTLIST> <ELSEIF_PART> <ELSEPART> end if
                break;

            case (short)ProductionIndex.Elseif_part_Elsif_Then:
                // <ELSEIF_PART> ::= elsif <EXPR> then <STMTLIST> <ELSEIF_PART>
                break;

            case (short)ProductionIndex.Elseif_part:
                // <ELSEIF_PART> ::=
                break;

            case (short)ProductionIndex.Inputstmt_Input_Gtgt:
                // <INPUTSTMT> ::= input '>>' <FACTOR>
                break;

            case (short)ProductionIndex.Loopstmt_Loop_End_Loop:
                // <LOOPSTMT> ::= loop <STMTLIST> end loop
                break;

            case (short)ProductionIndex.Member_part_Dot_Id:
                // <MEMBER_PART> ::= '.' Id
                break;

            case (short)ProductionIndex.Member_part_Dot_Id_Lparan_Rparan:
                // <MEMBER_PART> ::= '.' Id '(' <ARGLIST> ')'
                break;

            case (short)ProductionIndex.Member_part_Dot_Id_Lbracket_Rbracket:
                // <MEMBER_PART> ::= '.' Id '[' <EXPR> ']'
                break;

            case (short)ProductionIndex.Method_Method_Lparan_Rparan_Is_Id:
                // <METHOD> ::= method <M_TYPE> <METHOD_ID> '(' <PARAMETERS> ')' is <BODY> Id
                break;

            case (short)ProductionIndex.Method_decl_Method_Id_Lparan_Rparan_Semi:
                // <METHOD_DECL> ::= <ACCESS_SPEC> method <M_TYPE> Id '(' <PARAMETER_DECL> ')' ';'
                break;

            case (short)ProductionIndex.Method_id_Id_Coloncolon_Id:
                // <METHOD_ID> ::= Id '::' Id
                break;

            case (short)ProductionIndex.Method_id_Id:
                // <METHOD_ID> ::= Id
                break;

            case (short)ProductionIndex.M_type:
                // <M_TYPE> ::= <TYPE>
                break;

            case (short)ProductionIndex.M_type_Void:
                // <M_TYPE> ::= void
                break;

            case (short)ProductionIndex.Multop_Times:
                // <MULTOP> ::= '*'
                break;

            case (short)ProductionIndex.Multop_Div:
                // <MULTOP> ::= '/'
                break;

            case (short)ProductionIndex.Multop_Mod:
                // <MULTOP> ::= mod
                break;

            case (short)ProductionIndex.Optional_id_Id:
                // <OPTIONAL_ID> ::= Id
                break;

            case (short)ProductionIndex.Optional_id:
                // <OPTIONAL_ID> ::=
                break;

            case (short)ProductionIndex.Outputstmt_Output_Ltlt:
                // <OUTPUTSTMT> ::= output '<<' <EXPR>
                break;

            case (short)ProductionIndex.Outputstmt_Output_Ltlt2:
                // <OUTPUTSTMT> ::= output '<<' <STRING_OR_CHAR>
                break;

            case (short)ProductionIndex.String_or_char_Stringliteral:
                // <STRING_OR_CHAR> ::= StringLiteral
                break;

            case (short)ProductionIndex.String_or_char_Charliteral:
                // <STRING_OR_CHAR> ::= CharLiteral
                break;

            case (short)ProductionIndex.String_or_char:
                // <STRING_OR_CHAR> ::=
                break;

            case (short)ProductionIndex.Parameter_decl:
                // <PARAMETER_DECL> ::= <TYPE> <OPTIONAL_ID> <PARAMETER_DECLL>
                break;

            case (short)ProductionIndex.Parameter_decl2:
                // <PARAMETER_DECL> ::=
                break;

            case (short)ProductionIndex.Parameter_decll_Comma:
                // <PARAMETER_DECLL> ::= ',' <TYPE> <OPTIONAL_ID> <PARAMETER_DECLL>
                break;

            case (short)ProductionIndex.Parameter_decll:
                // <PARAMETER_DECLL> ::=
                break;

            case (short)ProductionIndex.Parameters_Id:
                // <PARAMETERS> ::= <TYPE> Id <PARAMETER_TYPELIST>
                break;

            case (short)ProductionIndex.Parameters:
                // <PARAMETERS> ::=
                break;

            case (short)ProductionIndex.Parameter_typelist_Comma_Id:
                // <PARAMETER_TYPELIST> ::= ',' <TYPE> Id <PARAMETER_TYPELIST>
                break;

            case (short)ProductionIndex.Parameter_typelist:
                // <PARAMETER_TYPELIST> ::=
                break;

            case (short)ProductionIndex.Relop_Eqeq:
                // <RELOP> ::= '=='
                break;

            case (short)ProductionIndex.Relop_Lt:
                // <RELOP> ::= '<'
                break;

            case (short)ProductionIndex.Relop_Lteq:
                // <RELOP> ::= '<='
                break;

            case (short)ProductionIndex.Relop_Gt:
                // <RELOP> ::= '>'
                break;

            case (short)ProductionIndex.Relop_Gteq:
                // <RELOP> ::= '>='
                break;

            case (short)ProductionIndex.Relop_Num:
                // <RELOP> ::= '#'
                break;

            case (short)ProductionIndex.Simpleexpr:
                // <SIMPLEEXPR> ::= <TERM> <SIMPLEEXPRLIST>
                break;

            case (short)ProductionIndex.Simpleexprlist:
                // <SIMPLEEXPRLIST> ::= <ADDOP> <TERM> <SIMPLEEXPRLIST>
                break;

            case (short)ProductionIndex.Simpleexprlist2:
                // <SIMPLEEXPRLIST> ::=
                break;

            case (short)ProductionIndex.Stmt:
                // <STMT> ::= <BLOCK>
                break;

            case (short)ProductionIndex.Stmt2:
                // <STMT> ::= <TRYSTMT>
                break;

            case (short)ProductionIndex.Stmt3:
                // <STMT> ::= <IFSTMT>
                break;

            case (short)ProductionIndex.Stmt4:
                // <STMT> ::= <LOOPSTMT>
                break;

            case (short)ProductionIndex.Stmt5:
                // <STMT> ::= <ASSIGNSTMT>
                break;

            case (short)ProductionIndex.Stmt6:
                // <STMT> ::= <CALLSTMT>
                break;

            case (short)ProductionIndex.Stmt7:
                // <STMT> ::= <OUTPUTSTMT>
                break;

            case (short)ProductionIndex.Stmt8:
                // <STMT> ::= <INPUTSTMT>
                break;

            case (short)ProductionIndex.Stmt_Continue:
                // <STMT> ::= continue
                break;

            case (short)ProductionIndex.Stmt_Break:
                // <STMT> ::= break
                break;

            case (short)ProductionIndex.Stmt_Return:
                // <STMT> ::= return
                break;

            case (short)ProductionIndex.Stmt_Return2:
                // <STMT> ::= return <EXPR>
                break;

            case (short)ProductionIndex.Stmt_Exit:
                // <STMT> ::= exit
                break;

            case (short)ProductionIndex.Stmt_Throw:
                // <STMT> ::= throw <EXPR>
                break;

            case (short)ProductionIndex.Stmtlist_Semi:
                // <STMTLIST> ::= <STMT> ';' <STMTLISTLIST>
                break;

            case (short)ProductionIndex.Stmtlist:
                // <STMTLIST> ::=
                break;

            case (short)ProductionIndex.Stmtlistlist_Semi:
                // <STMTLISTLIST> ::= <STMT> ';' <STMTLISTLIST>
                break;

            case (short)ProductionIndex.Stmtlistlist:
                // <STMTLISTLIST> ::=
                break;

            case (short)ProductionIndex.Super_init_Super_Lparan_Rparan:
                // <SUPER_INIT> ::= super '(' <ARGLIST> ')'
                break;

            case (short)ProductionIndex.Super_init:
                // <SUPER_INIT> ::=
                break;

            case (short)ProductionIndex.Super_class_Extends_Id:
                // <SUPER_CLASS> ::= extends Id
                break;

            case (short)ProductionIndex.Super_class:
                // <SUPER_CLASS> ::=
                break;

            case (short)ProductionIndex.Term:
                // <TERM> ::= <FACTOR> <TERMLIST>
                break;

            case (short)ProductionIndex.Termlist:
                // <TERMLIST> ::= <MULTOP> <FACTOR> <TERMLIST>
                break;

            case (short)ProductionIndex.Termlist2:
                // <TERMLIST> ::=
                break;

            case (short)ProductionIndex.This_init_This_Lparan_Rparan:
                // <THIS_INIT> ::= this '(' <ARGLIST> ')'
                break;

            case (short)ProductionIndex.This_init:
                // <THIS_INIT> ::=
                break;

            case (short)ProductionIndex.Trystmt_Try_End_Try:
                // <TRYSTMT> ::= try <STMTLIST> <CATCH_CLAUSE> <CATCH_CLAUSEE> end try
                break;

            case (short)ProductionIndex.Catch_clausee:
                // <CATCH_CLAUSEE> ::= <CATCH_CLAUSE> <CATCH_CLAUSEE>
                break;

            case (short)ProductionIndex.Catch_clausee2:
                // <CATCH_CLAUSEE> ::=
                break;

            case (short)ProductionIndex.Type:
                // <TYPE> ::= <Structure_Type>
                break;

            case (short)ProductionIndex.Type2:
                // <TYPE> ::= <Primitive_Type>
                break;

            case (short)ProductionIndex.Type3:
                // <TYPE> ::= <Array_Type>
                break;

            case (short)ProductionIndex.Primitive_type_Integer:
                // <Primitive_Type> ::= integer
                break;

            case (short)ProductionIndex.Primitive_type_Boolean:
                // <Primitive_Type> ::= boolean
                break;

            case (short)ProductionIndex.Structure_type_Id:
                // <Structure_Type> ::= Id
                break;

            case (short)ProductionIndex.Array_type_Lbracketrbracket:
                // <Array_Type> ::= <Structure_Type> '[]'
                break;

            case (short)ProductionIndex.Array_type_Lbracketrbracket2:
                // <Array_Type> ::= <Primitive_Type> '[]'
                break;

            case (short)ProductionIndex.Value_or_ref_This:
                // <VALUE_OR_REF> ::= this
                break;

            case (short)ProductionIndex.Value_or_ref_Super:
                // <VALUE_OR_REF> ::= super
                break;

            case (short)ProductionIndex.Value_or_ref_Id:
                // <VALUE_OR_REF> ::= Id
                break;

            case (short)ProductionIndex.Value_or_ref_Id_Lbracket_Rbracket:
                // <VALUE_OR_REF> ::= Id '[' <EXPR> ']'
                break;

            case (short)ProductionIndex.Value_or_ref_Id_Lparan_Rparan:
                // <VALUE_OR_REF> ::= Id '(' <ARGLIST> ')'
                break;

            case (short)ProductionIndex.Value_or_ref_Lparan_Rparan:
                // <VALUE_OR_REF> ::= '(' <EXPR> ')'
                break;

            case (short)ProductionIndex.Vardeclist_Id_Semi:
                // <VARDECLIST> ::= <TYPE> Id <VAR_TYPELIST> ';'
                break;

            case (short)ProductionIndex.Var_typelist_Comma_Id:
                // <VAR_TYPELIST> ::= ',' Id <VAR_TYPELIST>
                break;

            case (short)ProductionIndex.Var_typelist:
                // <VAR_TYPELIST> ::=
                break;

            case (short)ProductionIndex.Vardecs_Declare:
                // <VARDECS> ::= declare <VARDECLIST> <VARDECS>
                break;

            case (short)(short)ProductionIndex.Vardecs:
                // <VARDECS> ::=
                break;

        }  //switch

        return result;
    }
示例#29
0
 public static UISharedProperties FromReduction(GOLD.Reduction r)
 {
     UISharedProperties result = new UISharedProperties();
     return result;
 }
示例#30
0
        public object Execute(GOLD.Reduction node)
        {
            if (node.Count() == 3)
            {
                // van operátor és két operandus, először a két nem terminálist kell bontnai, majd a terminálisként adott operátorral
                // elvégzem a megfelelő műveletet és értéket adok/másolom

                string _operator = null;
                object _operand1 = null
                    ,  _operand2 = null
                    ;

                for (int i = 0; i < node.Count(); i++)
                {
                    switch (node[i].Type())
                    {
                        case SymbolType.Nonterminal: // Nemterminálisok vizsgálata

                            string type = Regex.Replace(node[i].Parent.ToString(), "[^0-9a-zA-Z]+", "");
                            Enums.eNonTerminals ntt = (Enums.eNonTerminals)Enum.Parse(typeof(Enums.eNonTerminals), type);

                            if (_operand1 == null)
                            {
                                /*
                                 * Elsőként meg kell nézni, hogy a keresett objektum Document, vagy Resource
                                 * A második lépés, hogy az ennek megfelelő objektumot az arra létrehozott service-től lekérjük
                                 * Az objektum lekérése után a lebontás kicsit másképp néz ki majd az eddigiekhez képes, ugyanis
                                 * objektumon belüli elérési vizsgálatokkal folytatódik
                                 */

                                // Element lekérés, majd ID -> megkapom a hivatkozandó neveket, ezeket pedig feldolgozom
                                _operand1 = Context.NonTerminalContext.Execute(ntt, (GOLD.Reduction)node[i].Data);
                            }
                            else
                            {
                                /*
                                 * Amennyiben az objektum lekérése sikeresen megtörtént, a lebontás itt folytatódik az objektumon belüli
                                 * hivatkozás kiértékelésével (létezik-e, ha igen, akkor mi az, stb...)
                                 */

                                // belső hivatkozott név, csupán a továbbbontáshoz kell
                                _operand2 = Context.NonTerminalContext.Execute(ntt, (GOLD.Reduction)node[i].Data);
                            }

                            break;

                        case SymbolType.Error:
                            Console.WriteLine("ERROR in Logical_Engine.Classes.Processor.ProcessTree");
                            break;

                        default:
                            // Terminálisok vizsgálata - itt operátor jel
                            _operator = node[i].Data as string;
                            break;
                    }
                }

                if (_operator != null)
                    _operand1 = Operation(_operand1, _operator, _operand2);
                Console.WriteLine("Chain value: " + _operand1 + " type: " + _operand1.GetType());
                return _operand1;

            }
            else
            {
                // egy nem terminális van, azt kell lebontani, majd
                // értékadás/másolás
                string type = Regex.Replace(node[0].Parent.ToString(), "[^0-9a-zA-Z]+", "");
                Enums.eNonTerminals ntt = (Enums.eNonTerminals)Enum.Parse(typeof(Enums.eNonTerminals), type);

                object returnValue = Context.NonTerminalContext.Execute(ntt, (GOLD.Reduction)node[0].Data);
                Console.WriteLine("Expression value: " + returnValue + " type: " + returnValue.GetType());
                return returnValue;
            }
        }
示例#31
0
    private object CreateNewObject(GOLD.Reduction r)
    {
        object result = null;

        switch (r.Parent.TableIndex())
        {
            case (short)ProductionIndex.Program:
        // <PROGRAM> ::= <CLASS>
        break;

        case (short)ProductionIndex.Program2:
        // <PROGRAM> ::= <METHOD>
        break;

        case (short)ProductionIndex.Program3:
        // <PROGRAM> ::= <PROGRAM> <CLASS>
        break;

        case (short)ProductionIndex.Program4:
        // <PROGRAM> ::= <PROGRAM> <METHOD>
        break;

        case (short)ProductionIndex.Body:
        // <BODY> ::= <SUPER_INIT> <THIS_INIT> <BLOCK>
        break;

        case (short)ProductionIndex.Body2:
        // <BODY> ::= <THIS_INIT> <BLOCK>
        break;

        case (short)ProductionIndex.Body3:
        // <BODY> ::= <SUPER_INIT> <BLOCK>
        break;

        case (short)ProductionIndex.Body4:
        // <BODY> ::= <BLOCK>
        break;

        case (short)ProductionIndex.This_init_This_Lparan_Rparan:
        // <THIS_INIT> ::= this '(' <ARGLIST> ')'
        break;

        case (short)ProductionIndex.Super_init_Super_Lparan_Rparan:
        // <SUPER_INIT> ::= super '(' <ARGLIST> ')'
        break;

        case (short)ProductionIndex.Block_Begin_End:
        // <BLOCK> ::= <VARDECS> begin <STATEMENTS> end
        break;

        case (short)ProductionIndex.Block_Begin_End2:
        // <BLOCK> ::= begin <STATEMENTS> end
        break;

        case (short)ProductionIndex.Vardeclist_Id_Semi:
        // <VARDECLIST> ::= <TYPE> Id ';'
        break;

        case (short)ProductionIndex.Vardeclist_Id_Semi2:
        // <VARDECLIST> ::= <TYPE> Id <VAR_TYPELIST> ';'
        break;

        case (short)ProductionIndex.Var_typelist_Comma_Id:
        // <VAR_TYPELIST> ::= ',' Id <VAR_TYPELIST>
        break;

        case (short)ProductionIndex.Vardecs_Declare:
        // <VARDECS> ::= declare <VARDECLIST>
        break;

        case (short)ProductionIndex.Vardecs_Declare2:
        // <VARDECS> ::= declare <VARDECLIST> <VARDECS>
        break;

        case (short)ProductionIndex.Name_Id:
        // <NAME> ::= Id
        break;

        case (short)ProductionIndex.Name_Dot_Id:
        // <NAME> ::= <NAME> '.' Id
        break;

        case (short)ProductionIndex.Assignment_Eq:
        // <ASSIGNMENT> ::= <NAME> '=' <EXPRESSION>
        break;

        case (short)ProductionIndex.Factor_This:
        // <FACTOR> ::= this
        break;

        case (short)ProductionIndex.Factor_Super:
        // <FACTOR> ::= super
        break;

        case (short)ProductionIndex.Factor_Number:
        // <FACTOR> ::= Number
        break;

        case (short)ProductionIndex.Factor_False:
        // <FACTOR> ::= false
        break;

        case (short)ProductionIndex.Factor_True:
        // <FACTOR> ::= true
        break;

        case (short)ProductionIndex.Factor_Null:
        // <FACTOR> ::= null
        break;

        case (short)ProductionIndex.Factor:
        // <FACTOR> ::= <ALLOCATOR>
        break;

        case (short)ProductionIndex.Factor2:
        // <FACTOR> ::= <CAST_EXPR>
        break;

        case (short)ProductionIndex.Allocator_New_Lparan_Rparan:
        // <ALLOCATOR> ::= new <TYPE> '(' <ARGLIST> ')'
        break;

        case (short)ProductionIndex.Allocator_New_Lparan_Rparan2:
        // <ALLOCATOR> ::= new <TYPE> '(' ')'
        break;

        case (short)ProductionIndex.Allocator_New_Lbracket_Rbracket:
        // <ALLOCATOR> ::= new <TYPE> '[' <EXPRESSION> ']'
        break;

        case (short)ProductionIndex.Arglist:
        // <ARGLIST> ::= <EXPRESSION>
        break;

        case (short)ProductionIndex.Arglist_Comma:
        // <ARGLIST> ::= <ARGLIST> ',' <EXPRESSION>
        break;

        case (short)ProductionIndex.Cast_expr_Cast_Lparan_Comma_Rparan:
        // <CAST_EXPR> ::= cast '(' <TYPE> ',' <EXPRESSION> ')'
        break;

        case (short)ProductionIndex.Expression:
        // <EXPRESSION> ::= <EXPRESSION_TERM>
        break;

        case (short)ProductionIndex.Expression_Plus:
        // <EXPRESSION> ::= <EXPRESSION> '+' <EXPRESSION_TERM>
        break;

        case (short)ProductionIndex.Expression_Minus:
        // <EXPRESSION> ::= <EXPRESSION> '-' <EXPRESSION_TERM>
        break;

        case (short)ProductionIndex.Expression_term:
        // <EXPRESSION_TERM> ::= <EXPRESSION_FACTOR>
        break;

        case (short)ProductionIndex.Expression_term_Times:
        // <EXPRESSION_TERM> ::= <EXPRESSION_TERM> '*' <EXPRESSION_FACTOR>
        break;

        case (short)ProductionIndex.Expression_term_Div:
        // <EXPRESSION_TERM> ::= <EXPRESSION_TERM> '/' <EXPRESSION_FACTOR>
        break;

        case (short)ProductionIndex.Expression_factor:
        // <EXPRESSION_FACTOR> ::= <EXPRESSION_BINARY>
        break;

        case (short)ProductionIndex.Expression_factor_Percent:
        // <EXPRESSION_FACTOR> ::= <EXPRESSION_FACTOR> '%' <EXPRESSION_BINARY>
        break;

        case (short)ProductionIndex.Expression_factor_Gt:
        // <EXPRESSION_FACTOR> ::= <EXPRESSION_FACTOR> '>' <EXPRESSION_BINARY>
        break;

        case (short)ProductionIndex.Expression_factor_Lt:
        // <EXPRESSION_FACTOR> ::= <EXPRESSION_FACTOR> '<' <EXPRESSION_BINARY>
        break;

        case (short)ProductionIndex.Expression_factor_Gteq:
        // <EXPRESSION_FACTOR> ::= <EXPRESSION_FACTOR> '>=' <EXPRESSION_BINARY>
        break;

        case (short)ProductionIndex.Expression_factor_Lteq:
        // <EXPRESSION_FACTOR> ::= <EXPRESSION_FACTOR> '<=' <EXPRESSION_BINARY>
        break;

        case (short)ProductionIndex.Expression_factor_Eqeq:
        // <EXPRESSION_FACTOR> ::= <EXPRESSION_FACTOR> '==' <EXPRESSION_BINARY>
        break;

        case (short)ProductionIndex.Expression_factor_Num:
        // <EXPRESSION_FACTOR> ::= <EXPRESSION_FACTOR> '#' <EXPRESSION_BINARY>
        break;

        case (short)ProductionIndex.Expression_binary:
        // <EXPRESSION_BINARY> ::= <EXPRESSION_UNARY>
        break;

        case (short)ProductionIndex.Expression_binary_Ampamp:
        // <EXPRESSION_BINARY> ::= <EXPRESSION_BINARY> '&&' <EXPRESSION_UNARY>
        break;

        case (short)ProductionIndex.Expression_binary_Pipepipe:
        // <EXPRESSION_BINARY> ::= <EXPRESSION_BINARY> '||' <EXPRESSION_UNARY>
        break;

        case (short)ProductionIndex.Expression_unary_Plus:
        // <EXPRESSION_UNARY> ::= '+' <EXPRESSION_PRIMARY>
        break;

        case (short)ProductionIndex.Expression_unary_Minus:
        // <EXPRESSION_UNARY> ::= '-' <EXPRESSION_PRIMARY>
        break;

        case (short)ProductionIndex.Expression_unary_Exclam:
        // <EXPRESSION_UNARY> ::= '!' <EXPRESSION_PRIMARY>
        break;

        case (short)ProductionIndex.Expression_unary:
        // <EXPRESSION_UNARY> ::= <EXPRESSION_PRIMARY>
        break;

        case (short)ProductionIndex.Expression_unary_Lbracket_Rbracket:
        // <EXPRESSION_UNARY> ::= <EXPRESSION_PRIMARY> '[' <EXPRESSION> ']'
        break;

        case (short)ProductionIndex.Expression_unary_Lparan_Rparan:
        // <EXPRESSION_UNARY> ::= <EXPRESSION_PRIMARY> '(' <ARGLIST> ')'
        break;

        case (short)ProductionIndex.Expression_primary:
        // <EXPRESSION_PRIMARY> ::= <NAME>
        break;

        case (short)ProductionIndex.Expression_primary2:
        // <EXPRESSION_PRIMARY> ::= <FUNCTION_CALL>
        break;

        case (short)ProductionIndex.Expression_primary3:
        // <EXPRESSION_PRIMARY> ::= <FACTOR>
        break;

        case (short)ProductionIndex.Statements:
        // <STATEMENTS> ::= <STATEMENT>
        break;

        case (short)ProductionIndex.Statements2:
        // <STATEMENTS> ::= <STATEMENTS> <STATEMENT>
        break;

        case (short)ProductionIndex.Statement:
        // <STATEMENT> ::= <BLOCK>
        break;

        case (short)ProductionIndex.Statement2:
        // <STATEMENT> ::= <METHOD>
        break;

        case (short)ProductionIndex.Statement3:
        // <STATEMENT> ::= <CLASS>
        break;

        case (short)ProductionIndex.Statement_Semi:
        // <STATEMENT> ::= <FUNCTION_CALL> ';'
        break;

        case (short)ProductionIndex.Statement_Semi2:
        // <STATEMENT> ::= <ASSIGNMENT> ';'
        break;

        case (short)ProductionIndex.Statement_Semi3:
        // <STATEMENT> ::= <INPUTSTMT> ';'
        break;

        case (short)ProductionIndex.Statement_Semi4:
        // <STATEMENT> ::= <OUTPUTSTMT> ';'
        break;

        case (short)ProductionIndex.Statement_Return_Semi:
        // <STATEMENT> ::= return <EXPRESSION> ';'
        break;

        case (short)ProductionIndex.Statement_Return_Semi2:
        // <STATEMENT> ::= return ';'
        break;

        case (short)ProductionIndex.Statement_Continue_Semi:
        // <STATEMENT> ::= continue ';'
        break;

        case (short)ProductionIndex.Statement_Break_Semi:
        // <STATEMENT> ::= break ';'
        break;

        case (short)ProductionIndex.Statement4:
        // <STATEMENT> ::= <IFSTMT>
        break;

        case (short)ProductionIndex.Statement5:
        // <STATEMENT> ::= <TRYSTMT>
        break;

        case (short)ProductionIndex.Statement_Loop_End_Loop:
        // <STATEMENT> ::= loop <STATEMENTS> end loop
        break;

        case (short)ProductionIndex.Statement_Exit_Semi:
        // <STATEMENT> ::= exit ';'
        break;

        case (short)ProductionIndex.Statement_Throw_Semi:
        // <STATEMENT> ::= throw <EXPRESSION> ';'
        break;

        case (short)ProductionIndex.Ifstmt_If_Then_End_If:
        // <IFSTMT> ::= if <EXPRESSION> then <STATEMENTS> end if
        break;

        case (short)ProductionIndex.Ifstmt_If_Then_End_If2:
        // <IFSTMT> ::= if <EXPRESSION> then <STATEMENTS> <ELSEPART> end if
        break;

        case (short)ProductionIndex.Ifstmt_If_Then_End_If3:
        // <IFSTMT> ::= if <EXPRESSION> then <STATEMENTS> <ELSEIF_PART> <ELSEPART> end if
        break;

        case (short)ProductionIndex.Elsepart_Else:
        // <ELSEPART> ::= else <STATEMENTS>
        break;

        case (short)ProductionIndex.Elseif_part_Elsif_Then:
        // <ELSEIF_PART> ::= elsif <EXPRESSION> then <STATEMENTS>
        break;

        case (short)ProductionIndex.Elseif_part_Elsif_Then2:
        // <ELSEIF_PART> ::= elsif <EXPRESSION> then <STATEMENTS> <ELSEIF_PART>
        break;

        case (short)ProductionIndex.Trystmt_Try_End_Try:
        // <TRYSTMT> ::= try <STATEMENTS> <CATCH_CLAUSE> end try
        break;

        case (short)ProductionIndex.Catch_clause_Catch_Lparan_Id_Rparan:
        // <CATCH_CLAUSE> ::= catch '(' <TYPE> Id ')' <STATEMENTS>
        break;

        case (short)ProductionIndex.Catch_clause_Catch_Lparan_Id_Rparan2:
        // <CATCH_CLAUSE> ::= catch '(' <TYPE> Id ')' <STATEMENTS> <CATCH_CLAUSE>
        break;

        case (short)ProductionIndex.Outputstmt_Output_Ltlt:
        // <OUTPUTSTMT> ::= output '<<' <EXPRESSION>
        break;

        case (short)ProductionIndex.Outputstmt_Output_Ltlt_Stringliteral:
        // <OUTPUTSTMT> ::= output '<<' StringLiteral
        break;

        case (short)ProductionIndex.Outputstmt_Output_Ltlt_Charliteral:
        // <OUTPUTSTMT> ::= output '<<' CharLiteral
        break;

        case (short)ProductionIndex.Inputstmt_Input_Gtgt:
        // <INPUTSTMT> ::= input '>>' <NAME>
        break;

        case (short)ProductionIndex.Type:
        // <TYPE> ::= <STRUCTURE_TYPE>
        break;

        case (short)ProductionIndex.Type2:
        // <TYPE> ::= <PRIMITIVE_TYPE>
        break;

        case (short)ProductionIndex.Type3:
        // <TYPE> ::= <ARRAY_TYPE>
        break;

        case (short)ProductionIndex.Primitive_type_Integer:
        // <PRIMITIVE_TYPE> ::= integer
        break;

        case (short)ProductionIndex.Primitive_type_Boolean:
        // <PRIMITIVE_TYPE> ::= boolean
        break;

        case (short)ProductionIndex.Structure_type_Id:
        // <STRUCTURE_TYPE> ::= Id
        break;

        case (short)ProductionIndex.Array_type_Lbracketrbracket:
        // <ARRAY_TYPE> ::= <STRUCTURE_TYPE> '[]'
        break;

        case (short)ProductionIndex.Array_type_Lbracketrbracket2:
        // <ARRAY_TYPE> ::= <PRIMITIVE_TYPE> '[]'
        break;

        case (short)ProductionIndex.Access_spec_Private:
        // <ACCESS_SPEC> ::= private
        break;

        case (short)ProductionIndex.Access_spec_Protected:
        // <ACCESS_SPEC> ::= protected
        break;

        case (short)ProductionIndex.Access_spec_Public:
        // <ACCESS_SPEC> ::= public
        break;

        case (short)ProductionIndex.Field_decl_Semi:
        // <FIELD_DECL> ::= <ACCESS_SPEC> <TYPE> <FIELD_DECLLIST> ';'
        break;

        case (short)ProductionIndex.Field_decllist_Id:
        // <FIELD_DECLLIST> ::= Id
        break;

        case (short)ProductionIndex.Field_decllist_Comma_Id:
        // <FIELD_DECLLIST> ::= <FIELD_DECLLIST> ',' Id
        break;

        case (short)ProductionIndex.Method_Method_Lparan_Rparan_Is_Id:
        // <METHOD> ::= method <M_TYPE> <METHOD_ID> '(' <PARAMETERS> ')' is <BODY> Id
        break;

        case (short)ProductionIndex.Method_Method_Lparan_Rparan_Is_Id2:
        // <METHOD> ::= method <M_TYPE> <METHOD_ID> '(' ')' is <BODY> Id
        break;

        case (short)ProductionIndex.Method_decl_Method_Id_Lparan_Rparan_Semi:
        // <METHOD_DECL> ::= <ACCESS_SPEC> method <M_TYPE> Id '(' <PARAMETER_DECL> ')' ';'
        break;

        case (short)ProductionIndex.Method_decl_Method_Id_Lparan_Rparan_Semi2:
        // <METHOD_DECL> ::= <ACCESS_SPEC> method <M_TYPE> Id '(' ')' ';'
        break;

        case (short)ProductionIndex.Method_id_Id_Coloncolon_Id:
        // <METHOD_ID> ::= Id '::' Id
        break;

        case (short)ProductionIndex.Method_id_Id:
        // <METHOD_ID> ::= Id
        break;

        case (short)ProductionIndex.M_type:
        // <M_TYPE> ::= <TYPE>
        break;

        case (short)ProductionIndex.M_type_Void:
        // <M_TYPE> ::= void
        break;

        case (short)ProductionIndex.Parameters_Id:
        // <PARAMETERS> ::= <TYPE> Id
        break;

        case (short)ProductionIndex.Parameters_Comma_Id:
        // <PARAMETERS> ::= <PARAMETERS> ',' <TYPE> Id
        break;

        case (short)ProductionIndex.Parameter_decl_Id:
        // <PARAMETER_DECL> ::= <TYPE> Id
        break;

        case (short)ProductionIndex.Parameter_decl:
        // <PARAMETER_DECL> ::= <TYPE>
        break;

        case (short)ProductionIndex.Parameter_decl_Comma_Id:
        // <PARAMETER_DECL> ::= <PARAMETER_DECL> ',' <TYPE> Id
        break;

        case (short)ProductionIndex.Parameter_decl_Comma:
        // <PARAMETER_DECL> ::= <PARAMETER_DECL> ',' <TYPE>
        break;

        case (short)ProductionIndex.Function_call_Call_Lparan_Rparan:
        // <FUNCTION_CALL> ::= call <NAME> '(' ')'
        break;

        case (short)ProductionIndex.Function_call_Call_Lparan_Rparan2:
        // <FUNCTION_CALL> ::= call <NAME> '(' <ARGLIST> ')'
        break;

        case (short)ProductionIndex.Class_Class_Id_Is_End_Id:
        // <CLASS> ::= class Id <SUPER_CLASS> is <CLASS_MEMBERLIST> end Id
        break;

        case (short)ProductionIndex.Class_Class_Id_Is_End_Id2:
        // <CLASS> ::= class Id is <CLASS_MEMBERLIST> end Id
        break;

        case (short)ProductionIndex.Class_memberlist:
        // <CLASS_MEMBERLIST> ::= <CLASS_MEMBER>
        break;

        case (short)ProductionIndex.Class_memberlist2:
        // <CLASS_MEMBERLIST> ::= <CLASS_MEMBERLIST> <CLASS_MEMBER>
        break;

        case (short)ProductionIndex.Class_member:
        // <CLASS_MEMBER> ::= <FIELD_DECL>
        break;

        case (short)ProductionIndex.Class_member2:
        // <CLASS_MEMBER> ::= <METHOD_DECL>
        break;

        case (short)ProductionIndex.Super_class_Extends_Id:
        // <SUPER_CLASS> ::= extends Id
        break;

        } //switch

        return result;
    }
示例#32
0
    private object CreateNewObject(GOLD.Reduction r)
    {
        object result = null;

        switch( (ProductionIndex) r.Parent.TableIndex)
        {
            case ProductionIndex.Nl_Newline:
                // <nl> ::= NewLine <nl>
                break;

            case ProductionIndex.Nl_Newline2:
                // <nl> ::= NewLine
                break;

            case ProductionIndex.Multiplier_Plus:
                // <Multiplier> ::= '+'
                break;

            case ProductionIndex.Multiplier_Times:
                // <Multiplier> ::= '*'
                break;

            case ProductionIndex.Multiplier:
                // <Multiplier> ::=
                break;

            case ProductionIndex.Regform_Pipepipe:
                // <regForm> ::= <regForm> '||' <regFormSeq>
                break;

            case ProductionIndex.Regform:
                // <regForm> ::= <regFormSeq>
                break;

            case ProductionIndex.Regformseq_Dot:
                // <regFormSeq> ::= <regFormSeq> '.' <regForm>
                break;

            case ProductionIndex.Regformseq:
                // <regFormSeq> ::= <regFormValue>
                break;

            case ProductionIndex.Regformvalue_Identifier:
                // <regFormValue> ::= Identifier <Multiplier>
                break;

            case ProductionIndex.Regformvalue_Not:
                // <regFormValue> ::= not <regForm>
                break;

            case ProductionIndex.Regformvalue_Lparen_Rparen:
                // <regFormValue> ::= '(' <regForm> ')' <Multiplier>
                break;

            case ProductionIndex.Muform_Identifier:
                // <muForm> ::= Identifier
                break;

            case ProductionIndex.Muform_Variable:
                // <muForm> ::= Variable
                break;

            case ProductionIndex.Muform_Lparen_Pipepipe_Rparen:
                // <muForm> ::= '(' <muForm> '||' <muForm> ')'
                break;

            case ProductionIndex.Muform_Lparen_Ampamp_Rparen:
                // <muForm> ::= '(' <muForm> '&&' <muForm> ')'
                break;

            case ProductionIndex.Muform_Lt_Gt:
                // <muForm> ::= '<' <regForm> '>' <muForm>
                break;

            case ProductionIndex.Muform_Lbracket_Rbracket:
                // <muForm> ::= '[' <regForm> ']' <muForm>
                break;

            case ProductionIndex.Muform_Mu_Variable_Dot:
                // <muForm> ::= mu Variable '.' <muForm>
                break;

            case ProductionIndex.Muform_Nu_Variable_Dot:
                // <muForm> ::= nu Variable '.' <muForm>
                break;

            case ProductionIndex.Muform_Not:
                // <muForm> ::= not <muForm>
                break;

            case ProductionIndex.Muform_Lparen_Rparen:
                // <muForm> ::= '(' <muForm> ')'
                break;

            case ProductionIndex.Line_Commentl:
                // <Line> ::= CommentL <nl>
                break;

            case ProductionIndex.Line:
                // <Line> ::= <muForm> <nl>
                break;

            case ProductionIndex.Line2:
                // <Line> ::= <nl>
                break;

            case ProductionIndex.Lines:
                // <Lines> ::= <Line> <Lines>
                break;

            case ProductionIndex.Lines2:
                // <Lines> ::=
                break;

        }  //switch

        return result;
    }