int terminal(int[] flags) throws RESyntaxException {
switch (pattern.charAt(idx)) {
case RE.OP_EOL:
case RE.OP_BOL:
case RE.OP_ANY:
    return node(pattern.charAt(idx++),0);
case '[':
  return characterClass();
case '(':
return expr(flags);
case ')':
syntaxError("Unexpected close paren");
case '|':
internalError();
case ']':
syntaxError("Mismatched class");
case 0:
syntaxError("Unexpected end of input");
case '?':
case '+':
case '{':
case '*':
syntaxError("Missing operand to closure");
case '\\':
{
int idxBeforeEscape=idx;
switch (escape()) {
case ESC_CLASS:
case ESC_COMPLEX:
flags[0]&=~NODE_NULLABLE;
return node(RE.OP_ESCAPE,pattern.charAt(idx - 1));
case ESC_BACKREF:
{
char backreference=(char)(pattern.charAt(idx - 1) - '0');
if (parens <= backreference) {
syntaxError("Bad backreference");
}
flags[0]|=NODE_NULLABLE;
return node(RE.OP_BACKREF,backreference);
}
default :
idx=idxBeforeEscape;
flags[0]&=~NODE_NULLABLE;
break;
}
}
}
flags[0]&=~NODE_NULLABLE;
return atom();
}

int terminal ( int [ ] flags ) throws RESyntaxException { switch ( pattern . charAt ( idx ) ) { case RE . OP_EOL : case RE . OP_BOL : case RE . OP_ANY : return node ( pattern . charAt ( idx ++ ) , 0 ) ; case '[' : return characterClass ( ) ; case '(' : return expr ( flags ) ; case ')' : syntaxError ( "Unexpected close paren" ) ; case '|' : internalError ( ) ; case ']' : syntaxError ( "Mismatched class" ) ; case 0 : syntaxError ( "Unexpected end of input" ) ; case '?' : case '+' : case '{' : case '*' : syntaxError ( "Missing operand to closure" ) ; case '\\' : { int idxBeforeEscape = idx ; switch ( escape ( ) ) { case ESC_CLASS : case ESC_COMPLEX : flags [ 0 ] &= ~ NODE_NULLABLE ; return node ( RE . OP_ESCAPE , pattern . charAt ( idx - 1 ) ) ; case ESC_BACKREF : { char backreference = ( char ) ( pattern . charAt ( idx - 1 ) - '0' ) ; if ( parens <= backreference ) { syntaxError ( "Bad backreference" ) ; } flags [ 0 ] |= NODE_NULLABLE ; return node ( RE . OP_BACKREF , backreference ) ; } default : idx = idxBeforeEscape ; flags [ 0 ] &= ~ NODE_NULLABLE ; break ; } } } flags [ 0 ] &= ~ NODE_NULLABLE ; return atom ( ) ; }
match a terminal node .
