First() public method

public First ( ) : int
return int
Example #1
0
        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());
        }
Example #2
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;
     }
 }
Example #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;
     }
 }