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()); }
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; } }
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; } }