Package com.github.jknack.antlr4ide.lang

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


  @Test
  public void checkActionRedefinition() throws Exception {
    EList<PrequelConstruct> prequels = new BasicEList<PrequelConstruct>();

    Grammar grammar = createMock(Grammar.class);
    GrammarAction action1 = createMock(GrammarAction.class);
    GrammarAction action2 = createMock(GrammarAction.class);
    EClass eClass = createMock(EClass.class);
    EStructuralFeature feature = createMock(EStructuralFeature.class);
    Antlr4Validator validator = PowerMock.createPartialMock(Antlr4Validator.class, "error");

    expect(grammar.getPrequels()).andReturn(prequels);

    expect(action1.getScope()).andReturn(null);
    expect(action1.getName()).andReturn("members");

    expect(action2.getScope()).andReturn(null);
View Full Code Here


  }

  @Test
  public void modeNotInLexer() throws Exception {

    Grammar grammar = createMock(Grammar.class);
    Mode mode = createMock(Mode.class);
    EClass eClass = createMock(EClass.class);
    EStructuralFeature feature = createMock(EStructuralFeature.class);
    Antlr4Validator validator = PowerMock.createPartialMock(Antlr4Validator.class, "error");

    expect(mode.eContainer()).andReturn(grammar);

    expect(grammar.getType()).andReturn(GrammarType.DEFAULT);

    expect(mode.eClass()).andReturn(eClass);
    expect(eClass.getEStructuralFeature("id")).andReturn(feature);

    PowerMock.expectPrivate(validator, "error", "lexical modes are only allowed in lexer grammars",
View Full Code Here

  @Test
  public void modeWithoutRules() throws Exception {
    EList<LexerRule> rules = new BasicEList<LexerRule>();

    Grammar grammar = createMock(Grammar.class);
    Mode mode = createMock(Mode.class);
    EClass eClass = createMock(EClass.class);
    EStructuralFeature feature = createMock(EStructuralFeature.class);
    LexerRule rule = createMock(LexerRule.class);
    Antlr4Validator validator = PowerMock.createPartialMock(Antlr4Validator.class, "error");

    expect(mode.eContainer()).andReturn(grammar);
    expect(mode.getId()).andReturn("MODE");

    expect(grammar.getType()).andReturn(GrammarType.LEXER);

    expect(mode.getRules()).andReturn(rules);
    expect(mode.eClass()).andReturn(eClass);
    expect(eClass.getEStructuralFeature("id")).andReturn(feature);
View Full Code Here

  }

  @Test
  public void parserRulesNotAllowed() throws Exception {

    Grammar grammar = createMock(Grammar.class);
    ParserRule rule = createMock(ParserRule.class);
    EClass eClass = createMock(EClass.class);
    EStructuralFeature feature = createMock(EStructuralFeature.class);
    Antlr4Validator validator = PowerMock.createPartialMock(Antlr4Validator.class, "error");

    expect(grammar.getType()).andReturn(GrammarType.LEXER);

    expect(rule.eContainer()).andReturn(grammar);
    expect(rule.eClass()).andReturn(eClass);
    expect(rule.getName()).andReturn("rule");
    expect(eClass.getEStructuralFeature("name")).andReturn(feature);
View Full Code Here

  }

  @Test
  public void lexerRulesNotAllowed() throws Exception {

    Grammar grammar = createMock(Grammar.class);
    LexerRule rule = createMock(LexerRule.class);
    EClass eClass = createMock(EClass.class);
    EStructuralFeature feature = createMock(EStructuralFeature.class);
    Antlr4Validator validator = PowerMock.createPartialMock(Antlr4Validator.class, "error");

    expect(grammar.getType()).andReturn(GrammarType.PARSER);

    expect(rule.eContainer()).andReturn(grammar);
    expect(rule.eClass()).andReturn(eClass);
    expect(rule.getName()).andReturn("RULE");
    expect(eClass.getEStructuralFeature("name")).andReturn(feature);
View Full Code Here

  private void repeatedPrequel(final Class<? extends PrequelConstruct> clazz, final String label)
      throws Exception {
    EList<PrequelConstruct> prequels = new BasicEList<PrequelConstruct>();

    Grammar grammar = createMock(Grammar.class);
    PrequelConstruct prequel1 = createMock(clazz);
    PrequelConstruct prequel2 = createMock(clazz);
    EClass eClass = createMock(EClass.class);
    Antlr4Validator validator = PowerMock.createPartialMock(Antlr4Validator.class, "error");

    expect(grammar.getPrequels()).andReturn(prequels);

    prequels.add(prequel1);
    prequels.add(prequel2);

    PowerMock.expectPrivate(validator, "error",
View Full Code Here

  @Test
  public void checkRuleRedefinition() throws Exception {
    EList<Rule> rules = new BasicEList<Rule>();

    Grammar grammar = createMock(Grammar.class);
    Rule rule1 = createMock(ParserRule.class);
    Rule rule2 = createMock(ParserRule.class);
    EClass eClass = createMock(EClass.class);
    EStructuralFeature feature = createMock(EStructuralFeature.class);
    Antlr4Validator validator = PowerMock.createPartialMock(Antlr4Validator.class, "error");

    expect(grammar.getRules()).andReturn(rules);
    expect(grammar.getModes()).andReturn(new BasicEList<Mode>());

    expect(rule1.getName()).andReturn("rule");

    expect(rule2.getName()).andReturn("rule");
    expect(rule2.eClass()).andReturn(eClass);
View Full Code Here

  @Test
  public void checkRuleRedefinitionInModes() throws Exception {
    EList<Mode> modes = new BasicEList<Mode>();
    EList<LexerRule> rules = new BasicEList<LexerRule>();

    Grammar grammar = createMock(Grammar.class);
    LexerRule rule1 = createMock(LexerRule.class);
    LexerRule rule2 = createMock(LexerRule.class);
    EClass eClass = createMock(EClass.class);
    EStructuralFeature feature = createMock(EStructuralFeature.class);
    Mode mode = createMock(Mode.class);
    Antlr4Validator validator = PowerMock.createPartialMock(Antlr4Validator.class, "error");

    expect(grammar.getRules()).andReturn(new BasicEList<Rule>());
    expect(grammar.getModes()).andReturn(modes);

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

    expect(rule1.getName()).andReturn("Rule");
View Full Code Here

  public void checkDuplicatedV3Token() throws Exception {
    EList<Rule> rules = new BasicEList<Rule>();
    EList<PrequelConstruct> prequels = new BasicEList<PrequelConstruct>();
    EList<V3Token> tokenList = new BasicEList<V3Token>();

    Grammar grammar = createMock(Grammar.class);
    LexerRule rule = createMock(LexerRule.class);
    V3Tokens tokens = createMock(V3Tokens.class);
    V3Token v3Token = createMock(V3Token.class);
    EClass eClass = createMock(EClass.class);
    EStructuralFeature feature = createMock(EStructuralFeature.class);
    Antlr4Validator validator = PowerMock.createPartialMock(Antlr4Validator.class, "warning");

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

    expect(tokens.getTokens()).andReturn(tokenList);

    expect(rule.getName()).andReturn("R");
View Full Code Here

  public void checkDuplicatedV4Token() throws Exception {
    EList<Rule> rules = new BasicEList<Rule>();
    EList<PrequelConstruct> prequels = new BasicEList<PrequelConstruct>();
    EList<V4Token> tokenList = new BasicEList<V4Token>();

    Grammar grammar = createMock(Grammar.class);
    LexerRule rule = createMock(LexerRule.class);
    V4Tokens tokens = createMock(V4Tokens.class);
    V4Token v4Token = createMock(V4Token.class);
    EClass eClass = createMock(EClass.class);
    EStructuralFeature feature = createMock(EStructuralFeature.class);
    Antlr4Validator validator = PowerMock.createPartialMock(Antlr4Validator.class, "warning");

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

    expect(tokens.getTokens()).andReturn(tokenList);

    expect(rule.getName()).andReturn("R");
View Full Code Here

TOP

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

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.