Package org.stringtemplate.v4.misc

Examples of org.stringtemplate.v4.misc.ErrorBuffer


    super(msgID,arg,null);
    this.e = e;
  }
  @Override
  public String toString() {
    ST st = getMessageTemplate();
    if ( arg!=null ) {
      st.add("arg", arg);
    }
    if ( arg2!=null ) {
      st.add("arg2", arg2);
    }
    if ( e!=null ) {
      st.add("exception", e);
      st.add("stackTrace", e.getStackTrace());
    }
    return super.toString(st);
  }
View Full Code Here


    column = decisionASTNode.getCharPositionInLine();
    String fileName = probe.dfa.nfa.grammar.getFileName();
    if ( fileName!=null ) {
      file = fileName;
    }
    ST st = getMessageTemplate();
    st.add("enclosingRule",
            probe.dfa.getNFADecisionStartState().enclosingRule.name);

    return super.toString(st);
  }
View Full Code Here

    String fileName = probe.dfa.nfa.grammar.getFileName();
    if ( fileName!=null ) {
      file = fileName;
    }

    ST st = getMessageTemplate();
    st.add("targetRules", targetRules);
    st.add("alt", alt);
    st.add("callSiteStates", callSiteStates);

    List<Label> labels =
      probe.getSampleNonDeterministicInputSequence(sampleBadState);
    String input = probe.getInputSequenceDisplay(labels);
    st.add("input", input);

    return super.toString(st);
  }
View Full Code Here

    String fileName = probe.dfa.nfa.grammar.getFileName();
    if ( fileName!=null ) {
      file = fileName;
    }

    ST st = getMessageTemplate();
    // Now fill template with information about problemState
    List<Label> labels = probe.getSampleNonDeterministicInputSequence(problemState);
    String input = probe.getInputSequenceDisplay(labels);
    st.add("input", input);

    if ( probe.dfa.isTokensRuleDecision() ) {
      Set<Integer> disabledAlts = probe.getDisabledAlternatives(problemState);
      for (Integer altI : disabledAlts) {
        String tokenName =
          probe.getTokenNameForTokensRuleAlt(altI);
        // reset the line/col to the token definition (pick last one)
        NFAState ruleStart =
          probe.dfa.nfa.grammar.getRuleStartState(tokenName);
        line = ruleStart.associatedASTNode.getLine();
        column = ruleStart.associatedASTNode.getCharPositionInLine();
        st.add("disabled", tokenName);
      }
    }
    else {
      st.add("disabled", probe.getDisabledAlternatives(problemState));
    }

    List<Integer> nondetAlts = probe.getNonDeterministicAltsForState(problemState);
    NFAState nfaStart = probe.dfa.getNFADecisionStartState();
    // all state paths have to begin with same NFA state
    int firstAlt = 0;
    if ( nondetAlts!=null ) {
      for (Integer displayAltI : nondetAlts) {
        if ( DecisionProbe.verbose ) {
          int tracePathAlt =
            nfaStart.translateDisplayAltToWalkAlt(displayAltI);
          if ( firstAlt == 0 ) {
            firstAlt = tracePathAlt;
          }
          List<? extends NFAState> path =
            probe.getNFAPathStatesForAlt(firstAlt,
                           tracePathAlt,
                           labels);
          st.addAggr("paths.{alt, states}", displayAltI, path);
        }
        else {
          if ( probe.dfa.isTokensRuleDecision() ) {
            // alts are token rules, convert to the names instead of numbers
            String tokenName =
              probe.getTokenNameForTokensRuleAlt(displayAltI);
            st.add("conflictingTokens", tokenName);
          }
          else {
            st.add("conflictingAlts", displayAltI);
          }
        }
      }
    }
    st.add("hasPredicateBlockedByAction", problemState.dfa.hasPredicateBlockedByAction);
    return super.toString(st);
  }
View Full Code Here

   */
  public GrammarAST addArtificialMatchTokensRule(GrammarAST grammarAST,
                           List<String> ruleNames,
                           List<String> delegateNames,
                           boolean filterMode) {
    ST matchTokenRuleST;
    if ( filterMode ) {
      matchTokenRuleST = new ST(
          ARTIFICIAL_TOKENS_RULENAME+
          " options {k=1; backtrack=true;} : <rules; separator=\"|\">;");
    }
    else {
      matchTokenRuleST = new ST(
          ARTIFICIAL_TOKENS_RULENAME+" : <rules; separator=\"|\">;");
    }

    // Now add token rule references
    for (int i = 0; i < ruleNames.size(); i++) {
      String rname = ruleNames.get(i);
      matchTokenRuleST.add("rules", rname);
    }
    for (int i = 0; i < delegateNames.size(); i++) {
      String dname = delegateNames.get(i);
      matchTokenRuleST.add("rules", dname+".Tokens");
    }
    //System.out.println("tokens rule: "+matchTokenRuleST.toString());
    GrammarAST r = parseArtificialRule(matchTokenRuleST.render());
    addRule(grammarAST, r);
    //addRule((GrammarAST)parser.getAST());
    //return (GrammarAST)parser.getAST();
    return r;
  }
View Full Code Here

                    DFA dfa)
    {
      if ( templates!=null ) {
        return templates.getInstanceOf("true_value");
      }
      return new ST("true");
    }
View Full Code Here

                    DFA dfa)
    {
      if ( templates!=null ) {
        return templates.getInstanceOf("false");
      }
      return new ST("false");
    }
View Full Code Here

    @Override
    public ST genExpr(CodeGenerator generator,
                    STGroup templates,
                    DFA dfa)
    {
      ST result = null;
      for (SemanticContext operand : operands) {
        if (result == null) {
          result = operand.genExpr(generator, templates, dfa);
          continue;
        }

        ST eST;
        if ( templates!=null ) {
          eST = templates.getInstanceOf("andPredicates");
        }
        else {
          eST = new ST("(<left>&&<right>)");
        }
        eST.add("left", result);
        eST.add("right", operand.genExpr(generator,templates,dfa));
        result = eST;
      }

      return result;
    }
View Full Code Here

    @Override
    public ST genExpr(CodeGenerator generator,
                    STGroup templates,
                    DFA dfa)
    {
      ST eST;
      if ( templates!=null ) {
        eST = templates.getInstanceOf("orPredicates");
      }
      else {
        eST = new ST("(<operands; separator=\"||\">)");
      }
      for (SemanticContext semctx : operands) {
        eST.add("operands", semctx.genExpr(generator,templates,dfa));
      }
      return eST;
    }
View Full Code Here

    @Override
    public ST genExpr(CodeGenerator generator,
                    STGroup templates,
                    DFA dfa)
    {
      ST eST;
      if ( templates!=null ) {
        eST = templates.getInstanceOf("notPredicate");
      }
      else {
        eST = new ST("!(<pred>)");
      }
      eST.add("pred", ctx.genExpr(generator,templates,dfa));
      return eST;
    }
View Full Code Here

TOP

Related Classes of org.stringtemplate.v4.misc.ErrorBuffer

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.