本文整理汇总了Java中org.parboiled.support.ValueStack.pop方法的典型用法代码示例。如果您正苦于以下问题:Java ValueStack.pop方法的具体用法?Java ValueStack.pop怎么用?Java ValueStack.pop使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.parboiled.support.ValueStack
的用法示例。
在下文中一共展示了ValueStack.pop方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: run
import org.parboiled.support.ValueStack; //导入方法依赖的package包/类
@Override
public boolean run(Context<CfgElement> context) {
final ValueStack<CfgElement> stack = context.getValueStack();
if (!context.hasError()) {
int size = stack.size();
switch (size) {
case 1:
CfgElement elemKey = stack.pop();
parsedProps.setProperty(unescape(elemKey.getText()), "");
cfgFile.getElements().add(new PairElement(elemKey));
break;
case 2:
// NOTE: stack popping order below is important!
final CfgElement elemValue = stack.pop();
elemKey = stack.pop();
parsedProps.setProperty(unescape(elemKey.getText()), unescape(elemValue.getText()));
cfgFile.getElements().add(new PairElement(elemKey, elemValue));
break;
default:
throw new IllegalStateException(String.format("Cannot manage %d values on the parsing stack", size));
}
} else {
stack.clear();
}
return true;
}
示例2: sequence
import org.parboiled.support.ValueStack; //导入方法依赖的package包/类
@Test
public void sequence() {
DomainParserGrammar.DomainGrammar parser = Parboiled.createParser(DomainParserGrammar.DomainGrammar.class);
ReportingParseRunner<?> runner = new ReportingParseRunner(parser.Domain());
ParsingResult<?> result = runner.run("R(-1.0:2.0),R(1.0:2.0)");
ValueStack<Real> s = (ValueStack<Real>) result.valueStack;
Assert.assertThat(s.size(), equalTo(2));
Assert.assertThat(s.peek().getBounds().getLowerBound(), equalTo(1.0));
s.pop();
Assert.assertThat(s.peek().getBounds().getLowerBound(), equalTo(-1.0));
}
示例3: linkNodes
import org.parboiled.support.ValueStack; //导入方法依赖的package包/类
public static void linkNodes(ValueStack<AstNode> stack) {
AstNode prev = null;
while (!stack.isEmpty()) {
AstNode node = stack.pop();
if (prev != null) {
AstNode parent = prev;
while (!(node.getStartIndex() <= parent.getEndIndex()
&& node.getStartIndex() >= parent.getStartIndex())) {
parent = parent.getParent();
}
//System.out.println("Tying "+node+" to parent: "+parent);
int index = -1;
List<AstNode> children = parent.getChildren();
if( ! children.isEmpty())
{
for(int i=0; i!=children.size(); i++)
{
if(node.getStartIndex() > children.get(i).getStartIndex())
{
index = i;
break;
}
}
}
parent.addChildAt(node, index+1);
node.setParent(parent);
}
prev = node;
}
}