当前位置: 首页>>代码示例>>Java>>正文


Java ValueStack类代码示例

本文整理汇总了Java中org.parboiled.support.ValueStack的典型用法代码示例。如果您正苦于以下问题:Java ValueStack类的具体用法?Java ValueStack怎么用?Java ValueStack使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ValueStack类属于org.parboiled.support包,在下文中一共展示了ValueStack类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
 
开发者ID:AlexFalappa,项目名称:nb-springboot,代码行数:27,代码来源:CfgPropsParboiled.java

示例2: parse

import org.parboiled.support.ValueStack; //导入依赖的package包/类
public static List<Node> parse(String query, ParserConfig config) {
    QueryParser expressionParser = Parboiled.createParser(QueryParser.class, config);
    ValueStack<Object> nodes = parse(query, expressionParser.Query());
    List<Node> nodeList = new LinkedList<>();

    for (Object node : nodes) {
        if (node instanceof Node) {
            nodeList.add((Node) node);
        }
    }
    return nodeList;
}
 
开发者ID:edmocosta,项目名称:queryfy,代码行数:13,代码来源:Evaluator.java

示例3: testOrderOperation

import org.parboiled.support.ValueStack; //导入依赖的package包/类
private void testOrderOperation(String query, List<OrderNode.OrderSpecifier> expected) {
    QueryParser expressionParser = Parboiled.createParser(QueryParser.class);

    ValueStack<Object> nodes = ExpressionParserUtils.parse(query, expressionParser.Query());
    for (Object node : nodes) {
        if (node instanceof OrderNode) {
            assertOrders((OrderNode) node, expected);
            return;
        }
    }
    Assert.fail("Order node not found");
}
 
开发者ID:edmocosta,项目名称:queryfy,代码行数:13,代码来源:OrderOperationTest.java

示例4: parse

import org.parboiled.support.ValueStack; //导入依赖的package包/类
public static ValueStack<Object> parse(String expression, Rule ruleTree) {
    ReportingParseRunner<Object> runner = new ReportingParseRunner<>(ruleTree);
    ParsingResult<Object> result = runner.run(expression);

    if (!result.matched || result.hasErrors()) {
        throw new IllegalArgumentException("Invalid query: " + printParseErrors(result));
    }

    return result.valueStack;
}
 
开发者ID:edmocosta,项目名称:queryfy,代码行数:11,代码来源:ExpressionParserUtils.java

示例5: testProjectionOperation

import org.parboiled.support.ValueStack; //导入依赖的package包/类
private void testProjectionOperation(String query, List<String> expected) {
    QueryParser expressionParser = Parboiled.createParser(QueryParser.class);

    ValueStack<Object> nodes = ExpressionParserUtils.parse(query, expressionParser.Query());
    for (Object node : nodes) {
        if (node instanceof ProjectionNode) {
            assertProjections((ProjectionNode) node, expected);
            return;
        }
    }
    Assert.fail("Projection node not found");
}
 
开发者ID:edmocosta,项目名称:queryfy,代码行数:13,代码来源:ProjectionOperationTest.java

示例6: 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));
}
 
开发者ID:collinprice,项目名称:thesis-cilib,代码行数:14,代码来源:DomainParserGrammarTest.java

示例7: boundless

import org.parboiled.support.ValueStack; //导入依赖的package包/类
@Test
public void boundless() {
    DomainParserGrammar.DomainGrammar parser = Parboiled.createParser(DomainParserGrammar.DomainGrammar.class);
    ReportingParseRunner<?> runner = new ReportingParseRunner(parser.Domain());
    ParsingResult<?> result = runner.run("Z");

    ValueStack<?> s = result.valueStack;

    Assert.assertThat(s.size(), equalTo(1));
}
 
开发者ID:collinprice,项目名称:thesis-cilib,代码行数:11,代码来源:DomainParserGrammarTest.java

示例8: 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;
    }

}
 
开发者ID:tcolar,项目名称:fantomidemodule,代码行数:32,代码来源:FantomParserAstActions.java

示例9: testQuery

import org.parboiled.support.ValueStack; //导入依赖的package包/类
private void testQuery(String query,
                       List<String> projections,
                       Object filterValue,
                       List<OrderNode.OrderSpecifier> orders,
                       LimitNode limit) {

    QueryParser expressionParser = Parboiled.createParser(QueryParser.class);
    ValueStack<Object> nodes = ExpressionParserUtils.parse(query, expressionParser.Query());

    boolean projectionTestOk = false;
    boolean filterTestOk = false;
    boolean orderTestOk = false;
    boolean limitTestOk = false;

    for (Object node : nodes) {
        if (node instanceof ProjectionNode) {
            if (projections == null || projections.isEmpty()) {
                Assert.fail("Projection selectors was not expected");
            }
            ProjectionOperationTest.assertProjections((ProjectionNode) node, projections);
            projectionTestOk = true;
            continue;
        }
        if (node instanceof LimitNode) {
            if (limit == null) {
                Assert.fail("Limit node was not expected");
            }
            Assert.assertEquals(limit, node);
            limitTestOk = true;
            continue;
        }
        if (node instanceof OrderNode) {
            if (orders == null || orders.isEmpty()) {
                Assert.fail("Order node was not expected");
            }
            OrderOperationTest.assertOrders((OrderNode) node, orders);
            orderTestOk = true;
            continue;
        }
        if (node instanceof FilterNode) {
            if (filterValue == null) {
                Assert.fail("Filter node was not expected");
            }
            Assert.assertEquals(filterValue, ((FilterNode) node).getArgs().get(0));
            filterTestOk = true;
            continue;
        }
        Assert.fail("Node type " + node.getClass() + " was not expected");
    }

    if (!projectionTestOk && projections != null) {
        Assert.fail("Projection node was not found");
    }
    if (!filterTestOk && filterValue != null) {
        Assert.fail("Filter node was not found");
    }
    if (!limitTestOk && limit != null) {
        Assert.fail("Limit node was not found");
    }
    if (!orderTestOk && orders != null) {
        Assert.fail("Order node was not found");
    }
}
 
开发者ID:edmocosta,项目名称:queryfy,代码行数:64,代码来源:QueryStructureTest.java

示例10: checkArgNotNull

import org.parboiled.support.ValueStack; //导入依赖的package包/类
public ParseRunner<V>withValueStack(ValueStack<V> valueStack) {
    this.valueStack = checkArgNotNull(valueStack, "valueStack");
    this.initialValueStackSnapshot = valueStack.takeSnapshot();
    return this;
}
 
开发者ID:parboiled1,项目名称:parboiled,代码行数:6,代码来源:AbstractParseRunner.java

示例11: getValueStack

import org.parboiled.support.ValueStack; //导入依赖的package包/类
public ValueStack<V> getValueStack() {
    if (valueStack == null) {
        withValueStack(new DefaultValueStack<V>());
    }
    return valueStack;
}
 
开发者ID:parboiled1,项目名称:parboiled,代码行数:7,代码来源:AbstractParseRunner.java

示例12: getValueStack

import org.parboiled.support.ValueStack; //导入依赖的package包/类
/**
 * Returns the value stack instance used during this parsing run.
 *
 * @return the value stack
 */
ValueStack<V> getValueStack();
 
开发者ID:parboiled1,项目名称:parboiled,代码行数:7,代码来源:Context.java

示例13: withValueStack

import org.parboiled.support.ValueStack; //导入依赖的package包/类
/**
 * Initializes the parse runner with the given ValueStack instance.
 *
 * @param valueStack the ValueStack to use
 * @return this instance
 */
ParseRunner<V> withValueStack(ValueStack<V> valueStack);
 
开发者ID:parboiled1,项目名称:parboiled,代码行数:8,代码来源:ParseRunner.java


注:本文中的org.parboiled.support.ValueStack类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。