} /** * optionstmt -> 'option' ID '{' optionlist '}' */ private OptionFormat optionStmt() throws ParserException, IOException { match(OPTION); String optionName=lookahead.sval; matchID(); match(OPENBLOCK); OptionFormat of = new OptionFormat(optionName); optionList(of); match(CLOSEBLOCK); return of; } /** * parse the specification for the given option identifier */ public OptionFormat parse(String option) 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. */ while (lookahead.ttype != StreamTokenizer.TT_EOF) { // look for the start symbol if ((lookahead.ttype != StreamTokenizer.TT_WORD) || (lookahead.sval.compareTo(START) != 0)) { // skip tokens until a start symbol is found nextToken(); continue; } // check if the option name is the one we are interested in match(START); if ((lookahead.ttype == StreamTokenizer.TT_WORD) && (lookahead.sval.compareTo(option) == 0)) { // 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; } public Set<OptionFormat> parseOptions() throws ParserException, IOException { Set<OptionFormat> options = new HashSet<OptionFormat>(); nextToken(); while (lookahead.ttype != StreamTokenizer.TT_EOF) { // look for the start symbol if ((lookahead.ttype != StreamTokenizer.TT_WORD) || (lookahead.sval.compareTo(START) != 0)) { // 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. OptionFormat of = optionStmt(); options.add(of); } return options; } OptionFormat getOptionFormat() { return optionFormat; } private void log(boolean logging, String s) { if (logging) { System.out.println(s); } }}Lines 501–585 of 585. Previous lines
} /** * optionstmt -> 'option' ID '{' optionlist '}' */ private OptionFormat optionStmt() throws ParserException, IOException { match(OPTION); String optionName=lookahead.sval; matchID(); match(OPENBLOCK); OptionFormat of = new OptionFormat(optionName); optionList(of); match(CLOSEBLOCK); return of; } /** * parse the specification for the given option identifier */ public OptionFormat parse(String option) 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. */ while (lookahead.ttype != StreamTokenizer.TT_EOF) { // look for the start symbol if ((lookahead.ttype != StreamTokenizer.TT_WORD) || (lookahead.sval.compareTo(START) != 0)) { // skip tokens until a start symbol is found nextToken(); continue; } // check if the option name is the one we are interested in match(START); if ((lookahead.ttype == StreamTokenizer.TT_WORD) && (lookahead.sval.compareTo(option) == 0)) { // 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; } public Set<OptionFormat> parseOptions() throws ParserException, IOException { Set<OptionFormat> options = new HashSet<OptionFormat>(); nextToken(); while (lookahead.ttype != StreamTokenizer.TT_EOF) { // look for the start symbol if ((lookahead.ttype != StreamTokenizer.TT_WORD) || (lookahead.sval.compareTo(START) != 0)) { // 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. OptionFormat of = optionStmt(); options.add(of); } return options; } OptionFormat getOptionFormat() { return optionFormat; } private void log(boolean logging, String s) { if (logging) { System.out.println(s); } } }