forked from jasder/antlr
Updated comments to indicate preference of .g4 over .g
This commit is contained in:
parent
cfcb2a1a55
commit
e5d7c27b09
|
@ -49,7 +49,7 @@ public class Interval {
|
|||
/** Interval objects are used readonly so share all with the
|
||||
* same single value a==b up to some max size. Use an array as a perfect hash.
|
||||
* Return shared object for 0..INTERVAL_POOL_MAX_VALUE or a new
|
||||
* Interval object with a..a in it. On Java.g, 218623 IntervalSets
|
||||
* Interval object with a..a in it. On Java.g4, 218623 IntervalSets
|
||||
* have a..a (set with 1 element).
|
||||
*/
|
||||
public static Interval of(int a, int b) {
|
||||
|
|
|
@ -7,7 +7,7 @@ import org.antlr.v4.runtime.atn.ParserATNSimulator;
|
|||
import java.io.File;
|
||||
|
||||
/** Parse a java file or directory of java files using the generated parser
|
||||
* ANTLR builds from java.g
|
||||
* ANTLR builds from java.g4
|
||||
*/
|
||||
class TestJava {
|
||||
public static long lexerTime = 0;
|
||||
|
|
|
@ -7,7 +7,7 @@ import org.antlr.v4.runtime.atn.ParserATNSimulator;
|
|||
import java.io.File;
|
||||
|
||||
/** Parse a java file or directory of java files using the generated parser
|
||||
* ANTLR builds from java.g
|
||||
* ANTLR builds from java.g4
|
||||
*/
|
||||
class TestYang {
|
||||
public static long lexerTime = 0;
|
||||
|
|
|
@ -471,13 +471,13 @@ public class Tool {
|
|||
* files. If the outputDir set by -o is not present it will be created.
|
||||
* The final filename is sensitive to the output directory and
|
||||
* the directory where the grammar file was found. If -o is /tmp
|
||||
* and the original grammar file was foo/t.g then output files
|
||||
* and the original grammar file was foo/t.g4 then output files
|
||||
* go in /tmp/foo.
|
||||
*
|
||||
* The output dir -o spec takes precedence if it's absolute.
|
||||
* E.g., if the grammar file dir is absolute the output dir is given
|
||||
* precendence. "-o /tmp /usr/lib/t.g" results in "/tmp/T.java" as
|
||||
* output (assuming t.g holds T.java).
|
||||
* precendence. "-o /tmp /usr/lib/t.g4" results in "/tmp/T.java" as
|
||||
* output (assuming t.g4 holds T.java).
|
||||
*
|
||||
* If no -o is specified, then just write to the directory where the
|
||||
* grammar file was found.
|
||||
|
@ -489,7 +489,7 @@ public class Tool {
|
|||
return new StringWriter();
|
||||
}
|
||||
// output directory is a function of where the grammar file lives
|
||||
// for subdir/T.g, you get subdir here. Well, depends on -o etc...
|
||||
// for subdir/T.g4, you get subdir here. Well, depends on -o etc...
|
||||
// But, if this is a .tokens file, then we force the output to
|
||||
// be the base output directory (or current directory if there is not a -o)
|
||||
//
|
||||
|
@ -555,9 +555,9 @@ public class Tool {
|
|||
fileDirectory = fileNameWithPath.substring(0, fileNameWithPath.lastIndexOf(File.separatorChar));
|
||||
}
|
||||
if ( haveOutputDir ) {
|
||||
// -o /tmp /var/lib/t.g => /tmp/T.java
|
||||
// -o subdir/output /usr/lib/t.g => subdir/output/T.java
|
||||
// -o . /usr/lib/t.g => ./T.java
|
||||
// -o /tmp /var/lib/t.g4 => /tmp/T.java
|
||||
// -o subdir/output /usr/lib/t.g4 => subdir/output/T.java
|
||||
// -o . /usr/lib/t.g4 => ./T.java
|
||||
if (fileDirectory != null &&
|
||||
(new File(fileDirectory).isAbsolute() ||
|
||||
fileDirectory.startsWith("~"))) { // isAbsolute doesn't count this :(
|
||||
|
@ -565,7 +565,7 @@ public class Tool {
|
|||
outputDir = new File(outputDirectory);
|
||||
}
|
||||
else {
|
||||
// -o /tmp subdir/t.g => /tmp/subdir/t.g
|
||||
// -o /tmp subdir/t.g4 => /tmp/subdir/t.g4
|
||||
if (fileDirectory != null) {
|
||||
outputDir = new File(outputDirectory, fileDirectory);
|
||||
}
|
||||
|
|
|
@ -257,7 +257,7 @@ public class CodeGenerator {
|
|||
}
|
||||
}
|
||||
|
||||
/** Generate TParser.java and TLexer.java from T.g if combined, else
|
||||
/** Generate TParser.java and TLexer.java from T.g4 if combined, else
|
||||
* just use T.java as output regardless of type.
|
||||
*/
|
||||
public String getRecognizerFileName() {
|
||||
|
|
|
@ -137,7 +137,7 @@ public class TokenVocabParser {
|
|||
}
|
||||
|
||||
/** Return a File descriptor for vocab file. Look in library or
|
||||
* in -o output path. antlr -o foo T.g U.g where U needs T.tokens
|
||||
* in -o output path. antlr -o foo T.g4 U.g4 where U needs T.tokens
|
||||
* won't work unless we look in foo too. If we do not find the
|
||||
* file in the lib directory then must assume that the .tokens file
|
||||
* is going to be generated as part of this build and we have defined
|
||||
|
|
|
@ -149,7 +149,7 @@ public enum ErrorType {
|
|||
|
||||
// Dependency sorting errors
|
||||
//
|
||||
/** t1.g -> t2.g -> t3.g ->t1.g */
|
||||
/** t1.g4 -> t2.g4 -> t3.g4 ->t1.g4 */
|
||||
CIRCULAR_DEPENDENCY(130, "your grammars contain a circular dependency and cannot be sorted into a valid build order", ErrorSeverity.ERROR),
|
||||
|
||||
// Simple informational messages
|
||||
|
|
|
@ -87,12 +87,12 @@ public class TestTopologicalSort extends BaseTest {
|
|||
@Test
|
||||
public void testSimpleTokenDependence() throws Exception {
|
||||
Graph g = new Graph();
|
||||
g.addEdge("Java.g", "MyJava.tokens"); // Java feeds off manual token file
|
||||
g.addEdge("Java.tokens", "Java.g");
|
||||
g.addEdge("Def.g", "Java.tokens"); // walkers feed off generated tokens
|
||||
g.addEdge("Ref.g", "Java.tokens");
|
||||
g.addEdge("Java.g4", "MyJava.tokens"); // Java feeds off manual token file
|
||||
g.addEdge("Java.tokens", "Java.g4");
|
||||
g.addEdge("Def.g4", "Java.tokens"); // walkers feed off generated tokens
|
||||
g.addEdge("Ref.g4", "Java.tokens");
|
||||
|
||||
String expecting = "[MyJava.tokens, Java.g, Java.tokens, Ref.g, Def.g]";
|
||||
String expecting = "[MyJava.tokens, Java.g4, Java.tokens, Ref.g4, Def.g4]";
|
||||
List nodes = g.sort();
|
||||
String result = nodes.toString();
|
||||
assertEquals(expecting, result);
|
||||
|
@ -101,12 +101,12 @@ public class TestTopologicalSort extends BaseTest {
|
|||
@Test
|
||||
public void testParserLexerCombo() throws Exception {
|
||||
Graph g = new Graph();
|
||||
g.addEdge("JavaLexer.tokens", "JavaLexer.g");
|
||||
g.addEdge("JavaParser.g", "JavaLexer.tokens");
|
||||
g.addEdge("Def.g", "JavaLexer.tokens");
|
||||
g.addEdge("Ref.g", "JavaLexer.tokens");
|
||||
g.addEdge("JavaLexer.tokens", "JavaLexer.g4");
|
||||
g.addEdge("JavaParser.g4", "JavaLexer.tokens");
|
||||
g.addEdge("Def.g4", "JavaLexer.tokens");
|
||||
g.addEdge("Ref.g4", "JavaLexer.tokens");
|
||||
|
||||
String expecting = "[JavaLexer.g, JavaLexer.tokens, JavaParser.g, Ref.g, Def.g]";
|
||||
String expecting = "[JavaLexer.g4, JavaLexer.tokens, JavaParser.g4, Ref.g4, Def.g4]";
|
||||
List nodes = g.sort();
|
||||
String result = nodes.toString();
|
||||
assertEquals(expecting, result);
|
||||
|
|
Loading…
Reference in New Issue