// el token da maloosh ay 30 lazma wlahi w 2arfni w hamoot w ashylo bas m7tag ashylo mn 200 alf 7eta f shylo enta law sm7t
        public Boolean MatchExpression(Node node, Token token, GrammarRule GR)
        {
            string grTypyFull = GR.GetType().ToString();
            string grType     = grTypyFull.Substring(grTypyFull.LastIndexOf('.') + 1);

            // MessageBox.Show(grType);
            if (grType[0] == 'G')
            {
                grType = grType.Substring(2);
            }


            /* MessageBox.Show("MATCH EXPRESSION \ngrtypr:: " + grType +
             *   "\ntokenValue::  " + token.tokenValue + "\ntokenType:: " + token.tokenValue
             + "\nnode::  " + node.Text + "\n GRtype::\t" + GR.GetType() + "\nlasttype\t" + lastTokenType);
             */

            //+ "\ntokenValue::  " + token.tokenValue + "\ntokenType:: " + token.tokenValue + "\nnode::  " + node.Text

            if (GR.GetType() == typeof(GrExp))
            {
                lastTokenType = grType;

                Node nodeNew = new Node(grType);
                node.AddChild(nodeNew);

                MessageBox.Show("MATCH EXPRESSION inside:: " + node.Text);

                //Match Grammar Rule
                return(GR.execute(nodeNew));
            }
            else
            {
                //MessageBox.Show("elseee");
                //lastTokenType = grType;

                //node.Text = grType;


                return(GR.execute(node));
            }
        }
Beispiel #2
0
        /// <summary>
        /// calls appropriate Grammar Rule for a certain token
        /// Advance input
        /// </summary>
        /// <param name="token"></param>
        public void MatchExpression(Node node, Token token, GrammarRule GR)
        {
            string grTypyFull = GR.GetType().ToString();
            string grType     = grTypyFull.Substring(grTypyFull.LastIndexOf('.') + 1);

            // MessageBox.Show(grType);
            if (grType[0] == 'G')
            {
                grType = grType.Substring(2);
            }
            if (GR.GetType() == typeof(GrExp))
            {
                Node nodeNew = new Node(grType);
                node.AddChild(nodeNew);
                // MessageBox.Show(token.tokenValue);
                //Match Grammar Rule
                GR.execute(nodeNew);
            }
            else
            {
                //node.Text = grType;
                GR.execute(node);
            }
        }