Examples of IntervalSet


Examples of org.antlr.v4.runtime.misc.IntervalSet

  /** [Aa\t \u1234a-z\]\-] char sets */
  @Override
  public Handle charSetLiteral(GrammarAST charSetAST) {
    ATNState left = newState(charSetAST);
    ATNState right = newState(charSetAST);
    IntervalSet set = getSetFromCharSetLiteral(charSetAST);
    left.addTransition(new SetTransition(right, set));
    charSetAST.atnState = left;
    return new Handle(left, right);
  }
View Full Code Here

Examples of org.antlr.v4.runtime.misc.IntervalSet

  public IntervalSet getSetFromCharSetLiteral(GrammarAST charSetAST) {
    String chars = charSetAST.getText();
    chars = chars.substring(1, chars.length()-1);
    String cset = '"'+ chars +'"';
    IntervalSet set = new IntervalSet();

    // unescape all valid escape char like \n, leaving escaped dashes as '\-'
    // so we can avoid seeing them as '-' range ops.
    chars = CharSupport.getStringFromGrammarStringLiteral(cset);
    // now make x-y become set of char
    int n = chars.length();
    for (int i=0; i< n; i++) {
      int c = chars.charAt(i);
      if ( c=='\\' && (i+1)<n && chars.charAt(i+1)=='-' ) { // \-
        set.add('-');
        i++;
      }
      else if ( (i+2)<n && chars.charAt(i+1)=='-' ) { // range x-y
        int x = c;
        int y = chars.charAt(i+2);
        if ( x<=y ) set.add(x,y);
        i+=2;
      }
      else {
        set.add(c);
      }
    }
    return set;
  }
View Full Code Here

Examples of org.antlr.v4.runtime.misc.IntervalSet

  public void process() {
    if ( !CodeGenerator.targetExists(g.getOptionString("language")) ) return;

    CodeGenerator gen = new CodeGenerator(g);
    IntervalSet idTypes = new IntervalSet();
    idTypes.add(ANTLRParser.ID);
    idTypes.add(ANTLRParser.RULE_REF);
    idTypes.add(ANTLRParser.TOKEN_REF);
    List<GrammarAST> idNodes = g.ast.getNodesWithType(idTypes);
    for (GrammarAST idNode : idNodes) {
      if ( gen.getTarget().grammarSymbolCausesIssueInGeneratedCode(idNode) ) {
        g.tool.errMgr.grammarError(ErrorType.USE_OF_BAD_WORD,
                       g.fileName, idNode.getToken(),
View Full Code Here

Examples of org.antlr.v4.runtime.misc.IntervalSet

    /** Lookahead for each alt 1..n */
    IntervalSet[] altLookSets = factory.getGrammar().decisionLOOK.get(decision);
    altLook = getAltLookaheadAsStringLists(altLookSets);

    IntervalSet expecting = IntervalSet.or(altLookSets); // combine alt sets
    this.error = getThrowNoViableAlt(factory, blkAST, expecting);
  }
View Full Code Here

Examples of org.antlr.v4.runtime.misc.IntervalSet

    /** Lookahead for each alt 1..n */
//    IntervalSet[] altLookSets = LinearApproximator.getLL1LookaheadSets(dfa);
    IntervalSet[] altLookSets = factory.getGrammar().decisionLOOK.get(decision);
    altLook = getAltLookaheadAsStringLists(altLookSets);
    IntervalSet look = altLookSets[0];
    IntervalSet followLook = altLookSets[1];

    IntervalSet expecting = look.or(followLook);
    this.error = getThrowNoViableAlt(factory, blkAST, expecting);

    expr = addCodeForLookaheadTempVar(look);
    followExpr = factory.getLL1Test(followLook, blkAST);
  }
View Full Code Here

Examples of org.antlr.v4.runtime.misc.IntervalSet

   */
  public Set<Decl> getDeclsForAllElements(List<AltAST> altASTs) {
    Set<String> needsList = new HashSet<String>();
    List<GrammarAST> allRefs = new ArrayList<GrammarAST>();
    for (AltAST ast : altASTs) {
      IntervalSet reftypes = new IntervalSet(RULE_REF, TOKEN_REF);
      List<GrammarAST> refs = ast.getNodesWithType(reftypes);
      allRefs.addAll(refs);
      FrequencySet<String> altFreq = getElementFrequenciesForAlt(ast);
      for (GrammarAST t : refs) {
        String refLabelName = t.getText();
View Full Code Here

Examples of org.antlr.v4.runtime.misc.IntervalSet

    StarLoopEntryState star = (StarLoopEntryState)starRoot.atnState;
    loopBackStateNumber = star.loopBackState.stateNumber;
    this.decision = star.decision;
    IntervalSet[] altLookSets = factory.getGrammar().decisionLOOK.get(decision);
    assert altLookSets.length == 2;
    IntervalSet enterLook = altLookSets[0];
    IntervalSet exitLook = altLookSets[1];
    loopExpr = addCodeForLoopLookaheadTempVar(enterLook);
  }
View Full Code Here

Examples of org.antlr.v4.runtime.misc.IntervalSet

    blockStartStateNumber = blkStart.stateNumber;
    PlusBlockStartState plus = (PlusBlockStartState)blkAST.atnState;
    this.decision = plus.loopBackState.decision;
    IntervalSet[] altLookSets = factory.getGrammar().decisionLOOK.get(decision);

    IntervalSet loopBackLook = altLookSets[0];
    loopExpr = addCodeForLoopLookaheadTempVar(loopBackLook);
  }
View Full Code Here

Examples of org.antlr.v4.runtime.misc.IntervalSet

        "[@29,41:43=''+'',<62>,4:6]\n" +
        "[@31,45:45='e',<57>,4:10]\n" +
        "[@37,53:55=''.'',<62>,5:6]\n" +
        "[@39,57:58='ID',<66>,5:10]";

    IntervalSet types =
        new IntervalSet(ANTLRParser.TOKEN_REF,
        ANTLRParser.STRING_LITERAL,
        ANTLRParser.RULE_REF);
    List<GrammarAST> nodes = g.ast.getNodesWithTypePreorderDFS(types);
    List<Token> tokens = new ArrayList<Token>();
    for (GrammarAST node : nodes) {
View Full Code Here

Examples of org.antlr.v4.runtime.misc.IntervalSet

        "[@31,43:45=''+'',<62>,4:6]\n" +
        "[@33,47:47='e',<57>,4:10]\n" +
        "[@39,55:57=''.'',<62>,5:6]\n" +
        "[@43,61:62='ID',<66>,5:12]";

    IntervalSet types =
        new IntervalSet(ANTLRParser.TOKEN_REF,
        ANTLRParser.STRING_LITERAL,
        ANTLRParser.RULE_REF);
    List<GrammarAST> nodes = g.ast.getNodesWithTypePreorderDFS(types);
    List<Token> tokens = new ArrayList<Token>();
    for (GrammarAST node : nodes) {
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.