/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
* A class implementing a simple predictive parser for output format
* specification language for the jstat command.
*
* @author Brian Doherty
* @since 1.5
*/
public class Parser {
};
private static char[] infixOps = {
};
private static char[] delimiters = {
};
private int columnCount;
}
st = new StreamTokenizer(r);
// allow both c++ style comments
st.slashSlashComments(true);
st.slashStarComments(true);
}
}
}
}
/**
* push back the lookahead token and restore the lookahead token
* to the previous token.
*/
private void pushBack() {
}
/**
* retrieve the next token, placing the token value in the lookahead
* member variable, storing its previous value in the previous member
* variable.
*/
}
/**
* match one of the token values in the given set of key words
* token is assumed to be of type TT_WORD, and the set is assumed
* to contain String objects.
*/
nextToken();
return t;
}
}
/**
* match a token with TT_TYPE=type, and the token value is a given sequence
* of characters.
*/
throws ParserException, IOException {
nextToken();
} else {
}
}
/**
* match a token with TT_TYPE=type
*/
nextToken();
} else {
}
}
/**
* match a token with TT_TYPE=char, where the token value is the given char.
*/
nextToken();
}
else {
}
}
/**
* match a token with TT_TYPE='"', where the token value is a sequence
* of characters between matching quote characters.
*/
}
/**
* match a TT_NUMBER token that matches a parsed number value
*/
}
/**
* match a TT_WORD token that matches an arbitrary, not quoted token.
*/
}
/**
* match a TT_WORD token that matches the given string
*/
}
/**
* determine if the given word is a reserved key word
*/
}
/**
* determine if the give work is a reserved key word
*/
return true;
}
}
return false;
}
/**
* scalestmt -> 'scale' scalespec
* scalespec -> <see above scaleTerminals array>
*/
throws ParserException, IOException {
}
/**
* alignstmt -> 'align' alignspec
* alignspec -> <see above alignTerminals array>
*/
throws ParserException, IOException {
}
/**
* headerstmt -> 'header' quotedstring
*/
throws ParserException, IOException {
}
/**
* widthstmt -> 'width' integer
*/
throws ParserException, IOException {
matchNumber();
}
/**
* formatstmt -> 'format' quotedstring
*/
throws ParserException, IOException {
}
/**
* Primary -> Literal | Identifier | '(' Expression ')'
*/
Expression e = null;
case OPENPAREN:
e = expression();
break;
case StreamTokenizer.TT_WORD:
if (isReservedWord(s)) {
}
matchID();
e = new Identifier(s);
break;
case StreamTokenizer.TT_NUMBER:
matchNumber();
break;
default:
}
return e;
}
/**
* Unary -> ('+'|'-') Unary | Primary
*/
Expression e = null;
while (true) {
case OPERATOR_PLUS:
break;
case OPERATOR_MINUS:
break;
default:
e = primary();
return e;
}
e = e1;
}
}
/**
* MultExpression -> Unary (('*' | '/') Unary)*
*/
Expression e = unary();
while (true) {
case OPERATOR_MULTIPLY:
break;
case OPERATOR_DIVIDE:
break;
default:
return e;
}
e = e1;
}
}
/**
* AddExpression -> MultExpression (('+' | '-') MultExpression)*
*/
Expression e = multExpression();
while (true) {
case OPERATOR_PLUS:
break;
case OPERATOR_MINUS:
break;
default:
return e;
}
e = e1;
}
}
/**
* Expression -> AddExpression
*/
Expression e = addExpression();
return e;
}
/**
* datastmt -> 'data' expression
*/
Expression e = expression();
cf.setExpression(e);
}
/**
* statementlist -> optionalstmt statementlist
* optionalstmt -> 'data' expression
* 'header' quotedstring
* 'width' integer
* 'format' formatstring
* 'align' alignspec
* 'scale' scalespec
*/
throws ParserException, IOException {
while (true) {
return;
}
headerStmt(cf);
formatStmt(cf);
} else {
return;
}
}
}
/**
* optionlist -> columspec optionlist
* null
* columspec -> 'column' '{' statementlist '}'
*/
throws ParserException, IOException {
while (true) {
return;
}
}
}
/**
* optionstmt -> 'option' ID '{' optionlist '}'
*/
matchID();
optionList(of);
return of;
}
/**
* parse the specification for the given option identifier
*/
throws ParserException, IOException {
nextToken();
/*
* this search stops on the first occurance of an option
* statement with a name matching the given option. Any
* duplicate options are ignored.
*/
// look for the start symbol
// skip tokens until a start symbol is found
nextToken();
continue;
}
// check if the option name is the one we are interested in
// this is the one we are looking for, parse it
pushBack();
return optionStmt();
} else {
// not what we are looking for, start skipping tokens
nextToken();
}
}
return null;
}
nextToken();
// look for the start symbol
// skip tokens until a start symbol is found
nextToken();
continue;
}
// note: if a duplicate option statement exists, then
// first one encountered is the chosen definition.
}
return options;
}
return optionFormat;
}
if (logging) {
}
}
}