void emitOptionToken( List<Token> tokenList, List<String> optionList) { tokenList.add(new Token(Token.OPTION, optionList)); tokenStream.state = TokenizerState.LITERAL_STATE; }
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; }
@SuppressWarnings("unchecked") 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 = ot.getOptionsList(); keywordNode.setOptions(optionList); advanceTokenPointer(); } return keywordNode; }
FormattingNode COMPOSITE() throws ScanException { CompositeNode compositeNode = new CompositeNode(); Node childNode = E(); // System.out.println("Child node: " + childNode); compositeNode.setChildNode(childNode); Token t = getNextToken(); // System.out.println("Next token is" + t); if (t.getType() != Token.RIGHT_PARENTHESIS) { throw new IllegalStateException( "Expecting RIGHT_PARENTHESIS token but got " + t); } else { // System.out.println("got expected ')'"); } return compositeNode; }
@SuppressWarnings("unchecked") 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 = ot.getOptionsList(); 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.KEYWORD: return SINGLE(); case Token.LEFT_PARENTHESIS: advanceTokenPointer(); return COMPOSITE(); default: throw new IllegalStateException("Unexpected token " + t); } }
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); } }
private void addValuedToken(int type, StringBuffer buf, List<Token> tokenList) { if (buf.length() > 0) { tokenList.add(new Token(type, buf.toString())); buf.setLength(0); } } }
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; }
break; case KEYWORD_STATE: tokenList.add(new Token(Token.SIMPLE_KEYWORD, buf.toString())); break; case RIGHT_PARENTHESIS_STATE:
Node T() throws ScanException { Token t = getCurentToken(); expectNotNull(t, "a LITERAL or '%'"); switch (t.getType()) { case Token.LITERAL: advanceTokenPointer(); return new Node(Node.LITERAL, t.getValue()); case Token.PERCENT: advanceTokenPointer(); // System.out.println("% token found"); FormatInfo fi; Token u = getCurentToken(); FormattingNode c; expectNotNull(u, "a FORMAT_MODIFIER, SIMPLE_KEYWORD or COMPOUND_KEYWORD"); if (u.getType() == Token.FORMAT_MODIFIER) { fi = FormatInfo.valueOf((String) u.getValue()); advanceTokenPointer(); c = C(); c.setFormatInfo(fi); } else { c = C(); } return c; default: return null; } }
void emitOptionToken( List<Token> tokenList, List<String> optionList) { tokenList.add(new Token(Token.OPTION, optionList)); tokenStream.state = TokenizerState.LITERAL_STATE; }
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; }
void emitOptionToken( List<Token> tokenList, List<String> optionList) { tokenList.add(new Token(Token.OPTION, optionList)); tokenStream.state = TokenizerState.LITERAL_STATE; }
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; }
void emitOptionToken( List<Token> tokenList, List<String> optionList) { tokenList.add(new Token(Token.OPTION, optionList)); tokenStream.state = TokenizerState.LITERAL_STATE; }
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; }
void emitOptionToken( List<Token> tokenList, List<String> optionList) { tokenList.add(new Token(Token.OPTION, optionList)); tokenStream.state = TokenizerState.LITERAL_STATE; }
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; }
void emitOptionToken(List<Token> tokenList, List<String> optionList) { tokenList.add(new Token(Token.OPTION, optionList)); tokenStream.state = TokenizerState.LITERAL_STATE; }