本文整理了Java中org.parboiled.support.ValueStack.pop()
方法的一些代码示例,展示了ValueStack.pop()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ValueStack.pop()
方法的具体详情如下:
包路径:org.parboiled.support.ValueStack
类名称:ValueStack
方法名:pop
[英]Removes the value at the top of the stack and returns it.
[中]移除堆栈顶部的值并返回它。
代码示例来源:origin: immutables/immutables
@Override
public Object get(Context<Object> context) {
return context.getValueStack().pop();
}
代码示例来源:origin: immutables/immutables
@Override
public final T get(Context<Object> context) {
@SuppressWarnings("unchecked")
B builder = (B) context.getValueStack().pop();
return build(builder);
}
代码示例来源:origin: org.pegdown/pegdown
Node parseListBlock(StringBuilderVar block) {
Context<Object> context = getContext();
Node innerRoot = parseInternal(block);
setContext(context); // we need to save and restore the context since we might be recursing
block.clearContents();
//debugMsg("parsed list block " + innerRoot.toString() + " adjusting indices by " + getContext().getValueStack().peek(), block.getString());
return withIndicesShifted(innerRoot, (Integer) context.getValueStack().pop());
}
代码示例来源:origin: org.immutables/trees
@Override
public Object get(Context<Object> context) {
return context.getValueStack().pop();
}
代码示例来源:origin: org.parboiled/parboiled-java
/**
* Removes the value at the top of the value stack and returns it.
*
* @return the current top value
* @throws IllegalArgumentException if the stack is empty
*/
public V pop() {
check();
return context.getValueStack().pop();
}
代码示例来源:origin: org.parboiled/parboiled-java
/**
* Removes the value the given number of elements below the top of the value stack.
*
* @param down the number of elements to skip before removing the value (0 being equivalent to drop())
* @return true
* @throws IllegalArgumentException if the stack does not contain enough elements to perform this operation
*/
public boolean drop(int down) {
check();
context.getValueStack().pop(down);
return true;
}
代码示例来源:origin: org.parboiled/parboiled-java
/**
* Removes the value the given number of elements below the top of the value stack.
*
* @param down the number of elements to skip before removing the value (0 being equivalent to pop())
* @return the value
* @throws IllegalArgumentException if the stack does not contain enough elements to perform this operation
*/
public V pop(int down) {
check();
return context.getValueStack().pop(down);
}
代码示例来源:origin: org.immutables/cases
@Override
public final T get(Context<Object> context) {
@SuppressWarnings("unchecked")
B builder = (B) context.getValueStack().pop();
return build(builder);
}
代码示例来源:origin: org.parboiled/parboiled-java
/**
* Removes the value at the top of the value stack.
*
* @return true
* @throws IllegalArgumentException if the stack is empty
*/
public boolean drop() {
check();
context.getValueStack().pop();
return true;
}
代码示例来源:origin: com.lyncode/plural-property
public static ExpressionList parse (String input) {
if (parser == null)
parser = Parboiled.createParser(PluralPropertyParser.class);
ParsingResult<Object> result = new RecoveringParseRunner<Object>(parser.Translate()).run(input);
Object e = result.valueStack.pop();
return (ExpressionList) e;
}
代码示例来源:origin: jtwig/jtwig-core
@Test
public void blockWithEnd() throws Exception {
ParsingResult<BlockNode> result = parse(underTest.NodeRule(), "{% block test %}{% endblock test %}");
assertThat(result.matched, is(true));
BlockNode node = result.valueStack.pop();
assertThat(node.getBlockIdentifier().getIdentifier(), is("test"));
}
代码示例来源:origin: jtwig/jtwig-core
@Test
public void NodeRuleSimple() throws Exception {
ParsingResult<IncludeNode> result = parse(underTest.NodeRule(), "{% include 'test' %}");
assertThat(result.matched, is(true));
IncludeNode node = result.valueStack.pop();
assertThat(node.isIgnoreMissing(), is(false));
assertThat(node.isInheritModel(), is(true));
assertThat(node.getMapExpression(), instanceOf(MapExpression.class));
}
代码示例来源:origin: jtwig/jtwig-core
@Test
public void trueExpression() throws Exception {
ParsingResult<Expression> result = parse(underTest.ExpressionRule(), "true");
assertThat(result.matched, is(true));
Expression expression = result.valueStack.pop();
assertThat(expression, is(instanceOf(ConstantExpression.class)));
ConstantExpression variableExpression = (ConstantExpression) expression;
assertEquals(variableExpression.getConstantValue(), true);
assertThat(variableExpression.getPosition().getLine(), is(1));
assertThat(variableExpression.getPosition().getColumn(), is(1));
}
代码示例来源:origin: jtwig/jtwig-core
@Test
public void output() throws Exception {
ParsingResult<OutputNode> result = parse(underTest.NodeRule(), "{{ one }}");
assertThat(result.matched, is(true));
OutputNode outputNode = result.valueStack.pop();
assertThat(outputNode.getExpression(), instanceOf(VariableExpression.class));
}
}
代码示例来源:origin: jtwig/jtwig-core
@Test
public void multiBinaryOperationExpression() throws Exception {
ParsingResult<Expression> result = parse(underTest.ExpressionRule(), "2 * 2 - 2");
assertThat(result.matched, is(true));
Expression expression = result.valueStack.pop();
assertThat(expression, instanceOf(BinaryOperationExpression.class));
BinaryOperationExpression exp = (BinaryOperationExpression) expression;
assertThat(exp.getBinaryOperator(), instanceOf(SubtractOperator.class));
}
代码示例来源:origin: jtwig/jtwig-core
@Test
public void ifNodeWithElseIf() throws Exception {
ParsingResult<IfNode> result = parse(underTest.NodeRule(), "{% if (true) %}{% elseif (false) %}{% endif %}");
assertThat(result.matched, is(true));
IfNode ifNode = result.valueStack.pop();
assertThat(ifNode.getConditionNodes().size(), is(2));
}
@Test
代码示例来源:origin: jtwig/jtwig-core
@Test
public void ifNodeWithMultipleElseIf() throws Exception {
ParsingResult<IfNode> result = parse(underTest.NodeRule(), "{% if (true) %}{% elseif (false) %}{% elseif (false) %}{% endif %}");
assertThat(result.matched, is(true));
IfNode ifNode = result.valueStack.pop();
assertThat(ifNode.getConditionNodes().size(), is(3));
}
}
代码示例来源:origin: jtwig/jtwig-core
@Test
public void macroNodeWithNames() throws Exception {
ParsingResult<MacroNode> result = parse(underTest.NodeRule(), "{% macro test(jtwig) %}{% endmacro %}");
assertThat(result.matched, is(true));
MacroNode macroNode = result.valueStack.pop();
assertThat(macroNode.getMacroName().getIdentifier(), is("test"));
assertThat(macroNode.getMacroArgumentNames().size(), is(1));
assertThat(macroNode.getMacroArgumentNames().iterator().next(), is("jtwig"));
}
}
代码示例来源:origin: jtwig/jtwig-core
@Test
public void binaryOperationExpression() throws Exception {
ParsingResult<Expression> result = parse(underTest.ExpressionRule(), "2 + 2");
assertThat(result.matched, is(true));
Expression expression = result.valueStack.pop();
assertThat(expression, instanceOf(BinaryOperationExpression.class));
BinaryOperationExpression exp = (BinaryOperationExpression) expression;
assertThat(exp.getLeftOperand(), instanceOf(ConstantExpression.class));
assertThat(exp.getRightOperand(), instanceOf(ConstantExpression.class));
assertThat(exp.getBinaryOperator(), instanceOf(SumOperator.class));
}
代码示例来源:origin: jtwig/jtwig-core
@Test
public void TernaryUnaryExpression() throws Exception {
ParsingResult<Expression> result = parse(underTest.ExpressionRule(), "not(2 == 2) ? not 1 : 2");
assertThat(result.matched, is(true));
Expression expression = result.valueStack.pop();
assertThat(expression, instanceOf(TernaryOperationExpression.class));
TernaryOperationExpression exp = (TernaryOperationExpression) expression;
assertThat(exp.getFirstExpression(), instanceOf(UnaryOperationExpression.class));
assertThat(exp.getSecondExpression(), instanceOf(UnaryOperationExpression.class));
assertThat(exp.getThirdExpression(), instanceOf(ConstantExpression.class));
}
}
内容来源于网络,如有侵权,请联系作者删除!