¿¹Á¦

public interface ICommonParsingConstants {
public static final int IF_TOKEN = 1;
public static final int WHILE_TOKEN = 2;
public static final String END_OF_LINE = "\n"; //$NON-NLS-1$
}

public class Parser implements ICommonParsingConstants {
public void processToken( int iToken ) {
if ( iToken == IF_TOKEN ) {
System.out.println( "if" ); //$NON-NLS-1$
} else if ( iToken == WHILE_TOKEN ) {
System.out.println( "while" ); //$NON-NLS-1$
}
}
}

public class Tokenizer implements ICommonParsingConstants {
public String getToken( String str ) {
return ( END_OF_LINE.equals( str ) ? "" : str ); //$NON-NLS-1$
}
}

¼Ö·ç¼Ç
  1. °¢ »ó¼ö¸¦ ÀÎÅÍÆäÀ̽º ¶Ç´Â ÇØ´ç »ó¼ö°¡ ³í¸®ÀûÀ¸·Î ¼ÓÇϴ Ŭ·¡½º·Î À̵¿ÇϽʽÿÀ.
  2. ºñ¾î ÀÖ´Â ÀÎÅÍÆäÀ̽º¸¦ Á¦°ÅÇϽʽÿÀ.

public class Parser {

public static final int IF_TOKEN = 1;
public static final int WHILE_TOKEN = 2;

public void processToken( int iToken ) {
if ( iToken == IF_TOKEN ) {
System.out.println( "if" ); //$NON-NLS-1$
} else if ( iToken == WHILE_TOKEN ) {
System.out.println( "while" ); //$NON-NLS-1$
}
}
}

public class Tokenizer {
public static final String END_OF_LINE = "\n"; //$NON-NLS-1$

public String getToken( String str ) {
return ( END_OF_LINE.equals( str ) ? "" : str ); //$NON-NLS-1$
}
}