========== CSplit: Version 2.0 ==========
========== CSplit: Begin part 6/11 ==========
case CPState.StarInCppComment:
switch (theEvent)
{
case CPEvent.FOUND_STAR:
// another '*' -- don't change state.
itsState = CPState.StarInCppComment;
break;
case CPEvent.FOUND_CR:
case CPEvent.FOUND_NL:
// Newline is end of C++ comment.
itsState = CPState.NormalInput;
break;
default:
itsState = CPState.InCppComment;
break;
}
break;
// We are inside a C comment, and there is a '*';
// maybe this is the end of the comment...
case CPState.StarInCComment:
switch (theEvent)
{
case CPEvent.FOUND_STAR:
// another '*' -- don't change state.
itsState = CPState.StarInCComment;
break;
case CPEvent.FOUND_SLASH:
// Yes, it's end of the C comment.
itsState = CPState.NormalInput;
break;
default:
// No, we are still in C comment.
itsState = CPState.InCComment;
break;
}
break;
}
}
//==================================================================
/**
* Read character from input file.
* @return read character.
*/
private int readChar()
{
int ch;
try
{
ch = InFile.read();
// BugBug: this assumes that input files contain
// 0x0D0A, not just 0x0D.
// TODO: implement own input buffer to emulate
// DOSish text mode read.
if (ch == '\r')
{
ch = InFile.read();
}
ReadCh = ch;
}
catch (IOException e)
{
System.err.println (e.toString());
ReadCh = EOF;
}
return ReadCh;
}
//==================================================================
/**
* Selects the next event according to the read character.
* Increments the number of read lines.
* @see CPEvent#getEvent
* @return the value of event.
*/
private int getEvent()
{
int theEvent = CPEvent.getEvent(ReadCh);
if (ReadCh == '\n')
{
// count processed lines, if someone needs it...
lines++;
}
return theEvent;
}
}
========== CSplit: End file CommentParser.java ==========
========== CSplit: Begin file Converter.java ==========
/**
* Converter.java
* Implementation of comment converter.
*
* ver 1.0, 23 Mar 1997
*
* Public domain by:
* Jari Laaksonen
* Arkkitehdinkatu 30 A 2
* FIN-33720 Tampere
* FINLAND
*
* Fidonet : 2:221/360.20
* Internet: jla@to.icl.fi
*/
class CommentConverter extends CommentParser
{
//==================================================================
/**
* Action processor.
*/
protected void processActions (int theEvent)
{
switch (itsState)
{
case CPState.BeginComment:
// Yes, it's a C++ comment...
if (theEvent == CPEvent.FOUND_SLASH)
{
changeChar ('*'); // ...change to C-style.
}
break;
case CPState.InCppComment:
switch (theEvent)
{
// EOF: if we are still in C++ comment...
case CPEvent.END_OF_FILE:
case CPEvent.FOUND_NL: // End of C++ comment...
print (" */"); // ...put ending C-comment mark.
break;
}
break;
case CPState.StarInCppComment:
switch (theEvent)
{
// End of C comment -- add space to prevent nested C comment.
// For example: "// /*comment*/"
========== CSplit: End part 6/11 crc: 26fc ==========
// Albert email: jla@to.icl.fi
--- GoldED/2 2.50+
---------------
* Origin: Albert's Point/2 in Finland, Europe (2:221/360.20)
|