Categories:
Audio (13)
Biotech (29)
Bytecode (36)
Database (77)
Framework (7)
Game (7)
General (507)
Graphics (53)
I/O (35)
IDE (2)
JAR Tools (101)
JavaBeans (21)
JDBC (121)
JDK (426)
JSP (20)
Logging (108)
Mail (58)
Messaging (8)
Network (84)
PDF (97)
Report (7)
Scripting (84)
Security (32)
Server (121)
Servlet (26)
SOAP (24)
Testing (54)
Web (15)
XML (309)
Collections:
Other Resources:
ANTLR Tool Source Code
ANTLR is a powerful parser generator for multiple programming languages including Java.
ANTLR contains 2 major modules:
ANTLR Tool Source Code files are provided in the distribution packge (antlr4-4.10.1.zip). You can download them at ANTLR Website.
You can also browse the source code below:
✍: FYIcenter
⏎ org/antlr/v4/gui/Trees.java
/* * Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. * Use of this file is governed by the BSD 3-clause license that * can be found in the LICENSE.txt file in the project root. */ package org.antlr.v4.gui; import org.antlr.v4.runtime.Parser; import org.antlr.v4.runtime.misc.Utils; import org.antlr.v4.runtime.tree.Tree; import javax.print.PrintException; import javax.swing.*; import java.io.BufferedWriter; import java.io.FileWriter; import java.io.IOException; import java.util.Arrays; import java.util.List; import java.util.concurrent.Future; public class Trees { /** Call this method to view a parse tree in a dialog box visually. */ public static Future<JFrame> inspect(Tree t, List<String> ruleNames) { TreeViewer viewer = new TreeViewer(ruleNames, t); return viewer.open(); } /** Call this method to view a parse tree in a dialog box visually. */ public static Future<JFrame> inspect(Tree t, Parser parser) { List<String> ruleNames = parser != null ? Arrays.asList(parser.getRuleNames()) : null; return inspect(t, ruleNames); } /** Save this tree in a postscript file */ public static void save(Tree t, Parser parser, String fileName) throws IOException, PrintException { List<String> ruleNames = parser != null ? Arrays.asList(parser.getRuleNames()) : null; save(t, ruleNames, fileName); } /** Save this tree in a postscript file using a particular font name and size */ public static void save(Tree t, Parser parser, String fileName, String fontName, int fontSize) throws IOException { List<String> ruleNames = parser != null ? Arrays.asList(parser.getRuleNames()) : null; save(t, ruleNames, fileName, fontName, fontSize); } /** Save this tree in a postscript file */ public static void save(Tree t, List<String> ruleNames, String fileName) throws IOException, PrintException { writePS(t, ruleNames, fileName); } /** Save this tree in a postscript file using a particular font name and size */ public static void save(Tree t, List<String> ruleNames, String fileName, String fontName, int fontSize) throws IOException { writePS(t, ruleNames, fileName, fontName, fontSize); } public static String getPS(Tree t, List<String> ruleNames, String fontName, int fontSize) { TreePostScriptGenerator psgen = new TreePostScriptGenerator(ruleNames, t, fontName, fontSize); return psgen.getPS(); } public static String getPS(Tree t, List<String> ruleNames) { return getPS(t, ruleNames, "Helvetica", 11); } public static void writePS(Tree t, List<String> ruleNames, String fileName, String fontName, int fontSize) throws IOException { String ps = getPS(t, ruleNames, fontName, fontSize); FileWriter f = new FileWriter(fileName); BufferedWriter bw = new BufferedWriter(f); try { bw.write(ps); } finally { bw.close(); } } public static void writePS(Tree t, List<String> ruleNames, String fileName) throws IOException { writePS(t, ruleNames, fileName, "Helvetica", 11); } /** Print out a whole tree in LISP form. Arg nodeTextProvider is used on the * node payloads to get the text for the nodes. * * @since 4.5.1 */ public static String toStringTree(Tree t, TreeTextProvider nodeTextProvider) { if ( t==null ) return "null"; String s = Utils.escapeWhitespace(nodeTextProvider.getText(t), false); if ( t.getChildCount()==0 ) return s; StringBuilder buf = new StringBuilder(); buf.append("("); s = Utils.escapeWhitespace(nodeTextProvider.getText(t), false); buf.append(s); buf.append(' '); for (int i = 0; i<t.getChildCount(); i++) { if ( i>0 ) buf.append(' '); buf.append(toStringTree(t.getChild(i), nodeTextProvider)); } buf.append(")"); return buf.toString(); } private Trees() { } }
⏎ org/antlr/v4/gui/Trees.java
Or download all of them as a single archive file:
File name: antlr-tool-4.10.1-sources.jar File size: 347718 bytes Release date: 2022-04-15 Download
2022-04-24, 31970👍, 0💬
Popular Posts:
ASM is an all purpose Java bytecode manipulation and analysis framework. It can be used to modify ex...
The JDT project provides the tool plug-ins that implement a Java IDE supporting the development of a...
Saxon-HE (home edition) is an open source product available under the Mozilla Public License. It pro...
kernel.jar is a component in iText Java library to provide low-level functionalities. iText Java lib...
How to run "jarsigner" command from JDK tools.jar file? "jarsigner" command allows you to digitally ...