MyC.Io.commentEndTok C# (CSharp) Method

commentEndTok() public method

public commentEndTok ( String s ) : String
s String
return String
public String commentEndTok(String s)
  {
#if DEBUG
  Console.Write("commentEndTok1 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

  /*
   * variant to include this token at end of comment
   */
  String b;
  if (s == null)		// make sure we have something
    return null;
  b = buf.ToString();		// have to convert first
  int i = b.LastIndexOf(s);	// find this token in buffer
  String c = b.Substring(0,i+s.Length).Trim(); // copy as comment
  buf = new StringBuilder(b.Substring(i+s.Length), MyC.MAXSTR); // remake buffer
  /*
   * 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("commentEndTok2 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
  return c;
  }

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 */
 }