private ExprCfg parseSimpleTerm(){
  int ch=read();
  ch=skipWhitespace(ch);
switch (ch) {
case '.':
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
{
      long value=0;
      double exp=1;
      int digits=0;
      for (; ch >= '0' && ch <= '9'; ch=read())       value=10 * value + ch - '0';
      if (ch != '.' && ch != 'e' && ch != 'E') {
        unread();
        return new ExprCfgLong(value);
      }
      if (ch == '.') {
        for (ch=read(); ch >= '0' && ch <= '9'; ch=read()) {
          value=10 * value + ch - '0';
          exp*=10;
          digits--;
        }
      }
      if (ch == 'e' || ch == 'E') {
        int sign=1;
        int expValue=0;
        ch=read();
        if (ch == '-') {
          sign=-1;
          ch=read();
        }
 else         if (ch == '+')         ch=read();
        for (; ch >= '0' && ch <= '9'; ch=read())         expValue=10 * expValue + ch - '0';
        exp=Math.pow(10,digits + sign * expValue);
        unread();
        return new ExprCfgDouble((double)value * (double)exp);
      }
      unread();
      return new ExprCfgDouble((double)value / (double)exp);
    }
case '+':
{
    return parseTerm();
  }
case '(':
{
  int index=_index;
  ch=skipWhitespace(read());
  _index=index;
  ExprCfg expr=parseExpr();
  ch=skipWhitespace(read());
  if (ch != ')') {
    throw error(L.l("Expected `)' at {0}.  All open parentheses must have matching closing parentheses.",badChar(ch)));
  }
  return expr;
}
case '\'':
case '"':
{
int end=ch;
CharBuffer cb=_cb;
cb.clear();
for (ch=read(); ch >= 0; ch=read()) {
  if (ch == '\\')   cb.append((char)read());
 else   if (ch != end)   cb.append((char)ch);
 else   if ((ch=read()) == end)   cb.append((char)ch);
 else {
    unread();
    break;
  }
}
return new ExprCfgString(cb.toString());
}
default :
if (!Character.isJavaIdentifierStart((char)ch) && ch != ':') {
throw error(L.l("Unexpected character at {0}.",badChar(ch)));
}
CharBuffer cb=_cb;
cb.clear();
for (; Character.isJavaIdentifierPart((char)ch) || ch == ':'; ch=read()) cb.append((char)ch);
unread();
if (cb.charAt(cb.length() - 1) == ':') {
unread();
cb.deleteCharAt(cb.length() - 1);
}
String name=cb.toString();
return new ExprCfgId(name);
}
}

private ExprCfg parseSimpleTerm ( ) { int ch = read ( ) ; ch = skipWhitespace ( ch ) ; switch ( ch ) { case '.' : case '0' : case '1' : case '2' : case '3' : case '4' : case '5' : case '6' : case '7' : case '8' : case '9' : { long value = 0 ; double exp = 1 ; int digits = 0 ; for ( ; ch >= '0' && ch <= '9' ; ch = read ( ) ) value = 10 * value + ch - '0' ; if ( ch != '.' && ch != 'e' && ch != 'E' ) { unread ( ) ; return new ExprCfgLong ( value ) ; } if ( ch == '.' ) { for ( ch = read ( ) ; ch >= '0' && ch <= '9' ; ch = read ( ) ) { value = 10 * value + ch - '0' ; exp *= 10 ; digits -- ; } } if ( ch == 'e' || ch == 'E' ) { int sign = 1 ; int expValue = 0 ; ch = read ( ) ; if ( ch == '-' ) { sign = - 1 ; ch = read ( ) ; } else if ( ch == '+' ) ch = read ( ) ; for ( ; ch >= '0' && ch <= '9' ; ch = read ( ) ) expValue = 10 * expValue + ch - '0' ; exp = Math . pow ( 10 , digits + sign * expValue ) ; unread ( ) ; return new ExprCfgDouble ( ( double ) value * ( double ) exp ) ; } unread ( ) ; return new ExprCfgDouble ( ( double ) value / ( double ) exp ) ; } case '+' : { return parseTerm ( ) ; } case '(' : { int index = _index ; ch = skipWhitespace ( read ( ) ) ; _index = index ; ExprCfg expr = parseExpr ( ) ; ch = skipWhitespace ( read ( ) ) ; if ( ch != ')' ) { throw error ( L . l ( "Expected `)' at {0}.  All open parentheses must have matching closing parentheses." , badChar ( ch ) ) ) ; } return expr ; } case '\'' : case '"' : { int end = ch ; CharBuffer cb = _cb ; cb . clear ( ) ; for ( ch = read ( ) ; ch >= 0 ; ch = read ( ) ) { if ( ch == '\\' ) cb . append ( ( char ) read ( ) ) ; else if ( ch != end ) cb . append ( ( char ) ch ) ; else if ( ( ch = read ( ) ) == end ) cb . append ( ( char ) ch ) ; else { unread ( ) ; break ; } } return new ExprCfgString ( cb . toString ( ) ) ; } default : if ( ! Character . isJavaIdentifierStart ( ( char ) ch ) && ch != ':' ) { throw error ( L . l ( "Unexpected character at {0}." , badChar ( ch ) ) ) ; } CharBuffer cb = _cb ; cb . clear ( ) ; for ( ; Character . isJavaIdentifierPart ( ( char ) ch ) || ch == ':' ; ch = read ( ) ) cb . append ( ( char ) ch ) ; unread ( ) ; if ( cb . charAt ( cb . length ( ) - 1 ) == ':' ) { unread ( ) ; cb . deleteCharAt ( cb . length ( ) - 1 ) ; } String name = cb . toString ( ) ; return new ExprCfgId ( name ) ; } }
simple - term : : = number : : = ' ( ' expr ' ) ' : : = variable : : = ' " ' string ' " ' : : = true | false | null
