Beispiel #1
0
 public ParserGen(Parser parser)
 {
     tab = parser.tab;
     trace = parser.trace;
     buffer = parser.scanner.buffer;
     errorNr = -1;
     usingPos = null;
 }
Beispiel #2
0
 string Pos(Position pos)
 {
     if (pos == null) return "     "; else return String.Format("{0,5}", pos.beg);
 }
Beispiel #3
0
 void CopySourcePart(Position pos, int indent)
 {
     // Copy text described by pos from atg to gen
     int ch, nChars, i;
     if (pos != null) {
     buffer.Pos = pos.beg; ch = buffer.Read(); nChars = pos.len - 1;
     Indent(indent);
     while (nChars >= 0) {
         while (ch == CR || ch == LF) {  // eol is either CR or CRLF or LF
             gen.WriteLine(); Indent(indent);
             if (ch == CR) { ch = buffer.Read(); nChars--; }  // skip CR
             if (ch == LF) { ch = buffer.Read(); nChars--; }  // skip LF
             for (i = 1; i <= pos.col && (ch == ' ' || ch == '\t'); i++) {
                 // skip blanks at beginning of line
                 ch = buffer.Read(); nChars--;
             }
             if (i <= pos.col) pos.col = i - 1; // heading TABs => not enough blanks
             if (nChars < 0) goto done;
         }
         gen.Write((char)ch);
         ch = buffer.Read(); nChars--;
     }
     done:
     if (indent > 0) gen.WriteLine();
     }
 }