LLOOP Index | GSP Language | GSP Library | Framework Classes | Component Classes

cplusplus_comment.gsp

This is the verbatim text of the file "cplusplus_comment.gsp" part of the LLOOP package. The copyright remains with Michel MEHL. All rights reserved.



/**
 * Pre-processes C++ comments (//)
 * Strips the input of any C++ // comment,
 * but regardless of whether the comment is within quotes.
 */ 

preprocessor cplusplus_comment
{{
  static bool bInComment = false;
  static char cPrev = 0;
  static bool bDoubleQuoteSeen = false;

  if (bInComment)
    {
      if (c == '\n')
	bInComment = false; // Keep the new lines for the line count
      else
	discard();
    }
  else if ( (cPrev == '/') && (c == '/') )//&& !bDoubleQuoteSeen) // Comment detected
    {
      bInComment = true;
      parser.pstream().seekp(-1,ios::cur); // Remove the '/' read before
      discard();
    }

  if (cPrev != '\\') bDoubleQuoteSeen = (bDoubleQuoteSeen ^ (c == '\"'));

  cPrev =  c;
}}

This file is part of the LLOOP Reversible Object-Oriented Parser Generator. Copyright (c) 2005-2006 Michel MEHL, France. All rights reserved. LLOOP is distributed by the company ERSA SaRL.


Copyright (c) 2005-2006 Michel MEHL, Haguenau, France
LLOOP version 1.1