Merge branch 'master' into move-doc-to-repo

This commit is contained in:
Terence Parr 2015-10-27 10:53:45 -07:00
commit 8aac8e7157
8 changed files with 38 additions and 16 deletions

View File

@ -77,5 +77,8 @@ YYYY/MM/DD, github id, Full name, email
2015/06/29, jvanzyl, Jason van Zyl, jason@takari.io
2015/08/18, krzkaczor, Krzysztof Kaczor, krzysztof@kaczor.io
2015/09/18, worsht, Rajiv Subrahmanyam, rajiv.public@gmail.com
2015/09/24, HSorensen, Henrik Sorensen, henrik.b.sorensen@gmail.com
2015/10/06, brwml, Bryan Wilhelm, bryan.wilhelm@microsoft.com
2015/10/08, fedotovalex, Alex Fedotov, me@alexfedotov.com
2015/10/21, martin-probst, Martin Probst, martin-probst@web.de
2015/10/21, hkff, Walid Benghabrit, walid.benghabrit@mines-nantes.fr

View File

@ -260,6 +260,7 @@ BufferedTokenStream.prototype.setTokenSource = function(tokenSource) {
this.index = -1;
};
// Given a starting index, return the index of the next token on channel.
// Return i if tokens[i] is on channel. Return -1 if there are no tokens
// on channel between i and EOF.

View File

@ -322,7 +322,7 @@ Parser.prototype.compileParseTreePattern = function(pattern, patternRuleIndex, l
lexer = lexer || null;
if (lexer === null) {
if (this.getTokenStream() !== null) {
var tokenSource = this.getTokenStream().getTokenSource();
var tokenSource = this.getTokenStream().tokenSource;
if (tokenSource instanceof Lexer) {
lexer = tokenSource;
}

View File

@ -280,7 +280,7 @@ class Parser (Recognizer):
def compileParseTreePattern(self, pattern, patternRuleIndex, lexer = None):
if lexer is None:
if self.getTokenStream() is not None:
tokenSource = self.getTokenStream().getTokenSource()
tokenSource = self.getTokenStream().tokenSource
if isinstance( tokenSource, Lexer ):
lexer = tokenSource
if lexer is None:

View File

@ -287,7 +287,7 @@ class Parser (Recognizer):
def compileParseTreePattern(self, pattern:str, patternRuleIndex:int, lexer:Lexer = None):
if lexer is None:
if self.getTokenStream() is not None:
tokenSource = self.getTokenStream().getTokenSource()
tokenSource = self.getTokenStream().tokenSource
if isinstance( tokenSource, Lexer ):
lexer = tokenSource
if lexer is None:

View File

@ -168,7 +168,7 @@
* letter-or-digit is a character for which the method
* Character.isJavaIdentifierPart(int) returns true."
*/
grammar Java;
grammar JavaLR;
// starting point for parsing a java file
/* The annotations are separated out to make parsing faster, but must be associated with

View File

@ -153,7 +153,7 @@ public class TestPerformance extends BaseTest {
/**
* {@code true} to use the Java grammar with expressions in the v4
* left-recursive syntax (Java-LR.g4). {@code false} to use the standard
* left-recursive syntax (JavaLR.g4). {@code false} to use the standard
* grammar (Java.g4). In either case, the grammar is renamed in the
* temporary directory to Java.g4 before compiling.
*/
@ -415,10 +415,10 @@ public class TestPerformance extends BaseTest {
assertTrue("The JDK_SOURCE_ROOT environment variable must be set for performance testing.", jdkSourceRoot != null && !jdkSourceRoot.isEmpty());
compileJavaParser(USE_LR_GRAMMAR);
final String lexerName = "JavaLexer";
final String parserName = "JavaParser";
final String listenerName = "JavaBaseListener";
final String entryPoint = "compilationUnit";
final String lexerName = USE_LR_GRAMMAR ? "JavaLRLexer" : "JavaLexer";
final String parserName = USE_LR_GRAMMAR ? "JavaLRParser" : "JavaParser";
final String listenerName = USE_LR_GRAMMAR ? "JavaLRBaseListener" : "JavaBaseListener";
final String entryPoint = "compilationUnit";
final ParserFactory factory = getParserFactory(lexerName, parserName, listenerName, entryPoint);
if (!TOP_PACKAGE.isEmpty()) {
@ -1108,9 +1108,10 @@ public class TestPerformance extends BaseTest {
}
protected void compileJavaParser(boolean leftRecursive) throws IOException {
String grammarFileName = "Java.g4";
String sourceName = leftRecursive ? "Java-LR.g4" : "Java.g4";
String body = load(sourceName, null);
String grammarFileName = leftRecursive ? "JavaLR.g4" : "Java.g4";
String parserName = leftRecursive ? "JavaLRParser" : "JavaParser";
String lexerName = leftRecursive ? "JavaLRLexer" : "JavaLexer";
String body = load(grammarFileName, null);
List<String> extraOptions = new ArrayList<String>();
extraOptions.add("-Werror");
if (FORCE_ATN) {
@ -1127,7 +1128,7 @@ public class TestPerformance extends BaseTest {
}
extraOptions.add("-visitor");
String[] extraOptionsArray = extraOptions.toArray(new String[extraOptions.size()]);
boolean success = rawGenerateAndBuildRecognizer(grammarFileName, body, "JavaParser", "JavaLexer", true, extraOptionsArray);
boolean success = rawGenerateAndBuildRecognizer(grammarFileName, body, parserName, lexerName, true, extraOptionsArray);
assertTrue(success);
}

View File

@ -119,13 +119,23 @@ using ParserRuleContext = Antlr4.Runtime.ParserRuleContext;
public partial class <file.grammarName>BaseListener : I<file.grammarName>Listener {
<file.listenerNames:{lname |
/// \<summary>
/// Enter a parse tree produced by \<see cref="<csIdentifier.(file.parserName)>.<csIdentifier.(lname)>"/>.
<if(file.listenerLabelRuleNames.(lname))>
/// Enter a parse tree produced by the \<c><lname>\</c>
/// labeled alternative in \<see cref="<file.parserName>.<file.listenerLabelRuleNames.(lname)>"/>.
<else>
/// Enter a parse tree produced by \<see cref="<file.parserName>.<lname>"/>.
<endif>
/// \<para>The default implementation does nothing.\</para>
/// \</summary>
/// \<param name="context">The parse tree.\</param>
public virtual void Enter<lname; format="cap">([NotNull] <csIdentifier.(file.parserName)>.<lname; format="cap">Context context) { \}
/// \<summary>
/// Exit a parse tree produced by \<see cref="<csIdentifier.(file.parserName)>.<csIdentifier.(lname)>"/>.
<if(file.listenerLabelRuleNames.(lname))>
/// Exit a parse tree produced by the \<c><lname>\</c>
/// labeled alternative in \<see cref="<file.parserName>.<file.listenerLabelRuleNames.(lname)>"/>.
<else>
/// Exit a parse tree produced by \<see cref="<file.parserName>.<lname>"/>.
<endif>
/// \<para>The default implementation does nothing.\</para>
/// \</summary>
/// \<param name="context">The parse tree.\</param>
@ -207,7 +217,12 @@ using ParserRuleContext = Antlr4.Runtime.ParserRuleContext;
public partial class <file.grammarName>BaseVisitor\<Result> : AbstractParseTreeVisitor\<Result>, I<file.grammarName>Visitor\<Result> {
<file.visitorNames:{lname |
/// \<summary>
/// Visit a parse tree produced by \<see cref="<csIdentifier.(file.parserName)>.<csIdentifier.(lname)>"/>.
<if(file.visitorLabelRuleNames.(lname))>
/// Visit a parse tree produced by the \<c><lname>\</c>
/// labeled alternative in \<see cref="<file.parserName>.<file.visitorLabelRuleNames.(lname)>"/>.
<else>
/// Visit a parse tree produced by \<see cref="<file.parserName>.<lname>"/>.
<endif>
/// \<para>
/// The default implementation returns the result of calling \<see cref="AbstractParseTreeVisitor{Result\}.VisitChildren(IRuleNode)"/>
/// on \<paramref name="context"/>.
@ -241,6 +256,8 @@ fileHeader(grammarFileName, ANTLRVersion) ::= <<
#pragma warning disable 0219
// Missing XML comment for publicly visible type or member '...'
#pragma warning disable 1591
// Ambiguous reference in cref attribute
#pragma warning disable 419
>>