Examples of ATN


Examples of org.antlr.v4.runtime.atn.ATN

      "15->7 EPSILON 0,0,0\n" +
      "16->17 ATOM 100,0,0\n" +
      "17->9 EPSILON 0,0,0\n" +
      "0:0\n" +
      "1:1\n";
    ATN atn = createATN(lg, true);
    String result = ATNSerializer.getDecoded(atn, Arrays.asList(lg.getTokenNames()));
    assertEquals(expecting, result);
  }
View Full Code Here

Examples of org.antlr.v4.runtime.atn.ATN

      "13->14 ATOM 99,0,0\n" +
      "14->8 EPSILON 0,0,0\n" +
      "0:0\n" +
      "1:1\n" +
      "2:2\n";
    ATN atn = createATN(lg, true);
    String result = ATNSerializer.getDecoded(atn, Arrays.asList(lg.getTokenNames()));
    assertEquals(expecting, result);
  }
View Full Code Here

Examples of org.antlr.v4.runtime.atn.ATN

    String expecting = "A, DONE, EOF";
    checkLexerMatches(lg, "a", expecting);
  }

  protected void checkLexerMatches(LexerGrammar lg, String inputString, String expecting) {
    ATN atn = createATN(lg, true);
    CharStream input = new ANTLRInputStream(inputString);
    ATNState startState = atn.modeNameToStartState.get("DEFAULT_MODE");
    DOTGenerator dot = new DOTGenerator(lg);
    System.out.println(dot.getDOT(startState, true));
View Full Code Here

Examples of org.antlr.v4.runtime.atn.ATN

      g.atn = f.createATN();
      assertEquals(0, g.tool.getNumErrors());
    }

    ATN atn = g.atn;
    if (useSerializer) {
      char[] serialized = ATNSerializer.getSerializedAsChars(atn);
      return new ATNDeserializer().deserialize(serialized);
    }
View Full Code Here

Examples of org.antlr.v4.runtime.atn.ATN

  List<ANTLRMessage> checkRuleDFA(String gtext, String ruleName, String expecting)
    throws Exception
  {
    ErrorQueue equeue = new ErrorQueue();
    Grammar g = new Grammar(gtext, equeue);
    ATN atn = createATN(g, false);
    ATNState s = atn.ruleToStartState[g.getRule(ruleName).index];
    if ( s==null ) {
      System.err.println("no such rule: "+ruleName);
      return null;
    }
View Full Code Here

Examples of org.antlr.v4.runtime.atn.ATN

  List<ANTLRMessage> checkRuleDFA(String gtext, int decision, String expecting)
    throws Exception
  {
    ErrorQueue equeue = new ErrorQueue();
    Grammar g = new Grammar(gtext, equeue);
    ATN atn = createATN(g, false);
    DecisionState blk = atn.decisionToState.get(decision);
    checkRuleDFA(g, blk, expecting);
    return equeue.all;
  }
View Full Code Here

Examples of org.antlr.v4.runtime.atn.ATN

    this.g = g;

    ATNType atnType = g instanceof LexerGrammar ? ATNType.LEXER : ATNType.PARSER;
    int maxTokenType = g.getMaxTokenType();
    this.atn = new ATN(atnType, maxTokenType);
  }
View Full Code Here

Examples of org.antlr.v4.runtime.atn.ATN

    if (this.isCombined()) {
      return implicitLexer.createLexerInterpreter(input);
    }

    char[] serializedAtn = ATNSerializer.getSerializedAsChars(atn);
    ATN deserialized = new ATNDeserializer().deserialize(serializedAtn);
    return new LexerInterpreter(fileName, getVocabulary(), Arrays.asList(getRuleNames()), ((LexerGrammar)this).modes.keySet(), deserialized, input);
  }
View Full Code Here

Examples of org.antlr.v4.runtime.atn.ATN

    if (this.isLexer()) {
      throw new IllegalStateException("A parser interpreter can only be created for a parser or combined grammar.");
    }

    char[] serializedAtn = ATNSerializer.getSerializedAsChars(atn);
    ATN deserialized = new ATNDeserializer().deserialize(serializedAtn);
    return new ParserInterpreter(fileName, getVocabulary(), Arrays.asList(getRuleNames()), deserialized, tokenStream);
  }
View Full Code Here

Examples of org.antlr.v4.runtime.atn.ATN

    if ( g.modes.get(modeName)==null ) {
      System.err.println("no such mode "+modeName);
      return;
    }
    ParserATNFactory f = new LexerATNFactory(g);
    ATN nfa = f.createATN();
    ATNState startState = nfa.modeNameToStartState.get(modeName);
    ATNPrinter serializer = new ATNPrinter(g, startState);
    String result = serializer.asString();
    //System.out.print(result);
    assertEquals(expecting, result);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.