Elements() public method

public Elements ( ) : int
return int
示例#1
0
文件: DFA.cs 项目: omaragb/tlp182
        public Comment firstComment;    // list of comments

        string CommentStr(Node p)
        {
            StringBuilder s = new StringBuilder();

            while (p != null)
            {
                if (p.typ == Node.chr)
                {
                    s.Append((char)p.val);
                }
                else if (p.typ == Node.clas)
                {
                    CharSet set = tab.CharClassSet(p.val);
                    if (set.Elements() != 1)
                    {
                        parser.SemErr("character set contains more than 1 character");
                    }
                    s.Append((char)set.First());
                }
                else
                {
                    parser.SemErr("comment delimiters may not be structured");
                }
                p = p.next;
            }
            if (s.Length == 0 || s.Length > 2)
            {
                parser.SemErr("comment delimiters must be 1 or 2 characters long");
                s = new StringBuilder("?");
            }
            return(s.ToString());
        }
示例#2
0
文件: DFA.cs 项目: omaragb/tlp182
 public void ShiftWith(CharSet s, Tab tab)
 {
     if (s.Elements() == 1)
     {
         typ = Node.chr; sym = s.First();
     }
     else
     {
         CharClass c = tab.FindCharClass(s);
         if (c == null)
         {
             c = tab.NewCharClass("#", s);                    // class with dummy name
         }
         typ = Node.clas; sym = c.n;
     }
 }
示例#3
0
 public void ShiftWith(CharSet s, Tab tab)
 {
     if (s.Elements() == 1) {
     typ = Node.chr; sym = s.First();
     } else {
     CharClass c = tab.FindCharClass(s);
     if (c == null) c = tab.NewCharClass("#", s); // class with dummy name
     typ = Node.clas; sym = c.n;
     }
 }