Package com.github.jknack.antlr4ide.lang

Examples of com.github.jknack.antlr4ide.lang.ActionElement


    Grammar grammar = createMock(Grammar.class);
    ParserRule rule1 = createMock(ParserRule.class);
    Return returns = createMock(Return.class);
    LocalVars locals = createMock(LocalVars.class);
    RuleBlock ruleBody = createMock(RuleBlock.class);
    ActionElement actionElement = createMock(ActionElement.class);

    expect(grammar.getRules()).andReturn(rules);

    expect(rule1.getArgs()).andReturn(null);
    expect(rule1.getReturn()).andReturn(returns);
    expect(rule1.getLocals()).andReturn(locals);
    expect(rule1.getBody()).andReturn(ruleBody).times(2);

    expect(returns.getBody()).andReturn(null);

    expect(locals.getBody()).andReturn(localsBody);

    ruleBodyList.add(actionElement);

    expect(ruleBody.eAllContents()).andReturn(newTreeIterator(ruleBodyList));
    expect(ruleBody.eAllContents()).andReturn(newTreeIterator(ruleBodyList));

    expect(actionElement.getBody()).andReturn("{$ctx.tree;}");

    rules.add(rule1);

    Object[] mocks = {grammar, rule1, returns, locals, ruleBody, actionElement };
View Full Code Here


    Return returns = createMock(Return.class);
    LocalVars locals = createMock(LocalVars.class);
    RuleBlock ruleBody = createMock(RuleBlock.class);
    RuleRef ruleRef = createMock(RuleRef.class);
    ParserRule expr = createMock(ParserRule.class);
    ActionElement actionElement = createMock(ActionElement.class);
    Antlr4Validator validator = PowerMock.createPartialMock(Antlr4Validator.class, "error");

    expect(grammar.getRules()).andReturn(rules);

    expect(rule1.getArgs()).andReturn(null);
    expect(rule1.getReturn()).andReturn(returns);
    expect(rule1.getLocals()).andReturn(locals);
    expect(rule1.getBody()).andReturn(ruleBody).times(2);

    expect(returns.getBody()).andReturn(null);

    expect(locals.getBody()).andReturn(null);

    ruleBodyList.add(ruleRef);
    ruleBodyList.add(actionElement);

    expect(ruleBody.eAllContents()).andReturn(newTreeIterator(ruleBodyList));
    expect(ruleBody.eAllContents()).andReturn(newTreeIterator(ruleBodyList));

    expect(ruleRef.getReference()).andReturn(expr);

    expect(expr.getName()).andReturn("expr");

    expect(actionElement.getBody()).andReturn("{int v = $expr.v;}");

    rules.add(rule1);

    Object[] mocks = {grammar, validator, rule1, returns, locals, ruleBody, actionElement,
        ruleRef, expr };
View Full Code Here

    Grammar grammar = createMock(Grammar.class);
    ParserRule rule1 = createMock(ParserRule.class);
    Return returns = createMock(Return.class);
    LocalVars locals = createMock(LocalVars.class);
    RuleBlock ruleBody = createMock(RuleBlock.class);
    ActionElement actionElement = createMock(ActionElement.class);
    Antlr4Validator validator = PowerMock.createPartialMock(Antlr4Validator.class, "error");

    expect(grammar.getRules()).andReturn(rules);

    expect(rule1.getArgs()).andReturn(null);
    expect(rule1.getReturn()).andReturn(returns);
    expect(rule1.getLocals()).andReturn(locals);
    expect(rule1.getBody()).andReturn(ruleBody).times(2);

    expect(returns.getBody()).andReturn(null);

    expect(locals.getBody()).andReturn(null);

    ruleBodyList.add(actionElement);

    expect(ruleBody.eAllContents()).andReturn(newTreeIterator(ruleBodyList));
    expect(ruleBody.eAllContents()).andReturn(newTreeIterator(ruleBodyList));

    expect(actionElement.getBody()).andReturn("{int v = $expr.v;}");

    PowerMock.expectPrivate(validator, "error", "unknown attribute reference 'expr' in '$expr'",
        actionElement, 9, 5);

    rules.add(rule1);
View Full Code Here

    LocalVars locals = createMock(LocalVars.class);
    RuleBlock ruleBody = createMock(RuleBlock.class);
    LabeledElement labeledElement = createMock(LabeledElement.class);
    Terminal terminal = createMock(Terminal.class);
    LexerRule ID = createMock(LexerRule.class);
    ActionElement actionElement = createMock(ActionElement.class);
    ActionOption actionOption = createMock(ActionOption.class);
    Antlr4Validator validator = PowerMock.createPartialMock(Antlr4Validator.class, "error");

    expect(grammar.getRules()).andReturn(rules);

    expect(rule1.getArgs()).andReturn(args);
    expect(rule1.getReturn()).andReturn(returns);
    expect(rule1.getLocals()).andReturn(locals);
    expect(rule1.getBody()).andReturn(ruleBody).times(2);

    expect(returns.getBody()).andReturn(returnBody);

    expect(locals.getBody()).andReturn(localsBody);

    ruleBodyList.add(labeledElement);
    ruleBodyList.add(terminal);
    ruleBodyList.add(actionElement);
    ruleBodyList.add(actionOption);

    expect(ruleBody.eAllContents()).andReturn(newTreeIterator(ruleBodyList));
    expect(ruleBody.eAllContents()).andReturn(newTreeIterator(ruleBodyList));

    expect(terminal.getReference()).andReturn(ID);

    expect(labeledElement.getName()).andReturn("var");

    expect(ID.getName()).andReturn("ID");

    expect(actionElement.getBody()).andReturn("{$undefined = 0;}");

    expect(actionOption.getValue()).andReturn("{$z = 0;}");

    PowerMock.expectPrivate(validator, "error",
        "unknown attribute reference 'undefined' in '$undefined'",
View Full Code Here

    LocalVars locals = createMock(LocalVars.class);
    RuleBlock ruleBody = createMock(RuleBlock.class);
    LabeledElement labeledElement = createMock(LabeledElement.class);
    Terminal terminal = createMock(Terminal.class);
    LexerRule ID = createMock(LexerRule.class);
    ActionElement actionElement = createMock(ActionElement.class);
    ActionOption actionOption = createMock(ActionOption.class);
    Antlr4Validator validator = PowerMock.createPartialMock(Antlr4Validator.class, "error");

    expect(grammar.getRules()).andReturn(rules);

    expect(rule1.getArgs()).andReturn(args);
    expect(rule1.getReturn()).andReturn(returns);
    expect(rule1.getLocals()).andReturn(locals);
    expect(rule1.getBody()).andReturn(ruleBody).times(2);

    expect(returns.getBody()).andReturn(returnBody);

    expect(locals.getBody()).andReturn(localsBody);

    ruleBodyList.add(labeledElement);
    ruleBodyList.add(terminal);
    ruleBodyList.add(actionElement);
    ruleBodyList.add(actionOption);

    expect(ruleBody.eAllContents()).andReturn(newTreeIterator(ruleBodyList));
    expect(ruleBody.eAllContents()).andReturn(newTreeIterator(ruleBodyList));

    expect(terminal.getReference()).andReturn(ID);

    expect(labeledElement.getName()).andReturn("var");

    expect(ID.getName()).andReturn("ID");

    expect(actionElement.getBody()).andReturn("{$a = 0; $b = 3; text = $ID.text;}");

    expect(actionOption.getValue()).andReturn("{$r = 0; $l = null; v = $var;}");

    rules.add(rule1);
View Full Code Here

    verify(mocks);
  }

  @Test
  public void deprecateGatedSemanticPredicate() throws Exception {
    ActionElement action = createMock(ActionElement.class);

    expect(action.getBody()).andReturn("{predicate}=>");

    Antlr4Validator validator = PowerMock.createPartialMock(Antlr4Validator.class, "warning");

    PowerMock
        .expectPrivate(
View Full Code Here

TOP

Related Classes of com.github.jknack.antlr4ide.lang.ActionElement

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.