question: int atom ( ) throws RESyntaxException { int ret = node ( RE . OP_ATOM , 0 ) ; int lenAtom = 0 ; atomLoop : while ( idx < len ) { if ( ( idx + 1 ) < len ) { char c = pattern . charAt ( idx + 1 ) ; if ( pattern . charAt ( idx ) == '\\' ) { int idxEscape = idx ; escape ( ) ; if ( idx < len ) { c = pattern . charAt ( idx ) ; } idx = idxEscape ; } switch ( c ) { case '{' : case '?' : case '*' : case '+' : if ( lenAtom != 0 ) { break atomLoop ; } } } switch ( pattern . charAt ( idx ) ) { case ']' : case '^' : case '$' : case '.' : case '[' : case '(' : case ')' : case '|' : break atomLoop ; case '{' : case '?' : case '*' : case '+' : if ( lenAtom == 0 ) { syntaxError ( "Missing operand to closure" ) ; } break atomLoop ; case '\\' : { int idxBeforeEscape = idx ; int c = escape ( ) ; if ( ( c & ESC_MASK ) == ESC_MASK ) { idx = idxBeforeEscape ; break atomLoop ; } emit ( ( char ) c ) ; lenAtom ++ ; } break ; default : emit ( pattern . charAt ( idx ++ ) ) ; lenAtom ++ ; break ; } } if ( lenAtom == 0 ) { internalError ( ) ; } instruction [ ret + RE . offsetOpdata ] = ( char ) lenAtom ; return ret ; }
target:  Absorb an atomic character string.  This method is a little tricky because it can un-include the last character of string if a closure operator follows. This is correct because *+? have higher precedence than concatentation (thus ABC* means AB(C*) and NOT (ABC)*).