MyC.Io.commentBegin C# (CSharp) Method

commentBegin() public method

public commentBegin ( String s ) : void
s String
return void
public void commentBegin(String s)
  {
  String b;
  if (s == null)		// make sure we have something
    return;
  b = buf.ToString();		// have to convert first
  int i = b.IndexOf(s);		// find this token in buffer
  if (i < 0)
    i = b.Length;		// if not found, use whole string
  buf = new StringBuilder(b.Substring(i), MyC.MAXSTR); // remake buffer from substr
  /*
   * need to update curline to be in synch with last emitted comment
   */
  curline = bufline;
  for (int ci = 0; ci < buf.Length; ci++)
    if (buf[ci] == '\n')
      curline--;
#if DEBUG
  Console.Write("commentBegin S=["+s+"], buf=");
  for (int _debug_i=0; _debug_i<buf.Length;_debug_i++)
    {
    int _debug_d = buf[_debug_i];
    char _debug_c = (char) (_debug_d + 96);
    if (_debug_d < 32)
      Console.Write("^"+_debug_c);
    else
      Console.Write(buf[_debug_i]);
    Console.Write("[");
    Console.Write(_debug_d);
    Console.Write("],");
    }
  Console.WriteLine(";");
#endif
  }

Usage Example

 void CommentToken()
 {
     io.commentBegin(tok.getValue());                    /* mark the begin of source comment */
     emit.CommentHolder();
     emit.CommentFill(io.commentEndTok(tok.getValue())); /* copy and emit comment */
 }