StrToGraph() public method

public StrToGraph ( string str ) : Graph
str string
return Graph
Beispiel #1
0
        void TokenFactor(out Graph g)
        {
            string name; int kind;

            g = null;
            if (la.kind == 1 || la.kind == 3 || la.kind == 5)
            {
                Sym(out name, out kind);
                if (kind == id)
                {
                    CharClass c = tab.FindCharClass(name);
                    if (c == null)
                    {
                        SemErr("undefined name");
                        c = tab.NewCharClass(name, new CharSet());
                    }
                    Node p = tab.NewNode(Node.clas, null, 0); p.val = c.n;
                    g           = new Graph(p);
                    tokenString = noString;
                }
                else             // str
                {
                    g = tab.StrToGraph(name);
                    if (tokenString == null)
                    {
                        tokenString = name;
                    }
                    else
                    {
                        tokenString = noString;
                    }
                }
            }
            else if (la.kind == 30)
            {
                Get();
                TokenExpr(out g);
                Expect(31);
            }
            else if (la.kind == 32)
            {
                Get();
                TokenExpr(out g);
                Expect(33);
                tab.MakeOption(g); tokenString = noString;
            }
            else if (la.kind == 34)
            {
                Get();
                TokenExpr(out g);
                Expect(35);
                tab.MakeIteration(g); tokenString = noString;
            }
            else
            {
                SynErr(51);
            }
            if (g == null)     // invalid start of TokenFactor
            {
                g = new Graph(tab.NewNode(Node.eps, null, 0));
            }
        }