Пример #1
0
        static void SimSet(out BitArray s)
        {
            int n1, n2;

            s = new BitArray(CharClass.charSetSize);
            if (la.kind == 1)
            {
                Get();
                CharClass c = CharClass.Find(t.val);
                if (c == null)
                {
                    SemErr("undefined name");
                }
                else
                {
                    s.Or(c.set);
                }
            }
            else if (la.kind == 3)
            {
                Get();
                string name = t.val;
                name = DFA.Unescape(name.Substring(1, name.Length - 2));
                foreach (char ch in name)
                {
                    s[ch] = true;
                }
            }
            else if (la.kind == 5)
            {
                Char(out n1);
                s[n1] = true;
                if (la.kind == 22)
                {
                    Get();
                    Char(out n2);
                    for (int i = n1; i <= n2; i++)
                    {
                        s[i] = true;
                    }
                }
            }
            else if (la.kind == 23)
            {
                Get();
                s    = new BitArray(CharClass.charSetSize, true);
                s[0] = false;
            }
            else
            {
                SynErr(49);
            }
        }
Пример #2
0
        static void TokenFactor(out Graph g)
        {
            string name;
            int    kind;

            g = new Graph();
            if (la.kind == 1 || la.kind == 3 || la.kind == 5)
            {
                Sym(out name, out kind);
                if (kind == id)
                {
                    CharClass c = CharClass.Find(name);
                    if (c == null)
                    {
                        SemErr("undefined name");
                        c = new CharClass(name, new BitArray(CharClass.charSetSize));
                    }
                    Node p = new Node(Node.clas, null, 0);
                    p.val = c.n;
                    g     = new Graph(p);
                }
                else
                {
                    g = Graph.StrToGraph(name); // str
                }
            }
            else if (la.kind == 28)
            {
                Get();
                TokenExpr(out g);
                Expect(29);
            }
            else if (la.kind == 30)
            {
                Get();
                TokenExpr(out g);
                Expect(31);
                Graph.MakeOption(g);
            }
            else if (la.kind == 32)
            {
                Get();
                TokenExpr(out g);
                Expect(33);
                Graph.MakeIteration(g);
            }
            else
            {
                SynErr(54);
            }
        }
Пример #3
0
 public void ShiftWith(BitArray s)
 {
     if (Sets.Elements(s) == 1)
     {
         typ = Node.chr; sym = Sets.First(s);
     }
     else
     {
         CharClass c = CharClass.Find(s);
         if (c == null)
         {
             c = new CharClass("#", s);                    // class with dummy name
         }
         typ = Node.clas; sym = c.n;
     }
 }
Пример #4
0
        static void SetDecl()
        {
            BitArray s;

            Expect(1);
            string    name = t.val;
            CharClass c    = CharClass.Find(name);

            if (c != null)
            {
                SemErr("name declared twice");
            }

            Expect(8);
            Set(out s);
            if (Sets.Elements(s) == 0)
            {
                SemErr("character set must not be empty");
            }
            c = new CharClass(name, s);

            Expect(9);
        }