• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java ValueStack类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了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;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java FlywayFactory类代码示例发布时间:2022-05-22
下一篇:
Java LDAPSocketFactory类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap