/** Each state in the DFA represents a different input sequence for an * alt of the decision. Given a DFA state, what is the semantic * predicate context for a particular alt. */ public SemanticContext getSemanticContextForAlt(DFAState d, int alt) { Map<Integer, SemanticContext> altToPredMap = stateToAltSetWithSemanticPredicatesMap.get(d); if ( altToPredMap==null ) { return null; } return altToPredMap.get(Utils.integer(alt)); }
public String getTargetStringLiteralFromANTLRStringLiteral( CodeGenerator generator, String literal) { literal = Utils.replace(literal,"\\\'","''"); // \' to ' to normalize literal = Utils.replace(literal,"\\r\\n","'#13#10'"); literal = Utils.replace(literal,"\\r","'#13'"); literal = Utils.replace(literal,"\\n","'#10'"); StringBuffer buf = new StringBuffer(literal); buf.setCharAt(0,'\''); buf.setCharAt(literal.length()-1,'\''); return buf.toString(); }
/** Each state in the DFA represents a different input sequence for an * alt of the decision. Given a DFA state, what is the semantic * predicate context for a particular alt. */ public SemanticContext getSemanticContextForAlt(DFAState d, int alt) { Map altToPredMap = (Map)stateToAltSetWithSemanticPredicatesMap.get(d); if ( altToPredMap==null ) { return null; } return (SemanticContext)altToPredMap.get(Utils.integer(alt)); }
public String getTargetStringLiteralFromANTLRStringLiteral( CodeGenerator generator, String literal) { literal = Utils.replace(literal,"\\\'","''"); // \' to ' to normalize literal = Utils.replace(literal,"\\r\\n","'#13#10'"); literal = Utils.replace(literal,"\\r","'#13'"); literal = Utils.replace(literal,"\\n","'#10'"); StringBuffer buf = new StringBuffer(literal); buf.setCharAt(0,'\''); buf.setCharAt(literal.length()-1,'\''); return buf.toString(); }
/** Each state in the DFA represents a different input sequence for an * alt of the decision. Given a DFA state, what is the semantic * predicate context for a particular alt. */ public SemanticContext getSemanticContextForAlt(DFAState d, int alt) { Map<Integer, SemanticContext> altToPredMap = stateToAltSetWithSemanticPredicatesMap.get(d); if ( altToPredMap==null ) { return null; } return altToPredMap.get(Utils.integer(alt)); }
@Override public String getTargetStringLiteralFromANTLRStringLiteral( CodeGenerator generator, String literal) { literal = Utils.replace(literal,"\\\'","''"); // \' to ' to normalize literal = Utils.replace(literal,"\\r\\n","'#13#10'"); literal = Utils.replace(literal,"\\r","'#13'"); literal = Utils.replace(literal,"\\n","'#10'"); StringBuilder buf = new StringBuilder(literal); buf.setCharAt(0,'\''); buf.setCharAt(literal.length()-1,'\''); return buf.toString(); }
protected void initAltRelatedInfo() { unreachableAlts = new LinkedList<Integer>(); for (int i = 1; i <= nAlts; i++) { unreachableAlts.add(Utils.integer(i)); } altToAcceptState = new DFAState[nAlts+1]; }
@Override public String getTargetStringLiteralFromANTLRStringLiteral( CodeGenerator generator, String literal) { literal = Utils.replace(literal,"\\\'","''"); // \' to ' to normalize literal = Utils.replace(literal,"\\r\\n","'#13#10'"); literal = Utils.replace(literal,"\\r","'#13'"); literal = Utils.replace(literal,"\\n","'#10'"); StringBuilder buf = new StringBuilder(literal); buf.setCharAt(0,'\''); buf.setCharAt(literal.length()-1,'\''); return buf.toString(); }
/** Each state in the DFA represents a different input sequence for an * alt of the decision. Given a DFA state, what is the semantic * predicate context for a particular alt. */ public SemanticContext getSemanticContextForAlt(DFAState d, int alt) { Map altToPredMap = (Map)stateToAltSetWithSemanticPredicatesMap.get(d); if ( altToPredMap==null ) { return null; } return (SemanticContext)altToPredMap.get(Utils.integer(alt)); }
public String groomQualifiedFileName(String outputDir, String fileName) { if (outputDir.equals(".")) { return fileName; } else if (outputDir.indexOf(' ') >= 0) { // has spaces? String escSpaces = Utils.replace(outputDir.toString(), " ", "\\ "); return escSpaces + File.separator + fileName; } else { return outputDir + File.separator + fileName; } } }
protected void initAltRelatedInfo() { unreachableAlts = new LinkedList<Integer>(); for (int i = 1; i <= nAlts; i++) { unreachableAlts.add(Utils.integer(i)); } altToAcceptState = new DFAState[nAlts+1]; }
public String groomQualifiedFileName(String outputDir, String fileName) { if (outputDir.equals(".")) { return fileName; } else if (outputDir.indexOf(' ') >= 0) { // has spaces? String escSpaces = Utils.replace(outputDir.toString(), " ", "\\ "); return escSpaces + File.separator + fileName; } else { return outputDir + File.separator + fileName; } } }
protected void initAltRelatedInfo() { unreachableAlts = new LinkedList(); for (int i = 1; i <= nAlts; i++) { unreachableAlts.add(Utils.integer(i)); } altToAcceptState = new DFAState[nAlts+1]; }
public String groomQualifiedFileName(String outputDir, String fileName) { if (outputDir.equals(".")) { return fileName; } else if (outputDir.indexOf(' ') >= 0) { // has spaces? String escSpaces = Utils.replace(outputDir.toString(), " ", "\\ "); return escSpaces + File.separator + fileName; } else { return outputDir + File.separator + fileName; } } }
protected void initAltRelatedInfo() { unreachableAlts = new LinkedList(); for (int i = 1; i <= nAlts; i++) { unreachableAlts.add(Utils.integer(i)); } altToAcceptState = new DFAState[nAlts+1]; }
public String groomQualifiedFileName(String outputDir, String fileName) { if (outputDir.equals(".")) { return fileName; } else if (outputDir.indexOf(' ') >= 0) { // has spaces? String escSpaces = Utils.replace(outputDir.toString(), " ", "\\ "); return escSpaces + File.separator + fileName; } else { return outputDir + File.separator + fileName; } } }
public List toList() { List values = new ArrayList(); int n = intervals.size(); for (int i = 0; i < n; i++) { Interval I = (Interval) intervals.get(i); int a = I.a; int b = I.b; for (int v=a; v<=b; v++) { values.add(Utils.integer(v)); } } return values; }
/** Convert from an ANTLR string literal found in a grammar file to * an equivalent string literal in the target language. For Java, this * is the translation 'a\n"' -> "a\n\"". Expect single quotes * around the incoming literal. Just flip the quotes and replace * double quotes with \" */ public String getTargetStringLiteralFromANTLRStringLiteral(CodeGenerator generator, String literal) { literal = Utils.replace(literal,"\"","\\\""); StringBuffer buf = new StringBuffer(literal); buf.setCharAt(0,'"'); buf.setCharAt(literal.length()-1,'"'); buf.insert(0,'@'); return buf.toString(); }
public List toList() { List values = new ArrayList(); int n = intervals.size(); for (int i = 0; i < n; i++) { Interval I = (Interval) intervals.get(i); int a = I.a; int b = I.b; for (int v=a; v<=b; v++) { values.add(Utils.integer(v)); } } return values; }
/** Convert from an ANTLR string literal found in a grammar file to * an equivalent string literal in the target language. For Java, this * is the translation 'a\n"' -> "a\n\"". Expect single quotes * around the incoming literal. Just flip the quotes and replace * double quotes with \" */ public String getTargetStringLiteralFromANTLRStringLiteral(CodeGenerator generator, String literal) { literal = Utils.replace(literal,"\"","\\\""); StringBuffer buf = new StringBuffer(literal); buf.setCharAt(0,'"'); buf.setCharAt(literal.length()-1,'"'); buf.insert(0,'@'); return buf.toString(); }