FormattingNode SINGLE() throws ScanException { // System.out.println("in SINGLE()"); Token t = getNextToken(); // System.out.println("==" + t); SimpleKeywordNode keywordNode = new SimpleKeywordNode(t.getValue()); Token ot = getCurentToken(); if (ot != null && ot.getType() == Token.OPTION) { List<String> optionList = (List<String>) ot.getValue(); keywordNode.setOptions(optionList); advanceTokenPointer(); } return keywordNode; }
FormattingNode COMPOSITE(String keyword) throws ScanException { CompositeNode compositeNode = new CompositeNode(keyword); Node childNode = E(); compositeNode.setChildNode(childNode); Token t = getNextToken(); if (t == null || t.getType() != Token.RIGHT_PARENTHESIS) { String msg = "Expecting RIGHT_PARENTHESIS token but got " + t; addError(msg); addError("See also "+MISSING_RIGHT_PARENTHESIS); throw new ScanException(msg); } Token ot = getCurentToken(); if (ot != null && ot.getType() == Token.OPTION) { List<String> optionList = (List<String>) ot.getValue(); compositeNode.setOptions(optionList); advanceTokenPointer(); } return compositeNode; }
FormattingNode C() throws ScanException { Token t = getCurentToken(); // System.out.println("in C()"); // System.out.println("Current token is " + t); expectNotNull(t, "a LEFT_PARENTHESIS or KEYWORD"); int type = t.getType(); switch (type) { case Token.SIMPLE_KEYWORD: return SINGLE(); case Token.COMPOSITE_KEYWORD: advanceTokenPointer(); return COMPOSITE(t.getValue().toString()); default: throw new IllegalStateException("Unexpected token " + t); } }
/** * When the parsing step is done, the Node list can be transformed into a * converter chain. * * @param top * @param converterMap * @return * @throws ScanException */ public Converter<E> compile(final Node top, Map converterMap) { Compiler<E> compiler = new Compiler<E>(top, converterMap); compiler.setContext(context); //compiler.setStatusManager(statusManager); return compiler.compile(); }
Node Eopt() throws ScanException { // System.out.println("in Eopt()"); Token next = getCurentToken(); // System.out.println("Current token is " + next); if (next == null) { return null; } else { return E(); } }
private void processOption(char c, List<Token> tokenList, StringBuffer buf) throws ScanException { OptionTokenizer ot = new OptionTokenizer(this); ot.tokenize(c, tokenList); }
public Parser(String pattern, IEscapeUtil escapeUtil) throws ScanException { try { TokenStream ts = new TokenStream(pattern, escapeUtil); this.tokenList = ts.tokenize(); } catch (IllegalArgumentException npe) { throw new ScanException("Failed to initialize Parser", npe); } }
Parser(TokenStream ts) throws ScanException { this.tokenList = ts.tokenize(); }
public boolean equals(Object o) { if (this == o) { return true; } if (!(o instanceof Node)) { return false; } Node r = (Node) o; return (type == r.type) && (value != null ? value.equals(r.value) : r.value == null) && (next != null ? next.equals(r.next) : r.next == null); }
void emitOptionToken( List<Token> tokenList, List<String> optionList) { tokenList.add(new Token(Token.OPTION, optionList)); tokenStream.state = TokenizerState.LITERAL_STATE; }
public Node parse() throws ScanException { return E(); }
public boolean equals(Object o) { if (!super.equals(o)) { return false; } if (!(o instanceof SimpleKeywordNode)) { return false; } SimpleKeywordNode r = (SimpleKeywordNode) o; return (optionList != null ? optionList.equals(r.optionList) : r.optionList == null); }
public String toString() { StringBuilder buf = new StringBuilder(); if(childNode != null) { buf.append("CompositeNode("+childNode+")"); } else { buf.append("CompositeNode(no child)"); } buf.append(printNext()); return buf.toString(); } }
public String toString() { StringBuilder buf = new StringBuilder(); if (optionList == null) { buf.append("KeyWord(" + value + "," + formatInfo + ")"); } else { buf.append("KeyWord(" + value + ", " + formatInfo + "," + optionList + ")"); } buf.append(printNext()); return buf.toString(); } }
@Override public int hashCode() { return super.hashCode(); }
@Override public int hashCode() { return super.hashCode(); }
@Override public int hashCode() { int result = super.hashCode(); result = 31 * result + (formatInfo != null ? formatInfo.hashCode() : 0); return result; } }
public boolean equals(Object o) { if (!super.equals(o)) { return false; } if(!(o instanceof FormattingNode)) { return false; } FormattingNode r = (FormattingNode) o; return (formatInfo != null ? formatInfo.equals(r.formatInfo) : r.formatInfo == null); }