| LLOOP Index | GSP Language | GSP Library | Framework Classes | Component Classes |
This is the verbatim text of the file "c_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 c_comment
{{
static bool bInComment = false;
static char cPrev = 0;
if (bInComment)
{
if ((cPrev == '*') && (c == '/'))
{
bInComment = false;
discard();
}
else if (c != '\n') // Keep the new lines for the line count
{
discard();
}
}
else if ( (cPrev == '/') && (c == '*') ) // Comment detected
{
/* The previous char is a slash and the current is a star.
* This means a C comment start is detected.
* The / char has actually already been accepted in the previous step.
* It is cancelled by moving back of one char in the pre-processed stream
* using the parser.pstream().seekp(-1,ios::cur)
* Note that parser.pstream() returns the pre-processed stream.
*/
bInComment = true;
parser.pstream().seekp(-1,ios::cur); // Remove the '/' read before
discard();
}
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 |