========== CSplit: Version 2.0 ==========
========== CSplit: Begin part 12/16 ==========
}
// Some action processors may need to do some extra processing
// based on the state of the FSM after the file is processed.
processActions (END_OF_FILE);
return 0;
}
========== CSplit: End file CMTPARSR.CPP ==========
========== CSplit: Begin file CMTREMOV.CPP ==========
/*
* CMTREMOV.CPP
* Implementation of comment remover.
*
* ver 1.0, 30 Jun 1996
*
* ver 1.1, 28 Mar 1997
* Some method names changed.
*
* Public domain by:
* Jari Laaksonen
* Arkkitehdinkatu 30 A 2
* FIN-33720 Tampere
* FINLAND
*
* Fidonet : 2:221/360.20
* Internet: jla@to.icl.fi
*/
#include "cmtremov.h"
void CommentRemover::processActions (Event theEvent)
{
int rc = 1;
static int backsl = 0;
static int nl = 0;
switch (itsState)
{
case NormalInput:
if (theEvent == FOUND_SLASH)
{
rc = 0; // Don't print it yet...
}
break;
case BeginComment:
switch (theEvent)
{
case FOUND_BACKSLASH: // Escaped character.
backsl = 1;
case FOUND_SLASH: // Yes, it's a C++ comment...
case FOUND_STAR: // Yes, it's a C-style comment.
rc = 0;
break;
default: // No, just a slash...
print ('/'); // Print the previous slash.
if (backsl)
{
print ('\\'); // Print the previous backslash.
backsl = 0;
}
if (nl)
{
print ('\n'); // Print the previous newline.
nl = 0;
}
break;
}
break;
case InsideEscape:
switch (itsPrevState)
{
case InCppComment:
case InCComment:
case StarInCppComment:
case StarInCComment:
rc = 0;
break;
case BeginComment:
if (theEvent == FOUND_NL)
{
rc = 0; // Don't print it yet...
nl = 1;
}
break;
}
break;
case InCppComment:
case InCComment:
case StarInCppComment:
case StarInCComment:
rc = 0;
break;
}
if (! nl && theEvent == FOUND_NL)
{
rc = 1;
}
if (rc)
printChar();
}
int main (int argc, char **argv)
{
CommentRemover obj;
if (0 == obj.init (argc, argv))
{
fprintf (stderr, "USAGE: CMTREMOV InFile [OutFile]\n");
}
else
{
obj.run();
obj.unInit();
fprintf (stderr, "\nOK! %lu lines processed. Last state = %d\n",
obj.getLines(), obj.getLastState()
);
}
return 0;
}
========== CSplit: End file CMTREMOV.CPP ==========
========== CSplit: Begin file CMTXTRAC.CPP ==========
/*
* CMTXTRAC.CPP
* Implementation of comment extractor.
*
* ver 1.0, 30 Jun 1996
*
* ver 1.1, 28 Mar 1997
* bug: did not mark end of C++ comment after NL in state \
\
StarInCppComment.
* Some method names changed.
*
* Public domain by:
* Jari Laaksonen
* Arkkitehdinkatu 30 A 2
========== CSplit: End part 12/16 crc: bfdd ==========
// Albert email: jla@to.icl.fi
--- GoldED/2 2.50+
---------------
* Origin: Albert's Point/2 in Finland, Europe (2:221/360.20)
|