h77!
Newbie
Joined: 03/25/2006 10:50:09
Messages: 1
Offline
|
Hi, Guys..
how are you?. I'm bigenners in java lang so i'm registering here to become java expert like u. i want to{ build scanner based on RE .Show your DFA's code and run}.I have the algorithm which may be help us in this program .
/********************************************************/
stete = initial_state;
current_character = get_next_character ();
while ( true )
{ next_state = T[state,current_character];
if (next_state = T[state,current_character];
if(next_state == ERROR)
break;
state = next_state;
current_character = get_next_character();
if (is_final_state(state) )
'we have a valid token'
else 'report an error'
// this algorithm does not take into account the longest match disambiguation rule since it ends at EOF
/********************************************************/
//The following algorithm is more general since it does not expect EOF at
the end of token but still uses longest match disambiguation rule.
stete = initial_state;
final_state = ERROR;
current_character = get_next_character ();
while ( true )
{ next_state = T[state,current_character];
if (next_state = T[state,current_character];
if(next_state == ERROR)
break;
state = next_state;
if ( is_final_state(state(state) )
final_state = state;
if( current_character == EOF )
break;
};
if (final_state == ERROR )
'report an error'
else if ( state != final_state )
'we have a valid token but we need to backtrack
(to put characters back into the stream) '
else 'we have a valid token'
/********************************************************/
I needs your activaty in my request ....please
Thanks so much
|