static void NextCh() { if (oldEols > 0) { ch = EOL; oldEols--; } else { ch = (char)Buffer.Read(); pos++; // replace isolated '\r' by '\n' in order to make // eol handling uniform across Windows, Unix and Mac if (ch == '\r' && Buffer.Peek() != '\n') { ch = EOL; } else if (ch > '\u007f') { ch = '?'; } if (ch == EOL) { line++; lineStart = pos + 1; } } }
void CopySourcePart(Position pos, int indent) { // Copy text described by pos from atg to gen int ch, i; if (pos != null) { buffer.Pos = pos.beg; ch = buffer.Read(); if (tab.emitLines) { gen.WriteLine(); gen.WriteLine("#line {0} \"{1}\"", pos.line, tab.srcName); } Indent(indent); while (buffer.Pos <= pos.end) { while (ch == CR || ch == LF) { // eol is either CR or CRLF or LF gen.WriteLine(); Indent(indent); if (ch == CR) { ch = buffer.Read(); // skip CR } if (ch == LF) { ch = buffer.Read(); // skip LF } for (i = 1; i <= pos.col && (ch == ' ' || ch == '\t'); i++) { // skip blanks at beginning of line ch = buffer.Read(); } if (buffer.Pos > pos.end) { goto done; } } gen.Write((char)ch); ch = buffer.Read(); } done: if (indent > 0) { gen.WriteLine(); } } }
void CopySourcePart(Position pos, int indent) { // Copy text described by pos from atg to gen int ch, i; if (pos != null) { buffer.Pos = pos.beg; ch = buffer.Read(); Indent(indent); while (buffer.Pos <= pos.end) { while (ch == CR || ch == LF) // eol is either CR or CRLF or LF { gen.WriteLine(); Indent(indent); if (ch == CR) { ch = buffer.Read(); // skip CR } if (ch == LF) { ch = buffer.Read(); // skip LF } for (i = 1; i <= pos.col && (ch == ' ' || ch == '\t'); i++) { // skip blanks at beginning of line ch = buffer.Read(); } if (i <= pos.col) { pos.col = i - 1; // heading TABs => not enough blanks } if (buffer.Pos > pos.end) { goto done; } } gen.Write((char)ch); ch = buffer.Read(); } done: if (indent > 0) { gen.WriteLine(); } } }
static 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; // CHANGES BY M.KRUEGER (#line pragma generation) gen.WriteLine(); gen.WriteLine(String.Format("#line {0} \"{1}\" ", Buffer.CountLines(pos.beg) + 1, Buffer.fileName)); // EOC 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(); // skip CR nChars--; } if (ch == LF) { ch = Buffer.Read(); // skip LF nChars--; } for (i = 1; i <= pos.col && ch <= ' '; 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(); } } }
/* AW 2003-03-10 moved this from ParserGen.cs */ public static string GetString(int beg, int end) { StringBuilder s = new StringBuilder(64); int oldPos = Buffer.Pos; Buffer.Pos = beg; while (beg < end) { s.Append((char)Buffer.Read()); beg++; } Buffer.Pos = oldPos; return(s.ToString()); }
void NextCh() { if (oldEols > 0) { ch = EOL; oldEols--; } else { pos = buffer.Pos; ch = buffer.Read(); col++; // replace isolated '\r' by '\n' in order to make // eol handling uniform across Windows, Unix and Mac if (ch == '\r' && buffer.Peek() != '\n') { ch = EOL; } if (ch == EOL) { line++; col = 0; } } }
/// <summary> /// Buffer helper, scans the buffer for line starts /// </summary> /// <param name="buffer">Buffer of the atg file</param> public BufferHelper(Buffer buffer) { this.buffer = buffer; int oldPos = buffer.Pos; buffer.Pos = 0; int ch; linePosition.Add(buffer.Pos); while ((ch = buffer.Read()) != Buffer.EOF) { if (ch == '\r' && buffer.Peek() != '\n') { ch = '\n'; } if (ch == '\n') { linePosition.Add(buffer.Pos + 1); } } buffer.Pos = oldPos; }
void NextCh() { if (oldEols > 0) { ch = EOL; oldEols--; } else { pos = buffer.Pos; // buffer reads unicode chars, if UTF8 has been detected ch = buffer.Read(); col++; charPos++; // replace isolated '\r' by '\n' in order to make // eol handling uniform across Windows, Unix and Mac if (ch == '\r' && buffer.Peek() != '\n') { ch = EOL; } if (ch == EOL) { line++; col = 0; } } //if (pos <= 10) Console.Write("{0:X} ", ch); }