void Coco() { Symbol sym; Graph g, g1, g2; string gramName; CharSet s; int beg, line; if (StartOf(1)) { Get(); beg = t.pos; line = t.line; while (StartOf(1)) { Get(); } pgen.usingPos = new Position(beg, la.pos, 0, line); } Expect(6); genScanner = true; tab.ignored = new CharSet(); Expect(1); gramName = t.val; beg = la.pos; line = la.line; while (StartOf(2)) { Get(); } tab.semDeclPos = new Position(beg, la.pos, 0, line); if (la.kind == 7) { Get(); dfa.ignoreCase = true; } if (la.kind == 8) { Get(); while (la.kind == 1) { SetDecl(); } } if (la.kind == 9) { Get(); while (la.kind == 1 || la.kind == 3 || la.kind == 5) { TokenDecl(Node.t); } } if (la.kind == 10) { Get(); while (la.kind == 1 || la.kind == 3 || la.kind == 5) { TokenDecl(Node.pr); } } while (la.kind == 11) { Get(); bool nested = false; Expect(12); TokenExpr(out g1); Expect(13); TokenExpr(out g2); if (la.kind == 14) { Get(); nested = true; } dfa.NewComment(g1.l, g2.l, nested); } while (la.kind == 15) { Get(); Set(out s); tab.ignored.Or(s); } while (!(la.kind == 0 || la.kind == 16)) { SynErr(42); Get(); } Expect(16); if (genScanner) { dfa.MakeDeterministic(); } tab.DeleteNodes(); while (la.kind == 1) { Get(); sym = tab.FindSym(t.val); bool undef = sym == null; if (undef) { sym = tab.NewSym(Node.nt, t.val, t.line); } else { if (sym.typ == Node.nt) { if (sym.graph != null) { SemErr("name declared twice"); } } else { SemErr("this symbol kind not allowed on left side of production"); } sym.line = t.line; } bool noAttrs = sym.attrPos == null; sym.attrPos = null; if (la.kind == 24 || la.kind == 26) { AttrDecl(sym); } if (!undef) { if (noAttrs != (sym.attrPos == null)) { SemErr("attribute mismatch between declaration and use of this symbol"); } } if (la.kind == 39) { SemText(out sym.semPos); } ExpectWeak(17, 3); Expression(out g); sym.graph = g.l; tab.Finish(g); ExpectWeak(18, 4); } Expect(19); Expect(1); if (gramName != t.val) { SemErr("name does not match grammar name"); } tab.gramSy = tab.FindSym(gramName); if (tab.gramSy == null) { SemErr("missing production for grammar name"); } else { sym = tab.gramSy; if (sym.attrPos != null) { SemErr("grammar symbol must not have attributes"); } } tab.noSym = tab.NewSym(Node.t, "???", 0); // noSym gets highest number tab.SetupAnys(); tab.RenumberPragmas(); if (tab.ddt[2]) { tab.PrintNodes(); } if (errors.count == 0) { Console.WriteLine("checking"); tab.CompSymbolSets(); if (tab.ddt[7]) { tab.XRef(); } if (tab.GrammarOk()) { Console.Write("parser"); pgen.WriteParser(); if (genScanner) { Console.Write(" + scanner"); dfa.WriteScanner(); if (tab.ddt[0]) { dfa.PrintStates(); } } Console.WriteLine(" generated"); if (tab.ddt[8]) { pgen.WriteStatistics(); } } } if (tab.ddt[6]) { tab.PrintSymbolTable(); } Expect(18); }