private Token getToken(int index) { Token t = tokenStream.LT(index); return t; }
private Token getToken(int index) { Token t = tokenStream.LT(index); return t; }
Token result = super.LT(k); if (k == 1 && result.getChannel()!=channel) {
private String parseNodeValue() throws XerialException { int nextToken = tokenStream.LA(1); switch (nextToken) { case At: // TODO throw new XerialException(XerialErrorCode.PARSE_ERROR, "nested function is not yet supported"); case PlainOneLine: case String: Token t = getToken(1); consume(); return t.getText(); default: throw unexpectedToken(tokenStream.LT(1), At, PlainOneLine, String); } }
private String parseNodeValue() throws XerialException { int nextToken = tokenStream.LA(1); switch (nextToken) { case At: // TODO throw new XerialException(XerialErrorCode.PARSE_ERROR, "nested function is not yet supported"); case PlainOneLine: case String: Token t = getToken(1); consume(); return t.getText(); default: throw unexpectedToken(tokenStream.LT(1), At, PlainOneLine, String); } }
private SilkFunction parseFunction() throws XerialException { SilkFunction func = new SilkFunction(); switch (tokenStream.LA(1)) { case NodeIndent: { Token t = getToken(1); func.setNodeIndent(t.getText()); consume(); parseFunctionInternal(func); return func; } case FunctionIndent: { Token t = getToken(1); // function indent func.setNodeIndent(t.getText()); consume(); Token funcName = testAndConsume(PlainOneLine); func.setName(funcName.getText().trim()); parseFunctionArgs(func); return func; } default: throw unexpectedToken(tokenStream.LT(1), NodeIndent, FunctionIndent); } }
private SilkFunction parseFunction() throws XerialException { SilkFunction func = new SilkFunction(); switch (tokenStream.LA(1)) { case NodeIndent: { Token t = getToken(1); func.setNodeIndent(t.getText()); consume(); parseFunctionInternal(func); return func; } case FunctionIndent: { Token t = getToken(1); // function indent func.setNodeIndent(t.getText()); consume(); Token funcName = testAndConsume(PlainOneLine); func.setName(funcName.getText().trim()); parseFunctionArgs(func); return func; } default: throw unexpectedToken(tokenStream.LT(1), NodeIndent, FunctionIndent); } }
public SilkElement parse() throws XerialException { switch (tokenStream.LA(1)) { case NodeIndent: if (tokenStream.LA(2) == At) return parseFunction(); else return parseSilkNode().build(); case BlockIndent: { SilkNodeBuilder node = parseSilkNode(); node.setOccurrence(SilkNodeOccurrence.SEQUENCE_PRESERVING_WHITESPACES); return node.build(); } case PullUpNodeIndent: { SilkNodeBuilder node = parseSilkNode(); node.setOccurrence(SilkNodeOccurrence.SEQUENCE_PRESERVING_WHITESPACES); return node.build(); } case FunctionIndent: { SilkFunction func = parseFunction(); return func; } default: throw unexpectedToken(tokenStream.LT(1), NodeIndent, FunctionIndent); } }
private void parseNodeValue(SilkNodeBuilder node) throws XerialException { int nextToken = tokenStream.LA(1); switch (nextToken) { case At: SilkFunction func = parseFunctionInternal(new SilkFunction()); node.setFunction(func); break; case PlainOneLine: case String: { Token t = getToken(1); consume(); node.setValue(t.getText()); break; } case JSON: { Token t = getToken(1); consume(); node.setJSON(t.getText()); break; } default: throw unexpectedToken(tokenStream.LT(1), At, PlainOneLine, String); } }
private void parseNodeValue(SilkNodeBuilder node) throws XerialException { int nextToken = tokenStream.LA(1); switch (nextToken) { case At: SilkFunction func = parseFunctionInternal(new SilkFunction()); node.setFunction(func); break; case PlainOneLine: case String: { Token t = getToken(1); consume(); node.setValue(t.getText()); break; } case JSON: { Token t = getToken(1); consume(); node.setJSON(t.getText()); break; } default: throw unexpectedToken(tokenStream.LT(1), At, PlainOneLine, String); } }
private SilkNodeBuilder parseSilkNode(SilkNodeBuilder node) throws XerialException { if (!(nextTokenIs(NodeIndent) || nextTokenIs(BlockIndent) || nextTokenIs(PullUpNodeIndent))) throw new XerialException(XerialErrorCode.PARSE_ERROR, "expected a node indent, but " + toString(tokenStream.LT(1))); Token indent = getToken(1); node.setIndent(indent.getText()); consume(); switch (tokenStream.LA(1)) { case LParen: consume(); parseAttributeList(node); testAndConsume(RParen); break; default: { parseNodeItem(node); break; } } return node; }
private SilkNodeBuilder parseSilkNode(SilkNodeBuilder node) throws XerialException { if (!(nextTokenIs(NodeIndent) || nextTokenIs(BlockIndent) || nextTokenIs(PullUpNodeIndent))) throw new XerialException(XerialErrorCode.PARSE_ERROR, "expected a node indent, but " + toString(tokenStream.LT(1))); Token indent = getToken(1); node.setIndent(indent.getText()); consume(); switch (tokenStream.LA(1)) { case LParen: consume(); parseAttributeList(node); testAndConsume(RParen); break; default: { parseNodeItem(node); break; } } return node; }
public SilkElement parse() throws XerialException { switch (tokenStream.LA(1)) { case NodeIndent: if (tokenStream.LA(2) == At) return parseFunction(); else return parseSilkNode().build(); case BlockIndent: { SilkNodeBuilder node = parseSilkNode(); node.setOccurrence(SilkNodeOccurrence.SEQUENCE_PRESERVING_WHITESPACES); return node.build(); } case PullUpNodeIndent: { SilkNodeBuilder node = parseSilkNode(); node.setOccurrence(SilkNodeOccurrence.SEQUENCE_PRESERVING_WHITESPACES); return node.build(); } case FunctionIndent: { SilkFunction func = parseFunction(); return func; } default: throw unexpectedToken(tokenStream.LT(1), NodeIndent, FunctionIndent); } }