Java Reference
In-Depth Information
1
/**
2
* Get the next opening or closing symbol.
3
* Return false if end of file.
4
* Skip past comments and character and string constants
5
*/
6
public char getNextOpenClose( )
7
{
8
while( nextChar( ) )
9
{
10
if( ch == '/' )
11
processSlash( );
12
else if( ch == '\'' || ch == '”' )
13
skipQuote( ch );
14
else if( ch == '(' || ch == '[' || ch == '{' ||
15
ch == ')' || ch == ']' || ch == '}' )
16
return ch;
17
}
18
return '\0'; // End of file
19
}
20
21
/**
22
* After the opening slash is seen deal with next character.
23
* If it is a comment starter, process it; otherwise putback
24
* the next character if it is not a newline.
25
*/
26
private void processSlash( )
27
{
28
if( nextChar( ) )
29
{
30
if( ch == '*' )
31
{
32
// Javadoc comment
33
if( nextChar( ) && ch != '*' )
34
putBackChar( );
35
skipComment( SLASH_STAR );
36
}
37
else if( ch == '/' )
38
skipComment( SLASH_SLASH );
39
else if( ch != '\n' )
40
putBackChar( );
41
}
42
}
figure 11.7
The
getNextOpenClose
routine for skipping
comments and quotes
and returning the next
opening or closing
character, along with
the
processSlash
routine
Search WWH ::
Custom Search