use of org.antlr.v4.runtime.misc.IntervalSet in project antlr4 by antlr.
the class UnicodeDataTemplateController method addEmojiPresentationPropertyCodesToCodePointRanges.
private static void addEmojiPresentationPropertyCodesToCodePointRanges(Map<String, IntervalSet> propertyCodePointRanges) {
UnicodeSet emojiDefaultUnicodeSet = new UnicodeSet("[[\\p{Emoji=Yes}]&[\\p{Emoji_Presentation=Yes}]]");
IntervalSet emojiDefaultIntervalSet = new IntervalSet();
addUnicodeSetToIntervalSet(emojiDefaultUnicodeSet, emojiDefaultIntervalSet);
propertyCodePointRanges.put("EmojiPresentation=EmojiDefault", emojiDefaultIntervalSet);
UnicodeSet textDefaultUnicodeSet = new UnicodeSet("[[\\p{Emoji=Yes}]&[\\p{Emoji_Presentation=No}]]");
IntervalSet textDefaultIntervalSet = new IntervalSet();
addUnicodeSetToIntervalSet(textDefaultUnicodeSet, textDefaultIntervalSet);
propertyCodePointRanges.put("EmojiPresentation=TextDefault", textDefaultIntervalSet);
UnicodeSet textUnicodeSet = new UnicodeSet("[\\p{Emoji=No}]");
IntervalSet textIntervalSet = new IntervalSet();
addUnicodeSetToIntervalSet(textUnicodeSet, textIntervalSet);
propertyCodePointRanges.put("EmojiPresentation=Text", textIntervalSet);
}
use of org.antlr.v4.runtime.misc.IntervalSet in project antlr4 by antlr.
the class CharSupport method getIntervalSetEscapedString.
public static String getIntervalSetEscapedString(IntervalSet intervalSet) {
StringBuilder buf = new StringBuilder();
Iterator<Interval> iter = intervalSet.getIntervals().iterator();
while (iter.hasNext()) {
Interval interval = iter.next();
buf.append(getRangeEscapedString(interval.a, interval.b));
if (iter.hasNext()) {
buf.append(" | ");
}
}
return buf.toString();
}
use of org.antlr.v4.runtime.misc.IntervalSet in project antlr4 by antlr.
the class CodeGenPipeline method process.
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(), idNode.getText());
}
}
// all templates are generated in memory to report the most complete
// error information possible, but actually writing output files stops
// after the first error is reported
int errorCount = g.tool.errMgr.getNumErrors();
if (g.isLexer()) {
if (gen.getTarget().needsHeader()) {
// Header file if needed.
ST lexer = gen.generateLexer(true);
if (g.tool.errMgr.getNumErrors() == errorCount) {
writeRecognizer(lexer, gen, true);
}
}
ST lexer = gen.generateLexer(false);
if (g.tool.errMgr.getNumErrors() == errorCount) {
writeRecognizer(lexer, gen, false);
}
} else {
if (gen.getTarget().needsHeader()) {
ST parser = gen.generateParser(true);
if (g.tool.errMgr.getNumErrors() == errorCount) {
writeRecognizer(parser, gen, true);
}
}
ST parser = gen.generateParser(false);
if (g.tool.errMgr.getNumErrors() == errorCount) {
writeRecognizer(parser, gen, false);
}
if (g.tool.gen_listener) {
if (gen.getTarget().needsHeader()) {
ST listener = gen.generateListener(true);
if (g.tool.errMgr.getNumErrors() == errorCount) {
gen.writeListener(listener, true);
}
}
ST listener = gen.generateListener(false);
if (g.tool.errMgr.getNumErrors() == errorCount) {
gen.writeListener(listener, false);
}
if (gen.getTarget().needsHeader()) {
ST baseListener = gen.generateBaseListener(true);
if (g.tool.errMgr.getNumErrors() == errorCount) {
gen.writeBaseListener(baseListener, true);
}
}
if (gen.getTarget().wantsBaseListener()) {
ST baseListener = gen.generateBaseListener(false);
if (g.tool.errMgr.getNumErrors() == errorCount) {
gen.writeBaseListener(baseListener, false);
}
}
}
if (g.tool.gen_visitor) {
if (gen.getTarget().needsHeader()) {
ST visitor = gen.generateVisitor(true);
if (g.tool.errMgr.getNumErrors() == errorCount) {
gen.writeVisitor(visitor, true);
}
}
ST visitor = gen.generateVisitor(false);
if (g.tool.errMgr.getNumErrors() == errorCount) {
gen.writeVisitor(visitor, false);
}
if (gen.getTarget().needsHeader()) {
ST baseVisitor = gen.generateBaseVisitor(true);
if (g.tool.errMgr.getNumErrors() == errorCount) {
gen.writeBaseVisitor(baseVisitor, true);
}
}
if (gen.getTarget().wantsBaseVisitor()) {
ST baseVisitor = gen.generateBaseVisitor(false);
if (g.tool.errMgr.getNumErrors() == errorCount) {
gen.writeBaseVisitor(baseVisitor, false);
}
}
}
}
gen.writeVocabFile();
}
Aggregations