========== CSplit: Version 2.0 ==========
========== CSplit: Begin part 3/11 ==========
case StarInCComment: str = "StarInCComment"; break;
default: str = "** unknown state **"; break;
}
return str;
}
}
/**
* class CPEvent contains Event constants and one static method
* that maps given character to event.
*/
class CPEvent
{
/**
* Event constants.
*/
static final int ANY_CHAR = 0;
static final int FOUND_BACKSLASH = 1;
static final int FOUND_NL = 2;
static final int FOUND_QUOTE = 3;
static final int FOUND_SINGLEQUOTE = 4;
static final int FOUND_SLASH = 5;
static final int FOUND_STAR = 6;
static final int FOUND_WHITESPACE = 7;
static final int END_OF_FILE = 8;
static final int FOUND_CR = 9;
//==================================================================
/**
* Selects the next event according to the read character.
* @return the value of event.
*/
static public int getEvent (int ch)
{
int v;
switch (ch)
{
case ' ':
case '\t': v = FOUND_WHITESPACE; break;
case '\"': v = FOUND_QUOTE; break;
case '\'': v = FOUND_SINGLEQUOTE; break;
case '\\': v = FOUND_BACKSLASH; break;
case '\n':
case '\r': v = FOUND_NL; break;
case '/': v = FOUND_SLASH; break;
case '*': v = FOUND_STAR; break;
default: v = ANY_CHAR; break;
}
return v;
}
}
/**
* class CommentParser
*/
abstract class CommentParser
{
static final int EOF = -1;
protected int itsState = CPState.NormalInput;
protected int itsPrevState;
private long lines = 0;
private int bOutFile = 0;
private int ReadCh;
private InputStream InFile;
private OutputStream OutFile;
//==================================================================
/**
*
*/
public CommentParser (int InitState)
{
itsState = InitState;
}
//==================================================================
/**
*
*/
public CommentParser ()
{
}
//==================================================================
/**
* Initialization method which takes the program's command line
* arguments and opens the input file and optionally the output
* file.
* @return true if successful, false if failed or no arguments.
*/
public boolean init (int argc, String argv[])
{
if (argc < 1)
{
return false;
}
if (! init (argv[0], CPState.NormalInput))
{
return false;
}
if (argc == 2)
{
if (argv[0].equalsIgnoreCase (argv[1]))
{
// input and output files cannot be the same,
// output goes to stdout instead.
OutFile = System.out;
}
else
{
try
{
OutFile = new FileOutputStream (argv[1]);
bOutFile = 1;
}
catch (IOException e)
{
System.err.println (e.toString());
OutFile = System.out;
}
}
}
return true;
}
//==================================================================
/**
* Initialization method which opens the input file.
* Action processors that don't need output file can use this
* function.
* @return true if successful, false if failed or no arguments.
*/
public boolean init (String file, int InitState)
{
itsState = InitState;
OutFile = System.out;
========== CSplit: End part 3/11 crc: 0e46 ==========
// Albert email: jla@to.icl.fi
--- GoldED/2 2.50+
---------------
* Origin: Albert's Point/2 in Finland, Europe (2:221/360.20)
|