Categories:
Audio (13)
Biotech (29)
Bytecode (36)
Database (77)
Framework (7)
Game (7)
General (507)
Graphics (53)
I/O (35)
IDE (2)
JAR Tools (102)
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 (322)
Collections:
Other Resources:
ANTLR Runtime Source Code
ANTLR is a powerful parser generator for multiple programming languages
including Java.
ANTLR contains 2 major modules:
ANTLR Runtime 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/runtime/misc/LogManager.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.runtime.misc;
import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
public class LogManager {
protected static class Record {
long timestamp;
StackTraceElement location;
String component;
String msg;
public Record() {
timestamp = System.currentTimeMillis();
location = new Throwable().getStackTrace()[0];
}
@Override
public String toString() {
StringBuilder buf = new StringBuilder();
buf.append(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:SSS").format(new Date(timestamp)));
buf.append(" ");
buf.append(component);
buf.append(" ");
buf.append(location.getFileName());
buf.append(":");
buf.append(location.getLineNumber());
buf.append(" ");
buf.append(msg);
return buf.toString();
}
}
protected List<Record> records;
public void log(String component, String msg) {
Record r = new Record();
r.component = component;
r.msg = msg;
if ( records==null ) {
records = new ArrayList<Record>();
}
records.add(r);
}
public void log(String msg) { log(null, msg); }
public void save(String filename) throws IOException {
FileWriter fw = new FileWriter(filename);
BufferedWriter bw = new BufferedWriter(fw);
try {
bw.write(toString());
}
finally {
bw.close();
}
}
public String save() throws IOException {
//String dir = System.getProperty("java.io.tmpdir");
String dir = ".";
String defaultFilename =
dir + "/antlr-" +
new SimpleDateFormat("yyyy-MM-dd-HH.mm.ss").format(new Date()) + ".log";
save(defaultFilename);
return defaultFilename;
}
@Override
public String toString() {
if ( records==null ) return "";
String nl = System.getProperty("line.separator");
StringBuilder buf = new StringBuilder();
for (Record r : records) {
buf.append(r);
buf.append(nl);
}
return buf.toString();
}
public static void main(String[] args) throws IOException {
LogManager mgr = new LogManager();
mgr.log("atn", "test msg");
mgr.log("dfa", "test msg 2");
System.out.println(mgr);
mgr.save();
}
}
⏎ org/antlr/v4/runtime/misc/LogManager.java
Or download all of them as a single archive file:
File name: antlr-runtime-4.10.1-sources.jar File size: 308953 bytes Release date: 2022-04-15 Download
⇐ What Is ANTLR Parser Generator
2018-10-21, ≈99🔥, 0💬
Popular Posts:
JDK 11 jdk.jdeps.jmod is the JMOD file for JDK 11 JDeps tool, which can be invoked by the "jdeps" co...
The Web Services Description Language for Java Toolkit (WSDL4J), Release 1.6.2, allows the creation,...
Apache Log4j IOStreams is a Log4j API extension that provides numerous classes from java.io that can...
What Is poi-scratchpad-5.2.3.jar ?poi-scratchpad-5.2.3.jar is one of the JAR files for Apache POI 5....
JDK 11 jdk.internal.opt.jmod is the JMOD file for JDK 11 Internal Opt module. JDK 11 Internal Opt mo...