@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(); }
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(); }
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(); }
@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(); }
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 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 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 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; } } }
/** 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(); }
/** 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(); }
/** 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 \" */ @Override public String getTargetStringLiteralFromANTLRStringLiteral(CodeGenerator generator, String literal) { literal = Utils.replace(literal,"\"","\\\""); StringBuilder buf = new StringBuilder(literal); buf.setCharAt(0,'"'); buf.setCharAt(literal.length()-1,'"'); buf.insert(0,'@'); return buf.toString(); }
/** 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 \" */ @Override public String getTargetStringLiteralFromANTLRStringLiteral(CodeGenerator generator, String literal) { literal = Utils.replace(literal,"\"","\\\""); StringBuilder buf = new StringBuilder(literal); buf.setCharAt(0,'"'); buf.setCharAt(literal.length()-1,'"'); buf.insert(0,'@'); return buf.toString(); }
public String toString(boolean showAlt) { StringBuilder buf = new StringBuilder(); buf.append(state); if ( showAlt ) { buf.append("|"); buf.append(alt); } if ( context.parent!=null ) { buf.append("|"); buf.append(context); } if ( semanticContext!=null && semanticContext!=SemanticContext.EMPTY_SEMANTIC_CONTEXT ) { buf.append("|"); String escQuote = Utils.replace(semanticContext.toString(), "\"", "\\\""); buf.append(escQuote); } if ( resolved ) { buf.append("|resolved"); } if ( resolveWithPredicate ) { buf.append("|resolveWithPredicate"); } return buf.toString(); } }
public String toString(boolean showAlt) { StringBuilder buf = new StringBuilder(); buf.append(state); if ( showAlt ) { buf.append("|"); buf.append(alt); } if ( context.parent!=null ) { buf.append("|"); buf.append(context); } if ( semanticContext!=null && semanticContext!=SemanticContext.EMPTY_SEMANTIC_CONTEXT ) { buf.append("|"); String escQuote = Utils.replace(semanticContext.toString(), "\"", "\\\""); buf.append(escQuote); } if ( resolved ) { buf.append("|resolved"); } if ( resolveWithPredicate ) { buf.append("|resolveWithPredicate"); } return buf.toString(); } }
public String toString(boolean showAlt) { StringBuffer buf = new StringBuffer(); buf.append(state); if ( showAlt ) { buf.append("|"); buf.append(alt); } if ( context.parent!=null ) { buf.append("|"); buf.append(context); } if ( semanticContext!=null && semanticContext!=SemanticContext.EMPTY_SEMANTIC_CONTEXT ) { buf.append("|"); String escQuote = Utils.replace(semanticContext.toString(), "\"", "\\\""); buf.append(escQuote); } if ( resolved ) { buf.append("|resolved"); } if ( resolveWithPredicate ) { buf.append("|resolveWithPredicate"); } return buf.toString(); } }
public String toString(boolean showAlt) { StringBuffer buf = new StringBuffer(); buf.append(state); if ( showAlt ) { buf.append("|"); buf.append(alt); } if ( context.parent!=null ) { buf.append("|"); buf.append(context); } if ( semanticContext!=null && semanticContext!=SemanticContext.EMPTY_SEMANTIC_CONTEXT ) { buf.append("|"); String escQuote = Utils.replace(semanticContext.toString(), "\"", "\\\""); buf.append(escQuote); } if ( resolved ) { buf.append("|resolved"); } if ( resolveWithPredicate ) { buf.append("|resolveWithPredicate"); } return buf.toString(); } }
/** Fix edge strings so they print out in DOT properly; * generate any gated predicates on edge too. */ protected String getEdgeLabel(Transition edge) { String label = edge.label.toString(grammar); label = Utils.replace(label,"\\", "\\\\"); label = Utils.replace(label,"\"", "\\\""); label = Utils.replace(label,"\n", "\\\\n"); label = Utils.replace(label,"\r", ""); if ( label.equals(Label.EPSILON_STR) ) { label = "e"; } State target = edge.target; if ( !edge.isSemanticPredicate() && target instanceof DFAState ) { // look for gated predicates; don't add gated to simple sempred edges SemanticContext preds = ((DFAState)target).getGatedPredicatesInNFAConfigurations(); if ( preds!=null ) { String predsStr = ""; predsStr = "&&{"+ preds.genExpr(grammar.generator, grammar.generator.getTemplates(), null).toString() +"}?"; label += predsStr; } } return label; }
/** Fix edge strings so they print out in DOT properly; * generate any gated predicates on edge too. */ protected String getEdgeLabel(Transition edge) { String label = edge.label.toString(grammar); label = Utils.replace(label,"\\", "\\\\"); label = Utils.replace(label,"\"", "\\\""); label = Utils.replace(label,"\n", "\\\\n"); label = Utils.replace(label,"\r", ""); if ( label.equals(Label.EPSILON_STR) ) { label = "e"; } State target = edge.target; if ( !edge.isSemanticPredicate() && target instanceof DFAState ) { // look for gated predicates; don't add gated to simple sempred edges SemanticContext preds = ((DFAState)target).getGatedPredicatesInNFAConfigurations(); if ( preds!=null ) { String predsStr = ""; predsStr = "&&{"+ preds.genExpr(grammar.generator, grammar.generator.getTemplates(), null).toString() +"}?"; label += predsStr; } } return label; }
/** Fix edge strings so they print out in DOT properly; * generate any gated predicates on edge too. */ protected String getEdgeLabel(Transition edge) { String label = edge.label.toString(grammar); label = Utils.replace(label,"\\", "\\\\"); label = Utils.replace(label,"\"", "\\\""); label = Utils.replace(label,"\n", "\\\\n"); label = Utils.replace(label,"\r", ""); if ( label.equals(Label.EPSILON_STR) ) { label = "e"; } State target = edge.target; if ( !edge.isSemanticPredicate() && target instanceof DFAState ) { // look for gated predicates; don't add gated to simple sempred edges SemanticContext preds = ((DFAState)target).getGatedPredicatesInNFAConfigurations(); if ( preds!=null ) { String predsStr; predsStr = "&&{"+ preds.genExpr(grammar.generator, grammar.generator.getTemplates(), null).render() +"}?"; label += predsStr; } } return label; }
/** Fix edge strings so they print out in DOT properly; * generate any gated predicates on edge too. */ protected String getEdgeLabel(Transition edge) { String label = edge.label.toString(grammar); label = Utils.replace(label,"\\", "\\\\"); label = Utils.replace(label,"\"", "\\\""); label = Utils.replace(label,"\n", "\\\\n"); label = Utils.replace(label,"\r", ""); if ( label.equals(Label.EPSILON_STR) ) { label = "e"; } State target = edge.target; if ( !edge.isSemanticPredicate() && target instanceof DFAState ) { // look for gated predicates; don't add gated to simple sempred edges SemanticContext preds = ((DFAState)target).getGatedPredicatesInNFAConfigurations(); if ( preds!=null ) { String predsStr; predsStr = "&&{"+ preds.genExpr(grammar.generator, grammar.generator.getTemplates(), null).render() +"}?"; label += predsStr; } } return label; }