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); } }
public static Graph StrToGraph(string str) { string s = DFA.Unescape(str.Substring(1, str.Length-2)); if (s.IndexOf('\0') >= 0) Parser.SemErr("\\0 not allowed here. Used as eof character"); if (s.Length == 0) Parser.SemErr("empty token not allowed"); Graph g = new Graph(); g.r = dummyNode; for (int i = 0; i < s.Length; i++) { Node p = new Node(Node.chr, (int)s[i], 0); g.r.next = p; g.r = p; } g.l = dummyNode.next; dummyNode.next = null; return g; }
static void Char(out int n) { Expect(5); string name = t.val; name = DFA.Unescape(name.Substring(1, name.Length - 2)); int max = CharClass.charSetSize; if (name.Length != 1 || name[0] > max - 1) { SemErr("unacceptable character value"); } n = name[0] % max; }