From e5bdcccfc71f43dcca6ead811b836f301bdf5866 Mon Sep 17 00:00:00 2001 From: Sam Harwell Date: Sat, 19 Jan 2013 15:53:04 -0600 Subject: [PATCH 01/11] Updated Mojo name (antlr4) and default phase (generate-sources) --- .../src/main/java/org/antlr/mojo/antlr4/Antlr4Mojo.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/antlr4-maven-plugin/src/main/java/org/antlr/mojo/antlr4/Antlr4Mojo.java b/antlr4-maven-plugin/src/main/java/org/antlr/mojo/antlr4/Antlr4Mojo.java index 51d0c48dc..070f46a08 100644 --- a/antlr4-maven-plugin/src/main/java/org/antlr/mojo/antlr4/Antlr4Mojo.java +++ b/antlr4-maven-plugin/src/main/java/org/antlr/mojo/antlr4/Antlr4Mojo.java @@ -73,8 +73,8 @@ import java.util.Set; * @author Sam Harwell */ @Mojo( - name = "antlr", - defaultPhase = LifecyclePhase.PROCESS_SOURCES, + name = "antlr4", + defaultPhase = LifecyclePhase.GENERATE_SOURCES, requiresDependencyResolution = ResolutionScope.COMPILE, requiresProject = true) public class Antlr4Mojo extends AbstractMojo { From 087dea5e39693d7fef63a036321c437de0addcab Mon Sep 17 00:00:00 2001 From: Sam Harwell Date: Sat, 19 Jan 2013 15:53:40 -0600 Subject: [PATCH 02/11] Use project source encoding setting by default --- .../src/main/java/org/antlr/mojo/antlr4/Antlr4Mojo.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/antlr4-maven-plugin/src/main/java/org/antlr/mojo/antlr4/Antlr4Mojo.java b/antlr4-maven-plugin/src/main/java/org/antlr/mojo/antlr4/Antlr4Mojo.java index 070f46a08..e8c3a1ca0 100644 --- a/antlr4-maven-plugin/src/main/java/org/antlr/mojo/antlr4/Antlr4Mojo.java +++ b/antlr4-maven-plugin/src/main/java/org/antlr/mojo/antlr4/Antlr4Mojo.java @@ -93,7 +93,7 @@ public class Antlr4Mojo extends AbstractMojo { /** * specify grammar file encoding; e.g., euc-jp */ - @Parameter + @Parameter(property = "project.build.sourceEncoding") protected String encoding; /** From 8e738dad523388439fab49d3e831a75e74c19526 Mon Sep 17 00:00:00 2001 From: Sam Harwell Date: Sat, 19 Jan 2013 15:54:44 -0600 Subject: [PATCH 03/11] Do not require explicit setting of source and output directories --- .../src/main/java/org/antlr/mojo/antlr4/Antlr4Mojo.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/antlr4-maven-plugin/src/main/java/org/antlr/mojo/antlr4/Antlr4Mojo.java b/antlr4-maven-plugin/src/main/java/org/antlr/mojo/antlr4/Antlr4Mojo.java index e8c3a1ca0..88296ecb4 100644 --- a/antlr4-maven-plugin/src/main/java/org/antlr/mojo/antlr4/Antlr4Mojo.java +++ b/antlr4-maven-plugin/src/main/java/org/antlr/mojo/antlr4/Antlr4Mojo.java @@ -168,13 +168,13 @@ public class Antlr4Mojo extends AbstractMojo { /** * Specifies the ANTLR directory containing grammar files. */ - @Parameter(defaultValue = "${basedir}/src/main/antlr4", required = true) + @Parameter(defaultValue = "${basedir}/src/main/antlr4") private File sourceDirectory; /** * Specify output directory where the Java files are generated. */ - @Parameter(defaultValue = "${project.build.directory}/generated-sources/antlr4", required = true) + @Parameter(defaultValue = "${project.build.directory}/generated-sources/antlr4") private File outputDirectory; /** From 502f0802fac17f8ffd700a56b118fed08910e619 Mon Sep 17 00:00:00 2001 From: Sam Harwell Date: Sat, 19 Jan 2013 15:55:07 -0600 Subject: [PATCH 04/11] Updated Mojo documentation --- .../org/antlr/mojo/antlr4/Antlr4Mojo.java | 82 +++---- .../src/site/apt/examples/import.apt | 4 +- .../src/site/apt/examples/libraries.apt | 21 +- .../src/site/apt/examples/simple.apt | 12 +- antlr4-maven-plugin/src/site/apt/faq.apt.vm | 1 + antlr4-maven-plugin/src/site/apt/index.apt | 9 +- antlr4-maven-plugin/src/site/apt/usage.apt.vm | 226 ++++-------------- antlr4-maven-plugin/src/site/site.xml | 2 + 8 files changed, 104 insertions(+), 253 deletions(-) create mode 100644 antlr4-maven-plugin/src/site/apt/faq.apt.vm diff --git a/antlr4-maven-plugin/src/main/java/org/antlr/mojo/antlr4/Antlr4Mojo.java b/antlr4-maven-plugin/src/main/java/org/antlr/mojo/antlr4/Antlr4Mojo.java index 88296ecb4..a190b13bf 100644 --- a/antlr4-maven-plugin/src/main/java/org/antlr/mojo/antlr4/Antlr4Mojo.java +++ b/antlr4-maven-plugin/src/main/java/org/antlr/mojo/antlr4/Antlr4Mojo.java @@ -66,10 +66,9 @@ import java.util.Map; import java.util.Set; /** - * Goal that picks up all the ANTLR grammars in a project and moves those that - * are required for generation of the compilable sources into the location - * that we use to compile them, such as {@code target/generated-sources/antlr4}. - * + * Parses ANTLR 4 grammar files {@code *.g4} and transforms them into Java + * source files. + * * @author Sam Harwell */ @Mojo( @@ -84,8 +83,8 @@ public class Antlr4Mojo extends AbstractMojo { // /** - * If set to true then the ANTLR tool will generate a description of the atn - * for each rule in Dot format + * If set to true then the ANTLR tool will generate a description of the ATN + * for each rule in Dot format. */ @Parameter(property = "antlr4.atn", defaultValue = "false") protected boolean atn; @@ -97,25 +96,25 @@ public class Antlr4Mojo extends AbstractMojo { protected String encoding; /** - * generate parse tree listener (default) + * Generate parse tree listener interface and base class. */ @Parameter(property = "antlr4.listener", defaultValue = "true") protected boolean listener; /** - * generate parse tree visitor + * Generate parse tree visitor interface and base class. */ @Parameter(property = "antlr4.visitor", defaultValue = "false") protected boolean visitor; /** - * treat warnings as errors + * Treat warnings as errors. */ @Parameter(property = "antlr4.treatWarningsAsErrors", defaultValue = "false") protected boolean treatWarningsAsErrors; /** - * use the ATN simulator for all predictions + * Use the ATN simulator for all predictions. */ @Parameter(property = "antlr4.forceATN", defaultValue = "false") protected boolean forceATN; @@ -135,38 +134,37 @@ public class Antlr4Mojo extends AbstractMojo { protected List arguments; /* -------------------------------------------------------------------- - * The following are Maven specific parameters, rather than specificlly + * The following are Maven specific parameters, rather than specific * options that the ANTLR tool can use. */ - /** - * Provides an explicit list of all the grammars that should - * be included in the generate phase of the plugin. Note that the plugin - * is smart enough to realize that imported grammars should be included but - * not acted upon directly by the ANTLR Tool. - * - * Unless otherwise specified, the include list scans for and includes all - * files that end in ".g" in any directory beneath src/main/antlr4. Note that - * this version of the plugin looks for the directory antlr4 and not the directory - * antlr, so as to avoid clashes and confusion for projects that use both v3 and v4 grammars - * such as ANTLR itself. - */ + /** + * Provides an explicit list of all the grammars that should be included in + * the generate phase of the plugin. Note that the plugin is smart enough to + * realize that imported grammars should be included but not acted upon + * directly by the ANTLR Tool. + *

+ * A set of Ant-like inclusion patterns used to select files from the source + * directory for processing. By default, the pattern + * **/*.g4 is used to select grammar files. + */ @Parameter protected Set includes = new HashSet(); /** - * Provides an explicit list of any grammars that should be excluded from - * the generate phase of the plugin. Files listed here will not be sent for - * processing by the ANTLR tool. + * A set of Ant-like exclusion patterns used to prevent certain files from + * being processed. By default, this set is empty such that no files are + * excluded. */ @Parameter protected Set excludes = new HashSet(); /** + * The current Maven project. */ @Parameter(property = "project", required = true, readonly = true) protected MavenProject project; /** - * Specifies the ANTLR directory containing grammar files. + * The directory where the ANTLR grammar files ({@code *.g4}) are located. */ @Parameter(defaultValue = "${basedir}/src/main/antlr4") private File sourceDirectory; @@ -178,7 +176,7 @@ public class Antlr4Mojo extends AbstractMojo { private File outputDirectory; /** - * Specify location of grammars and tokens files. + * Specify location of imported grammars and tokens files. */ @Parameter(defaultValue = "${basedir}/src/main/antlr4/imports") private File libDirectory; @@ -207,42 +205,28 @@ public class Antlr4Mojo extends AbstractMojo { /** * The main entry point for this Mojo, it is responsible for converting * ANTLR 4.x grammars into the target language specified by the grammar. - * - * @throws MojoExecutionException When something is discovered such as a missing source - * @throws MojoFailureException When something really bad happens such as not being able to create the ANTLR Tool + * + * @throws MojoExecutionException if a configuration or grammar error causes + * the code generation process to fail + * @throws MojoFailureException if an instance of the ANTLR 4 {@link Tool} + * cannot be created */ @Override public void execute() throws MojoExecutionException, MojoFailureException { Log log = getLog(); - // Check to see if the user asked for debug information, then dump all the - // parameters we have picked up if they did. - // if (log.isDebugEnabled()) { - - // Excludes - // for (String e : excludes) { log.debug("ANTLR: Exclude: " + e); } - // Includes - // for (String e : includes) { log.debug("ANTLR: Include: " + e); } - // Output location - // log.debug("ANTLR: Output: " + outputDirectory); - - // Library directory - // log.debug("ANTLR: Library: " + libDirectory); - - // Flags - // } if (!sourceDirectory.isDirectory()) { @@ -363,7 +347,7 @@ public class Antlr4Mojo extends AbstractMojo { /** * * @param sourceDirectory - * @throws org.codehaus.plexus.compiler.util.scan.InclusionScanException + * @throws InclusionScanException */ @NotNull private List> processGrammarFiles(List args, File sourceDirectory) throws InclusionScanException { @@ -445,7 +429,7 @@ public class Antlr4Mojo extends AbstractMojo { * relative to the base of the output directory and reflect the input * organization of the grammar files. * - * @param sourceDirectory The source directory File object + * @param sourceDirectory The source directory {@link File} object * @param grammarFileName The full path to the input grammar file * @return The path to the grammar file relative to the source directory */ diff --git a/antlr4-maven-plugin/src/site/apt/examples/import.apt b/antlr4-maven-plugin/src/site/apt/examples/import.apt index 7e71ea913..4bdfd46ab 100644 --- a/antlr4-maven-plugin/src/site/apt/examples/import.apt +++ b/antlr4-maven-plugin/src/site/apt/examples/import.apt @@ -1,8 +1,8 @@ Imported Grammar Files In order to have the ANTLR plugin automatically locate and use grammars used - as imports in your main .g4 files, you need to place the imported grammar - files in the imports directory beneath the root directory of your grammar + as imports in your main <<<.g4>>> files, you need to place the imported grammar + files in the <<>> directory beneath the root directory of your grammar files (which is <<>> by default of course). For a default layout, place your import grammars in the directory: <<>> diff --git a/antlr4-maven-plugin/src/site/apt/examples/libraries.apt b/antlr4-maven-plugin/src/site/apt/examples/libraries.apt index 8a052242d..8b2477273 100644 --- a/antlr4-maven-plugin/src/site/apt/examples/libraries.apt +++ b/antlr4-maven-plugin/src/site/apt/examples/libraries.apt @@ -2,23 +2,23 @@ Libraries The introduction of the import directive in a grammar allows reuse of common grammar files as well as the ability to divide up functional components of large grammars. However it has - caused some confusion in regard to the fact that generated vocab files (<<>>) can also + caused some confusion in regard to the fact that generated vocabulary files (<<<*.tokens>>>) can also be searched for with the <<<>>> directive. This has confused two separate functions and imposes a structure upon the layout of your grammar files in certain cases. If you have grammars that both use the import - directive and also require the use of a vocab file then you will need to locate - the grammar that generates the .tokens file alongside the grammar that uses it. This + directive and also require the use of a vocabulary file then you will need to locate + the grammar that generates the <<<.tokens>>> file alongside the grammar that uses it. This is because you will need to use the <<<>>> directive to specify the - location of your imported grammars and ANTLR will not find any vocab files in + location of your imported grammars and ANTLR will not find any vocabulary files in this directory. - The .tokens files for any grammars are generated within the same output directory structure - as the .java files. So, whereever the .java files are generated, you will also find the .tokens - files. ANTLR looks for .tokens files in both the <<<>>> and the output directory - where it is placing the geenrated .java files. Hence when you locate the grammars that generate - .tokens files in the same source directory as the ones that use the .tokens files, then - the Maven plugin will find the expected .tokens files. + The <<<.tokens>>> files for any grammars are generated within the same output directory structure + as the <<<.java>>> files. So, wherever the <<<.java>>> files are generated, you will also find the <<<.tokens>>> + files. ANTLR looks for <<<.tokens>>> files in both the <<<>>> and the output directory + where it is placing the generated <<<.java>>> files. Hence when you locate the grammars that generate + <<<.tokens>>> files in the same source directory as the ones that use the <<<.tokens>>> files, then + the Maven plugin will find the expected <<<.tokens>>> files. The <<<>>> is specified like any other directory parameter in Maven. Here is an example: @@ -30,7 +30,6 @@ Libraries 4.0-SNAPSHOT - diff --git a/antlr4-maven-plugin/src/site/apt/examples/simple.apt b/antlr4-maven-plugin/src/site/apt/examples/simple.apt index aa5ef0469..3c3412ada 100644 --- a/antlr4-maven-plugin/src/site/apt/examples/simple.apt +++ b/antlr4-maven-plugin/src/site/apt/examples/simple.apt @@ -1,7 +1,7 @@ Simple configuration If your grammar files are organized into the default locations as described in the {{{../index.html}introduction}}, - then configuring the pom.xml file for your project is as simple as adding this to it + then configuring the <<>> file for your project is as simple as adding this to it +-- @@ -21,12 +21,12 @@ Simple configuration +-- - When the mvn command is executed all grammar files under <<>>, except any + When the <<>> command is executed all grammar files under <<>>, except any import grammars under <<>> will be analyzed and converted to - java source code in the output directory <<>>. + Java source code in the output directory <<>>. Your input files under <<>> should be stored in sub directories that - reflect the package structure of your java parsers. If your grammar file parser.g4 contains: + reflect the package structure of your java parsers. If your grammar file <<>> contains: +--- @header { @@ -34,7 +34,7 @@ package org.jimi.themuss; } +--- - Then the .g4 file should be stored in: <<>>. THis way - the generated .java files will correctly reflect the package structure in which they will + Then the <<<.g4>>> file should be stored in: <<>>. This way + the generated <<<.java>>> files will correctly reflect the package structure in which they will finally rest as classes. diff --git a/antlr4-maven-plugin/src/site/apt/faq.apt.vm b/antlr4-maven-plugin/src/site/apt/faq.apt.vm new file mode 100644 index 000000000..d6360a1c1 --- /dev/null +++ b/antlr4-maven-plugin/src/site/apt/faq.apt.vm @@ -0,0 +1 @@ +FAQ diff --git a/antlr4-maven-plugin/src/site/apt/index.apt b/antlr4-maven-plugin/src/site/apt/index.apt index f954e5a3a..cfbfaf293 100644 --- a/antlr4-maven-plugin/src/site/apt/index.apt +++ b/antlr4-maven-plugin/src/site/apt/index.apt @@ -28,7 +28,7 @@ ANTLR v4 Maven plugin use version 4.0 of the plugin, you will build your grammars using version 4.0 of the ANTLR tool, version 4.2 of the plugin will use version 4.2 of the ANTLR tool and so on. - You may also find that there are patch versions of the plugin suchas 4.0-1 4.0-2 and + You may also find that there are patch versions of the plugin such as 4.0-1 4.0-2 and so on. Use the latest patch release of the plugin. The current version of the plugin is shown at the top of this page after the <> date. @@ -49,10 +49,10 @@ ANTLR v4 Maven plugin +--- imports/ .g4 files that are imported by other grammars. +-- - If your grammar is intended to be part of a package called org.foo.bar then you would + If your grammar is intended to be part of a package called <<>> then you would place it in the directory <<>>. The plugin will then produce - .java and .tokens files in the output directory <<>> - When the Java files are compiled they will be in the correct location for the javac + <<<.java>>> and <<<.tokens>>> files in the output directory <<>> + When the Java files are compiled they will be in the correct location for the Javac compiler without any special configuration. The generated java files are automatically submitted for compilation by the plugin. @@ -60,4 +60,3 @@ ANTLR v4 Maven plugin any grammar files that are imported by other grammar files (do not make subdirectories here.) Such files are never built on their own, but the plugin will automatically tell the ANTLR tool to look in this directory for library files. - diff --git a/antlr4-maven-plugin/src/site/apt/usage.apt.vm b/antlr4-maven-plugin/src/site/apt/usage.apt.vm index cff53a01d..e3f41d672 100644 --- a/antlr4-maven-plugin/src/site/apt/usage.apt.vm +++ b/antlr4-maven-plugin/src/site/apt/usage.apt.vm @@ -1,193 +1,59 @@ Usage - The Maven plugin for antlr is simple to use but is at its simplest when you use the default - layouts for your grammars, as so: + The ANTLR 4 plugin for Maven can generate parsers for any number of grammars in + your project. + +* Compiling Grammars into Parsers + + By default, the <<<{{{./antlr-mojo.html}antlr}}>>> goal will search for grammar + files in the directory <<<$\{basedir\}/src/main/antlr4>>> and any additional + <<<.tokens>>> files in the directory <<<$\{basedir\}/src/main/antlr4/imports>>>. + This can be configured to search other directories using the plugin configuration + parameters as described in the <<<{{{./antlr-mojo.html}antlr}}>>> goal + documentation. + + The following figure shows the expected layout of files for the default + configuration of this plugin. +-- src/main/ | - +--- antlr4/... .g4 files organized in the required package structure + +--- antlr4/... .g4 files organized in the required package structure | - +--- imports/ .g4 files that are imported by other grammars. + +--- imports/ user-created .tokens files and .g4 files that are imported by other grammars +-- - However, if you are not able to use this structure for whatever reason, you - can configure the locations of the grammar files, where library/import files - are located and where the output files should be generated. - -* Plugin Descriptor - - The current version of the plugin is shown at the top of this page after the <> date. - - The full layout of the descriptor (at least, those parts that are not standard Maven things), - showing the default values of the configuration options, is as follows: + The next step is to configure your POM to call the plugin. The goals will + normally run during the generate-sources phase of the build. Examples of how to + configure your POM can be found on the various examples pages, reachable via + the page menu. If you stick with the default values, the snippet below will + suffice: +-- - - org.antlr - antlr4-maven-plugin - 4.0-SNAPSHOT - - - - - - - antlr - - 10000 - false - false - false - - - src/main/antlr4/imports - antlr - target/generated-sources/antlr4 - false - false - false - src/main/antlr4 - false - true - - - - - + + ... + + + + org.antlr + antlr4-maven-plugin + ${project.version} + + + antlr + + antlr + + + + + + ... + + ... + +-- - Note that you can create multiple executions, and thus build some grammars with different - options to others (such as setting the debug option for instance). - -** Configuration parameters - -*** report - - If set to true, then after the tool has processed an input grammar file - it will report variaous statistics about the parser, such as information - on cyclic DFAs, which rules may use backtracking, and so on. - - default-value="false" - -*** printGrammar - - If set to true, then the ANTLR tool will print a version of the input - grammar which is devoid of any actions that may be present in the input file. - - default-value = "false" - -*** debug - - If set to true, then the code generated by the ANTLR code generator will - be set to debug mode. This means that when run, the code will 'hang' and - wait for a debug connection on a TCP port (49100 by default). - - default-value="false" - -*** profile - - If set to true, then then the generated parser will compute and report on - profile information at runtime. - - default-value="false" - -*** nfa - - If set to true then the ANTLR tool will generate a description of the nfa - for each rule in Dot format - - default-value="false" - - protected boolean nfa; - -*** dfa - - If set to true then the ANTLR tool will generate a description of the DFA - for each decision in the grammar in Dot format - - default-value="false" - -*** trace - - If set to true, the generated parser code will log rule entry and exit points - to stdout as an aid to debugging. - - default-value="false" - -*** messageFormat - - If this parameter is set, it indicates that any warning or error messages returned - by ANLTR, shoould be formatted in the specified way. Currently, ANTLR supports the - built-in formats of antlr, gnu and vs2005. - - default-value="antlr" - -*** verbose - - If this parameter is set to true, then ANTLR will report all sorts of things - about what it is doing such as the names of files and the version of ANTLR and so on. - - default-value="true" - -*** conversionTimeout - - The number of milliseconds ANTLR will wait for analysis of each - alternative in the grammar to complete before giving up. You may raise - this value if ANTLR gives up on a complicated alt and tells you that - there are lots of ambiguties, but you know that it just needed to spend - more time on it. Note that this is an absolute time and not CPU time. - - default-value="10000" - -*** includes - - Provides an explicit list of all the grammars that should - be included in the generate phase of the plugin. Note that the plugin - is smart enough to realize that imported grammars should be included but - not acted upon directly by the ANTLR Tool. - - Unless otherwise specified, the include list scans for and includes all - files that end in ".g4" in any directory beneath src/main/antlr4. Note that - this version of the plugin looks for the directory antlr4 and not the directory - antlr, so as to avoid clashes and confusion for projects that use both v3 and v4 grammars - such as ANTLR itself. - -*** excludes - - Provides an explicit list of any grammars that should be excluded from - the generate phase of the plugin. Files listed here will not be sent for - processing by the ANTLR tool. - -*** sourceDirectory - - Specifies the Antlr directory containing grammar files. For - antlr version 4.x we default this to a directory in the tree - called antlr4 because the antlr directory is occupied by version - 2.x grammars. - - <> Take careful note that the default location for antlr grammars - is now <> and NOT <> - - default-value="<<<${basedir}/src/main/antlr4>>>" - -*** outputDirectory - - Location for generated Java files. For antlr version 4.x we default - this to a directory in the tree called antlr4 because the antlr - directory is occupied by version 2.x grammars. - - default-value="<<<${project.build.directory}/generated-sources/antlr4>>>" - -*** libDirectory - - Location for imported token files, e.g. .tokens and imported grammars. - Note that ANTLR will not try to process grammars that it finds in this directory, but - will include this directory in the search for .tokens files and import grammars. - - <> If you change the lib directory from the default but the directory is - still under<<<${basedir}/src/main/antlr4>>>, then you will need to exclude - the grammars from processing specifically, using the <<<>>> option. - - default-value="<<<${basedir}/src/main/antlr4/imports>>>" - + Note that you can create multiple executions, and thus build some grammars with + different options to others (such as setting the <<>> option for + instance). diff --git a/antlr4-maven-plugin/src/site/site.xml b/antlr4-maven-plugin/src/site/site.xml index 96467c1a3..0cf1aa278 100644 --- a/antlr4-maven-plugin/src/site/site.xml +++ b/antlr4-maven-plugin/src/site/site.xml @@ -17,7 +17,9 @@

+ + From fc9a0fe96b81e68f845b183f2795f8c4dcb6b777 Mon Sep 17 00:00:00 2001 From: Sam Harwell Date: Sat, 19 Jan 2013 15:56:07 -0600 Subject: [PATCH 05/11] Set inceptionYear, organization, and mailingLists; fix scm url --- pom.xml | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 55eb4113d..bdc318091 100644 --- a/pom.xml +++ b/pom.xml @@ -16,6 +16,11 @@ ANTLR 4 ANTLR 4 Master Build POM http://www.antlr.org + 1992 + + ANTLR + http://www.antlr.org + @@ -63,13 +68,20 @@ true + + + antlr-discussion + https://groups.google.com/forum/?fromgroups#!forum/antlr-discussion + + + GitHub Issues https://github.com/antlr/antlr4/issues - git://github.com/antlr/antlr4.git + https://github.com/antlr/antlr4/tree/master scm:git:git://github.com/antlr/antlr4.git scm:git:git@github.com:antlr/antlr4.git From 2e693dc1695659ec3960edb478e1cb91ce6f02b7 Mon Sep 17 00:00:00 2001 From: Sam Harwell Date: Sat, 19 Jan 2013 15:56:38 -0600 Subject: [PATCH 06/11] Fix url, specify reporting plugins --- antlr4-maven-plugin/pom.xml | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/antlr4-maven-plugin/pom.xml b/antlr4-maven-plugin/pom.xml index a74429bbd..9188b2f8d 100644 --- a/antlr4-maven-plugin/pom.xml +++ b/antlr4-maven-plugin/pom.xml @@ -49,6 +49,7 @@ ANTLR 4 Maven plugin Maven plugin for ANTLR 4 grammars + http://www.antlr.org 3.0 @@ -179,4 +180,22 @@ + + + + org.apache.maven.plugins + maven-javadoc-plugin + 2.9 + + true + + + + + org.apache.maven.plugins + maven-jxr-plugin + 2.3 + + + From 0054cc020a30c11eba5197ffb518412377da13cb Mon Sep 17 00:00:00 2001 From: Sam Harwell Date: Mon, 21 Jan 2013 06:39:32 -0600 Subject: [PATCH 07/11] Prediction context documentation including graphs --- .../atn/images/ArrayMerge_DiffTopDiffPar.dot | 77 ++++++++++ .../atn/images/ArrayMerge_EqualTop.dot | 72 +++++++++ .../atn/images/ArrayMerge_ShareTopDiffPar.dot | 83 +++++++++++ .../atn/images/ArrayMerge_ShareTopSamePar.dot | 75 ++++++++++ .../images/ArrayMerge_ShareTopSharePar.dot | 87 +++++++++++ .../atn/images/FullMerge_EmptyRoot.dot | 46 ++++++ .../atn/images/FullMerge_EmptyRoots.dot | 27 ++++ .../runtime/atn/images/FullMerge_SameRoot.dot | 52 +++++++ .../atn/images/LocalMerge_DiffRoots.dot | 39 +++++ .../atn/images/LocalMerge_EmptyParent.dot | 38 +++++ .../atn/images/LocalMerge_EmptyRoot.dot | 27 ++++ .../images/SingletonMerge_DiffRootDiffPar.dot | 40 +++++ .../images/SingletonMerge_DiffRootSamePar.dot | 39 +++++ .../images/SingletonMerge_SameRootDiffPar.dot | 54 +++++++ .../images/SingletonMerge_SameRootSamePar.dot | 38 +++++ .../v4/runtime/atn/PredictionContext.java | 138 ++++++++++++++++-- 16 files changed, 922 insertions(+), 10 deletions(-) create mode 100644 runtime/Java/src/main/dot/org/antlr/v4/runtime/atn/images/ArrayMerge_DiffTopDiffPar.dot create mode 100644 runtime/Java/src/main/dot/org/antlr/v4/runtime/atn/images/ArrayMerge_EqualTop.dot create mode 100644 runtime/Java/src/main/dot/org/antlr/v4/runtime/atn/images/ArrayMerge_ShareTopDiffPar.dot create mode 100644 runtime/Java/src/main/dot/org/antlr/v4/runtime/atn/images/ArrayMerge_ShareTopSamePar.dot create mode 100644 runtime/Java/src/main/dot/org/antlr/v4/runtime/atn/images/ArrayMerge_ShareTopSharePar.dot create mode 100644 runtime/Java/src/main/dot/org/antlr/v4/runtime/atn/images/FullMerge_EmptyRoot.dot create mode 100644 runtime/Java/src/main/dot/org/antlr/v4/runtime/atn/images/FullMerge_EmptyRoots.dot create mode 100644 runtime/Java/src/main/dot/org/antlr/v4/runtime/atn/images/FullMerge_SameRoot.dot create mode 100644 runtime/Java/src/main/dot/org/antlr/v4/runtime/atn/images/LocalMerge_DiffRoots.dot create mode 100644 runtime/Java/src/main/dot/org/antlr/v4/runtime/atn/images/LocalMerge_EmptyParent.dot create mode 100644 runtime/Java/src/main/dot/org/antlr/v4/runtime/atn/images/LocalMerge_EmptyRoot.dot create mode 100644 runtime/Java/src/main/dot/org/antlr/v4/runtime/atn/images/SingletonMerge_DiffRootDiffPar.dot create mode 100644 runtime/Java/src/main/dot/org/antlr/v4/runtime/atn/images/SingletonMerge_DiffRootSamePar.dot create mode 100644 runtime/Java/src/main/dot/org/antlr/v4/runtime/atn/images/SingletonMerge_SameRootDiffPar.dot create mode 100644 runtime/Java/src/main/dot/org/antlr/v4/runtime/atn/images/SingletonMerge_SameRootSamePar.dot diff --git a/runtime/Java/src/main/dot/org/antlr/v4/runtime/atn/images/ArrayMerge_DiffTopDiffPar.dot b/runtime/Java/src/main/dot/org/antlr/v4/runtime/atn/images/ArrayMerge_DiffTopDiffPar.dot new file mode 100644 index 000000000..68948fe48 --- /dev/null +++ b/runtime/Java/src/main/dot/org/antlr/v4/runtime/atn/images/ArrayMerge_DiffTopDiffPar.dot @@ -0,0 +1,77 @@ +digraph "" { + graph[dpi="60";compound="true"]; + + subgraph clusterA { + label=""; + color="invis"; + { rank="same"; + node[shape="invtriangle";margin="0.01,0.01"]; + A_u1[label="u"]; + A_v1[label="v"]; + } + + A_left[shape="record";label="{ | a} | { | b}"]; + + { edge[dir="back"]; + A_u1:s -> A_left:a:n; + A_v1:s -> A_left:b:n; + } + } + + subgraph AB { + temp0[color="invis";shape="point";label=""]; + temp1[shape="none";label="+"]; + temp0 -> temp1[style="invisible";dir="none"]; + } + + subgraph clusterB { + label=""; + color="invis"; + { rank="same"; + node[shape="invtriangle";margin="0.01,0.01"]; + A_w1[label="w"]; + A_x1[label="x"]; + } + + A_right[shape="record";label="{ | c} | { | d}"]; + + { edge[dir="back"]; + A_w1:s -> A_right:c:n; + A_x1:s -> A_right:d:n; + } + } + + subgraph BC { + node[color="invis";shape="point"]; + temp2a; + { rank="same"; + temp2b; + temp2c; + } + + temp2a -> temp2b[style="invisible";dir="none"]; + temp2a -> temp2c[style="invisible";dir="none"]; + temp2b -> temp2c[constraint="false";label="wwwwwww"]; + } + + subgraph clusterC { + label=""; + color="invis"; + { rank="same"; + node[shape="invtriangle";margin="0.01,0.01"]; + A_u2[label="u"]; + A_v2[label="v"]; + A_w2[label="w"]; + A_x2[label="x"]; + } + + A_result[shape="record";label="{ | a} | { | b} | { | c} | { | d}"]; + + { edge[dir="back"]; + A_u2:s -> A_result:a:n; + A_v2:s -> A_result:b:n; + A_w2:s -> A_result:c:n; + A_x2:s -> A_result:d:n; + } + } +} diff --git a/runtime/Java/src/main/dot/org/antlr/v4/runtime/atn/images/ArrayMerge_EqualTop.dot b/runtime/Java/src/main/dot/org/antlr/v4/runtime/atn/images/ArrayMerge_EqualTop.dot new file mode 100644 index 000000000..3ae341b2c --- /dev/null +++ b/runtime/Java/src/main/dot/org/antlr/v4/runtime/atn/images/ArrayMerge_EqualTop.dot @@ -0,0 +1,72 @@ +digraph "" { + graph[dpi="60";compound="true"]; + + subgraph clusterA { + label=""; + color="invis"; + { rank="same"; + node[shape="invtriangle";margin="0.01,0.01"]; + A_u1[label="x"]; + } + + A_left[shape="record";label="{ | a}"]; + + { edge[dir="back"]; + A_u1:s -> A_left:a:n; + } + } + + subgraph AB { + temp0[color="invis";shape="point";label=""]; + temp1[shape="none";label="+"]; + temp0 -> temp1[style="invisible";dir="none"]; + } + + subgraph clusterB { + label=""; + color="invis"; + { rank="same"; + node[shape="invtriangle";margin="0.01,0.01"]; + A_w1[label="y"]; + } + + A_right[shape="record";label="{ | a}"]; + + { edge[dir="back"]; + A_w1:s -> A_right:a:n; + } + } + + subgraph BC { + node[color="invis";shape="point"]; + temp2a; + { rank="same"; + temp2b; + temp2c; + } + + temp2a -> temp2b[style="invisible";dir="none"]; + temp2a -> temp2c[style="invisible";dir="none"]; + temp2b -> temp2c[constraint="false";label="wwwwwww"]; + } + + subgraph clusterC { + label=""; + color="invis"; + { rank="same"; + node[shape="invtriangle";margin="0.01,0.01"]; + A_u2[label=""]; + A_v2[label=""]; + } + + A_result[shape="record";label="{ | x} | { | y}"]; + + A_ap[label="a'";shape="none"]; + + { edge[dir="back"]; + A_u2:s -> A_result:x:n; + A_v2:s -> A_result:y:n; + A_result:s -> A_ap:n; + } + } +} diff --git a/runtime/Java/src/main/dot/org/antlr/v4/runtime/atn/images/ArrayMerge_ShareTopDiffPar.dot b/runtime/Java/src/main/dot/org/antlr/v4/runtime/atn/images/ArrayMerge_ShareTopDiffPar.dot new file mode 100644 index 000000000..87e494f1a --- /dev/null +++ b/runtime/Java/src/main/dot/org/antlr/v4/runtime/atn/images/ArrayMerge_ShareTopDiffPar.dot @@ -0,0 +1,83 @@ +digraph "" { + graph[dpi="60";compound="true"]; + + subgraph clusterA { + label=""; + color="invis"; + { rank="same"; + node[shape="invtriangle";margin="0.01,0.01"]; + A_u1[label="u"]; + A_v1[label="v"]; + } + + A_left[shape="record";label="{ | a} | { | b}"]; + + { edge[dir="back"]; + A_u1:s -> A_left:a:n; + A_v1:s -> A_left:b:n; + } + } + + subgraph AB { + temp0[color="invis";shape="point";label=""]; + temp1[shape="none";label="+"]; + temp0 -> temp1[style="invisible";dir="none"]; + } + + subgraph clusterB { + label=""; + color="invis"; + { rank="same"; + node[shape="invtriangle";margin="0.01,0.01"]; + A_w1[label="w"]; + A_x1[label="x"]; + } + + A_right[shape="record";label="{ | b} | { | d}"]; + + { edge[dir="back"]; + A_w1:s -> A_right:b:n; + A_x1:s -> A_right:d:n; + } + } + + subgraph BC { + node[color="invis";shape="point"]; + temp2a; + { rank="same"; + temp2b; + temp2c; + } + + temp2a -> temp2b[style="invisible";dir="none"]; + temp2a -> temp2c[style="invisible";dir="none"]; + temp2b -> temp2c[constraint="false";label="wwwwwww"]; + } + + subgraph clusterC { + label=""; + color="invis"; + { rank="same"; + node[shape="invtriangle";margin="0.01,0.01"]; + A_u2[label="u"]; + A_vw[shape="record";label="{ | v} | { | w}"]; + A_x2[label="x"]; + } + + { rank="same"; + node[shape="invtriangle";margin="0.01,0.01"]; + A_vp[label=""]; + A_wp[label=""]; + } + + A_result[shape="record";label="{ | a} | { | b'} | { | d}"]; + + { edge[dir="back"]; + A_u2:s -> A_result:a:n; + A_vw:s -> A_result:b:n; + A_x2:s -> A_result:d:n; + A_vp:s -> A_vw:v:n; + A_wp:s -> A_vw:w:n; + } + } +} diff --git a/runtime/Java/src/main/dot/org/antlr/v4/runtime/atn/images/ArrayMerge_ShareTopSamePar.dot b/runtime/Java/src/main/dot/org/antlr/v4/runtime/atn/images/ArrayMerge_ShareTopSamePar.dot new file mode 100644 index 000000000..638721aac --- /dev/null +++ b/runtime/Java/src/main/dot/org/antlr/v4/runtime/atn/images/ArrayMerge_ShareTopSamePar.dot @@ -0,0 +1,75 @@ +digraph "" { + graph[dpi="60";compound="true"]; + + subgraph clusterA { + label=""; + color="invis"; + { rank="same"; + node[shape="invtriangle";margin="0.01,0.01"]; + A_u1[label="u"]; + A_v1[label="v"]; + } + + A_left[shape="record";label="{ | a} | { | b}"]; + + { edge[dir="back"]; + A_u1:s -> A_left:a:n; + A_v1:s -> A_left:b:n; + } + } + + subgraph AB { + temp0[color="invis";shape="point";label=""]; + temp1[shape="none";label="+"]; + temp0 -> temp1[style="invisible";dir="none"]; + } + + subgraph clusterB { + label=""; + color="invis"; + { rank="same"; + node[shape="invtriangle";margin="0.01,0.01"]; + A_w1[label="v"]; + A_x1[label="x"]; + } + + A_right[shape="record";label="{ | b} | { | d}"]; + + { edge[dir="back"]; + A_w1:s -> A_right:b:n; + A_x1:s -> A_right:d:n; + } + } + + subgraph BC { + node[color="invis";shape="point"]; + temp2a; + { rank="same"; + temp2b; + temp2c; + } + + temp2a -> temp2b[style="invisible";dir="none"]; + temp2a -> temp2c[style="invisible";dir="none"]; + temp2b -> temp2c[constraint="false";label="wwwwwww"]; + } + + subgraph clusterC { + label=""; + color="invis"; + { rank="same"; + node[shape="invtriangle";margin="0.01,0.01"]; + A_u2[label="u"]; + A_v2[label="v"]; + A_x2[label="x"]; + } + + A_result[shape="record";label="{ | a} | { | b} | { | d}"]; + + { edge[dir="back"]; + A_u2:s -> A_result:a:n; + A_v2:s -> A_result:b:n; + A_x2:s -> A_result:d:n; + } + } +} diff --git a/runtime/Java/src/main/dot/org/antlr/v4/runtime/atn/images/ArrayMerge_ShareTopSharePar.dot b/runtime/Java/src/main/dot/org/antlr/v4/runtime/atn/images/ArrayMerge_ShareTopSharePar.dot new file mode 100644 index 000000000..8eb558fac --- /dev/null +++ b/runtime/Java/src/main/dot/org/antlr/v4/runtime/atn/images/ArrayMerge_ShareTopSharePar.dot @@ -0,0 +1,87 @@ +digraph "" { + graph[dpi="60";compound="true"]; + + subgraph clusterA { + label=""; + color="invis"; + { rank="same"; + node[shape="invtriangle";margin="0.01,0.01"]; + A_u1[label="u"]; + A_v1[label="v"]; + } + + A_left[shape="record";label="{ | a} | { | b}"]; + + { edge[dir="back"]; + A_u1:s -> A_left:a:n; + A_v1:s -> A_left:b:n; + } + } + + subgraph AB { + temp0[color="invis";shape="point";label=""]; + temp1[shape="none";label="+"]; + temp0 -> temp1[style="invisible";dir="none"]; + } + + subgraph clusterB { + label=""; + color="invis"; + { rank="same"; + node[shape="invtriangle";margin="0.01,0.01"]; + A_w1[label="v"]; + A_x1[label="u"]; + } + + A_right[shape="record";label="{ | b} | { | d}"]; + + { edge[dir="back"]; + A_w1:s -> A_right:b:n; + A_x1:s -> A_right:d:n; + } + } + + subgraph BC { + node[color="invis";shape="point"]; + temp2a; + { rank="same"; + temp2b; + temp2c; + } + + temp2a -> temp2b[style="invisible";dir="none"]; + temp2a -> temp2c[style="invisible";dir="none"]; + temp2b -> temp2c[constraint="false";label="wwwwwww"]; + } + + subgraph clusterC { + label=""; + color="invis"; + subgraph clusterSubC { + node[group="";shape="invtriangle";margin="0.01,0.01"]; + A_u2[label="u"]; + { rank="same"; + A_ut1[color="invis";shape="point";width="0.00000001"]; + A_v2[label="v"]; + A_ut2[color="invis";shape="point";width="0.00000001"]; + } + + A_ut1 -> A_v2 -> A_ut2[style="invisible",dir="none"]; + A_u2 -> A_v2[style="invisible",dir="none"]; + } + + A_result[shape="record";label="{ | a} | { | b} | { | d}"]; + + { edge[dir="back"]; + A_u2:sw -> A_ut1:n; + A_v2:s -> A_result:b:n; + A_u2:se -> A_ut2:n; + A_v2:s -> A_result:n[style="invisible",dir="none"]; + } + + { edge[dir="none";constraint="false"]; + A_ut1:s -> A_result:a:n; + A_ut2:s -> A_result:d:n; + } + } +} diff --git a/runtime/Java/src/main/dot/org/antlr/v4/runtime/atn/images/FullMerge_EmptyRoot.dot b/runtime/Java/src/main/dot/org/antlr/v4/runtime/atn/images/FullMerge_EmptyRoot.dot new file mode 100644 index 000000000..d740ef1a2 --- /dev/null +++ b/runtime/Java/src/main/dot/org/antlr/v4/runtime/atn/images/FullMerge_EmptyRoot.dot @@ -0,0 +1,46 @@ +digraph "" { + graph[dpi="60";compound="true"]; + + subgraph L { + node[shape="none"]; + lefttree[label=""]; + left[label="$"]; + + lefttree -> left[style="invisible";dir="none"]; + } + + subgraph AB { + optree[shape="none";label=""]; + temp1[shape="none";label="+"]; + + optree -> temp1[style="invisible";dir="none"]; + } + + subgraph R { + righttree[shape="none";label=""]; + right[shape="invtriangle";label="x"]; + + righttree -> right[style="invisible";dir="none"]; + } + + subgraph BC { + node[color="invis";shape="point"]; + temp2a; + { rank="same"; + temp2b; + temp2c; + } + + temp2a -> temp2b[style="invisible";dir="none"]; + temp2a -> temp2c[style="invisible";dir="none"]; + temp2b -> temp2c[constraint="false";label="wwwwwww"]; + } + + subgraph Res { + node[shape="none"]; + resulttree[shape="invtriangle";label=""]; + result[shape="record";label="{ | $} | { | x}"]; + + resulttree -> result:x:n[dir="back"]; + } +} diff --git a/runtime/Java/src/main/dot/org/antlr/v4/runtime/atn/images/FullMerge_EmptyRoots.dot b/runtime/Java/src/main/dot/org/antlr/v4/runtime/atn/images/FullMerge_EmptyRoots.dot new file mode 100644 index 000000000..b852f21de --- /dev/null +++ b/runtime/Java/src/main/dot/org/antlr/v4/runtime/atn/images/FullMerge_EmptyRoots.dot @@ -0,0 +1,27 @@ +digraph "" { + graph[dpi="60";compound="true"]; + + subgraph L { + left[shape="none";label="$"]; + } + + subgraph AB { + temp1[shape="none";label="+"]; + } + + subgraph R { + right[shape="none";label="$"]; + } + + subgraph BC { + node[color="invis";shape="point"]; + temp2b; + temp2c; + + temp2b -> temp2c[constraint="false";label="wwwwwww"]; + } + + subgraph Res { + result[shape="none";label="$"]; + } +} diff --git a/runtime/Java/src/main/dot/org/antlr/v4/runtime/atn/images/FullMerge_SameRoot.dot b/runtime/Java/src/main/dot/org/antlr/v4/runtime/atn/images/FullMerge_SameRoot.dot new file mode 100644 index 000000000..b95ccb47d --- /dev/null +++ b/runtime/Java/src/main/dot/org/antlr/v4/runtime/atn/images/FullMerge_SameRoot.dot @@ -0,0 +1,52 @@ +digraph "" { + graph[dpi="60";compound="true"]; + + subgraph L { + node[shape="none"]; + lefttree[label=""]; + left[label="$"]; + leftroot[label="a"]; + + lefttree -> left[style="invisible";dir="none"]; + left -> leftroot[dir="back"]; + } + + subgraph AB { + optree[shape="none";label=""]; + temp1[shape="none";label="+"]; + + optree -> temp1[style="invisible";dir="none"]; + } + + subgraph R { + righttree[shape="none";label=""]; + right[shape="invtriangle";label="x"]; + rightroot[shape="none";label="a"]; + + righttree -> right[style="invisible";dir="none"]; + right -> rightroot[dir="back"]; + } + + subgraph BC { + node[color="invis";shape="point"]; + temp2a; + { rank="same"; + temp2b; + temp2c; + } + + temp2a -> temp2b[style="invisible";dir="none"]; + temp2a -> temp2c[style="invisible";dir="none"]; + temp2b -> temp2c[constraint="false";label="wwwwwww"]; + } + + subgraph Res { + node[shape="none"]; + resulttree[shape="invtriangle";label=""]; + result[shape="record";label="{ | $} | { | x}"]; + resultroot[label="a'"]; + + resulttree -> result:x:n[dir="back"]; + result -> resultroot[dir="back"]; + } +} diff --git a/runtime/Java/src/main/dot/org/antlr/v4/runtime/atn/images/LocalMerge_DiffRoots.dot b/runtime/Java/src/main/dot/org/antlr/v4/runtime/atn/images/LocalMerge_DiffRoots.dot new file mode 100644 index 000000000..f23adef00 --- /dev/null +++ b/runtime/Java/src/main/dot/org/antlr/v4/runtime/atn/images/LocalMerge_DiffRoots.dot @@ -0,0 +1,39 @@ +digraph "" { + graph[dpi="60";compound="true"]; + + subgraph L { + node[shape="none"]; + left[label="$"]; + leftroot[label="a"]; + + left -> leftroot[dir="back"]; + } + + subgraph AB { + temp1[shape="none";label="+"]; + } + + subgraph R { + right[shape="invtriangle";label="x"]; + rightroot[shape="none";label="b"]; + + right -> rightroot[dir="back"]; + } + + subgraph BC { + node[color="invis";shape="point"]; + temp2b; + temp2c; + + temp2b -> temp2c[constraint="false";label="wwwwwww"]; + } + + subgraph Res { + node[shape="none"]; + result[label="$"]; + resultroot[shape="record";label="{ | a} | { | b}"]; + + result -> resultroot:a:n[dir="back"]; + result -> resultroot:b:n[dir="back"]; + } +} diff --git a/runtime/Java/src/main/dot/org/antlr/v4/runtime/atn/images/LocalMerge_EmptyParent.dot b/runtime/Java/src/main/dot/org/antlr/v4/runtime/atn/images/LocalMerge_EmptyParent.dot new file mode 100644 index 000000000..92c474955 --- /dev/null +++ b/runtime/Java/src/main/dot/org/antlr/v4/runtime/atn/images/LocalMerge_EmptyParent.dot @@ -0,0 +1,38 @@ +digraph "" { + graph[dpi="60";compound="true"]; + + subgraph L { + node[shape="none"]; + left[label="$"]; + leftroot[label="a"]; + + left -> leftroot[dir="back"]; + } + + subgraph AB { + temp1[shape="none";label="+"]; + } + + subgraph R { + right[shape="invtriangle";label="x"]; + rightroot[shape="none";label="a"]; + + right -> rightroot[dir="back"]; + } + + subgraph BC { + node[color="invis";shape="point"]; + temp2b; + temp2c; + + temp2b -> temp2c[constraint="false";label="wwwwwww"]; + } + + subgraph Res { + node[shape="none"]; + result[label="$"]; + resultroot[label="a"]; + + result -> resultroot[dir="back"]; + } +} diff --git a/runtime/Java/src/main/dot/org/antlr/v4/runtime/atn/images/LocalMerge_EmptyRoot.dot b/runtime/Java/src/main/dot/org/antlr/v4/runtime/atn/images/LocalMerge_EmptyRoot.dot new file mode 100644 index 000000000..d4ac91caa --- /dev/null +++ b/runtime/Java/src/main/dot/org/antlr/v4/runtime/atn/images/LocalMerge_EmptyRoot.dot @@ -0,0 +1,27 @@ +digraph "" { + graph[dpi="60";compound="true"]; + + subgraph L { + left[shape="none";label="$"]; + } + + subgraph AB { + temp1[shape="none";label="+"]; + } + + subgraph R { + right[shape="invtriangle";label="x"]; + } + + subgraph BC { + node[color="invis";shape="point"]; + temp2b; + temp2c; + + temp2b -> temp2c[constraint="false";label="wwwwwww"]; + } + + subgraph Res { + result[shape="none";label="$"]; + } +} diff --git a/runtime/Java/src/main/dot/org/antlr/v4/runtime/atn/images/SingletonMerge_DiffRootDiffPar.dot b/runtime/Java/src/main/dot/org/antlr/v4/runtime/atn/images/SingletonMerge_DiffRootDiffPar.dot new file mode 100644 index 000000000..19886d1d7 --- /dev/null +++ b/runtime/Java/src/main/dot/org/antlr/v4/runtime/atn/images/SingletonMerge_DiffRootDiffPar.dot @@ -0,0 +1,40 @@ +digraph "" { + graph[dpi="60";compound="true"]; + + subgraph L { + node[shape="none"]; + left[shape="invtriangle";label="x"]; + leftroot[label="a"]; + + left -> leftroot[dir="back"]; + } + + subgraph AB { + temp1[shape="none";label="+"]; + } + + subgraph R { + right[shape="invtriangle";label="y"]; + rightroot[shape="none";label="b"]; + + right -> rightroot[dir="back"]; + } + + subgraph BC { + node[color="invis";shape="point"]; + temp2b; + temp2c; + + temp2b -> temp2c[constraint="false";label="wwwwwww"]; + } + + subgraph clusterRes { + color="invis"; + resulttree1[shape="invtriangle";label="x"]; + resulttree2[shape="invtriangle";label="y"]; + result[shape="record";label="{ | a} | { | b}"]; + + resulttree1:s -> result:a:n[dir="back"]; + resulttree2:s -> result:b:n[dir="back"]; + } +} diff --git a/runtime/Java/src/main/dot/org/antlr/v4/runtime/atn/images/SingletonMerge_DiffRootSamePar.dot b/runtime/Java/src/main/dot/org/antlr/v4/runtime/atn/images/SingletonMerge_DiffRootSamePar.dot new file mode 100644 index 000000000..b3f01408e --- /dev/null +++ b/runtime/Java/src/main/dot/org/antlr/v4/runtime/atn/images/SingletonMerge_DiffRootSamePar.dot @@ -0,0 +1,39 @@ +digraph "" { + graph[dpi="60";compound="true"]; + + subgraph L { + node[shape="none"]; + left[shape="invtriangle";label="x"]; + leftroot[label="a"]; + + left -> leftroot[dir="back"]; + } + + subgraph AB { + temp1[shape="none";label="+"]; + } + + subgraph R { + right[shape="invtriangle";label="x"]; + rightroot[shape="none";label="b"]; + + right -> rightroot[dir="back"]; + } + + subgraph BC { + node[color="invis";shape="point"]; + temp2b; + temp2c; + + temp2b -> temp2c[constraint="false";label="wwwwwww"]; + } + + subgraph clusterRes { + color="invis"; + resulttree[shape="invtriangle";label="x"]; + result[shape="record";label="{ | a} | { | b}"]; + + resulttree -> result:a:n[dir="back"]; + resulttree -> result:b:n[dir="back"]; + } +} diff --git a/runtime/Java/src/main/dot/org/antlr/v4/runtime/atn/images/SingletonMerge_SameRootDiffPar.dot b/runtime/Java/src/main/dot/org/antlr/v4/runtime/atn/images/SingletonMerge_SameRootDiffPar.dot new file mode 100644 index 000000000..c33f461d4 --- /dev/null +++ b/runtime/Java/src/main/dot/org/antlr/v4/runtime/atn/images/SingletonMerge_SameRootDiffPar.dot @@ -0,0 +1,54 @@ +digraph "" { + graph[dpi="60";compound="true"]; + + subgraph L { + node[shape="none"]; + lefttree[label=""]; + left[shape="invtriangle";label="x"]; + leftroot[label="a"]; + + lefttree -> left[style="invisible";dir="none"]; + left -> leftroot[dir="back"]; + } + + subgraph AB { + optree[shape="none";label=""]; + temp1[shape="none";label="+"]; + + optree -> temp1[style="invisible";dir="none"]; + } + + subgraph R { + righttree[shape="none";label=""]; + right[shape="invtriangle";label="y"]; + rightroot[shape="none";label="a"]; + + righttree -> right[style="invisible";dir="none"]; + right -> rightroot[dir="back"]; + } + + subgraph BC { + node[color="invis";shape="point"]; + temp2a; + { rank="same"; + temp2b; + temp2c; + } + + temp2a -> temp2b[style="invisible";dir="none"]; + temp2a -> temp2c[style="invisible";dir="none"]; + temp2b -> temp2c[constraint="false";label="wwwwwww"]; + } + + subgraph clusterRes { + color="invis"; + resulttree1[shape="invtriangle";label=""]; + resulttree2[shape="invtriangle";label=""]; + result[shape="record";label="{ | x} | { | y}"]; + resultroot[shape="none";label="a'"]; + + resulttree1:s -> result:x:n[dir="back"]; + resulttree2:s -> result:y:n[dir="back"]; + result -> resultroot[dir="back"]; + } +} diff --git a/runtime/Java/src/main/dot/org/antlr/v4/runtime/atn/images/SingletonMerge_SameRootSamePar.dot b/runtime/Java/src/main/dot/org/antlr/v4/runtime/atn/images/SingletonMerge_SameRootSamePar.dot new file mode 100644 index 000000000..46d0940c8 --- /dev/null +++ b/runtime/Java/src/main/dot/org/antlr/v4/runtime/atn/images/SingletonMerge_SameRootSamePar.dot @@ -0,0 +1,38 @@ +digraph "" { + graph[dpi="60";compound="true"]; + + subgraph L { + node[shape="none"]; + left[shape="invtriangle";label="x"]; + leftroot[label="a"]; + + left -> leftroot[dir="back"]; + } + + subgraph AB { + temp1[shape="none";label="+"]; + } + + subgraph R { + right[shape="invtriangle";label="x"]; + rightroot[shape="none";label="a"]; + + right -> rightroot[dir="back"]; + } + + subgraph BC { + node[color="invis";shape="point"]; + temp2b; + temp2c; + + temp2b -> temp2c[constraint="false";label="wwwwwww"]; + } + + subgraph clusterRes { + color="invis"; + result[shape="invtriangle";label="x"]; + resultroot[shape="none";label="a"]; + + result -> resultroot[dir="back"]; + } +} diff --git a/runtime/Java/src/org/antlr/v4/runtime/atn/PredictionContext.java b/runtime/Java/src/org/antlr/v4/runtime/atn/PredictionContext.java index 0ddb5178c..102d29f5c 100644 --- a/runtime/Java/src/org/antlr/v4/runtime/atn/PredictionContext.java +++ b/runtime/Java/src/org/antlr/v4/runtime/atn/PredictionContext.java @@ -48,11 +48,16 @@ import java.util.Map; public abstract class PredictionContext implements Iterable, Comparable // to sort node lists by id { - /** Represents $ in local ctx prediction, which means wildcard. *+x = *. */ + /** + * Represents {@code $} in local context prediction, which means wildcard. + * {@code *+x = *}. + */ public static final EmptyPredictionContext EMPTY = new EmptyPredictionContext(); - /** Represents $ in an array in full ctx mode, when $ doesn't mean wildcard: - * $ + x = [$,x]. Here, $ = EMPTY_RETURN_STATE. + /** + * Represents {@code $} in an array in full context mode, when {@code $} + * doesn't mean wildcard: {@code $ + x = [$,x]}. Here, + * {@code $} = {@link #EMPTY_RETURN_STATE}. */ public static final int EMPTY_RETURN_STATE = Integer.MAX_VALUE; @@ -97,7 +102,7 @@ public abstract class PredictionContext implements Iterable + * + * Stack tops equal, parents merge is same; return left graph.
+ * + * + *

+ * + * Same stack top, parents differ; merge parents giving array node, then + * remainders of those graphs. A new root node is created to point to the + * merged parents.
+ * + * + *

+ * + * Different stack tops pointing to same parent. Make array node for the + * root where both element in the root point to the same (original) + * parent.
+ * + * + *

+ * + * Different stack tops pointing to different parents. Make array node for + * the root where each element points to the corresponding original + * parent.
+ * + * + * @param a the first {@link SingletonPredictionContext} + * @param b the second {@link SingletonPredictionContext} + * @param rootIsWildcard {@code true} if this is a local-context merge, + * otherwise false to indicate a full-context merge + * @param mergeCache + * @return + */ public static PredictionContext mergeSingletons( SingletonPredictionContext a, SingletonPredictionContext b, @@ -220,9 +260,56 @@ public abstract class PredictionContext implements IterableLocal-Context Merges + * + * These local-context merge operations are used when {@code rootIsWildcard} + * is true. + * + *

+ * + * {@link #EMPTY} is superset of any graph; return {@link #EMPTY}.
+ * + * + *

+ * + * {@link #EMPTY} and anything is {@code #EMPTY}, so merged parent is + * {@code #EMPTY}; return left graph.
+ * + * + *

+ * + * Special case of last merge if local context.
+ * + * + *

Full-Context Merges

+ * + * These full-context merge operations are used when {@code rootIsWildcard} + * is false. + * + *

+ * + * + * + *

+ * + * Must keep all contexts; {@link #EMPTY} in array is a special value (and + * null parent).
+ * + * + *

+ * + * + * + * @param a the first {@link SingletonPredictionContext} + * @param b the second {@link SingletonPredictionContext} + * @param rootIsWildcard {@code true} if this is a local-context merge, + * otherwise false to indicate a full-context merge + */ public static PredictionContext mergeRoot(SingletonPredictionContext a, SingletonPredictionContext b, boolean rootIsWildcard) @@ -251,7 +338,35 @@ public abstract class PredictionContext implements Iterable + * + * Different tops, different parents.
+ * + * + *

+ * + * Shared top, same parents.
+ * + * + *

+ * + * Shared top, different parents.
+ * + * + *

+ * + * Shared top, all shared parents.
+ * + * + *

+ * + * Equal tops, merge parents and reduce top to + * {@link SingletonPredictionContext}.
+ * + */ public static PredictionContext mergeArrays( ArrayPredictionContext a, ArrayPredictionContext b, @@ -361,7 +476,10 @@ public abstract class PredictionContext implements IterableM {@code parents}; merge any {@code equals()} + * ones. + */ protected static void combineCommonParents(PredictionContext[] parents) { Map uniqueParents = new HashMap(); From b956a9eda16009f390119de4a90226dc544d507e Mon Sep 17 00:00:00 2001 From: Sam Harwell Date: Mon, 21 Jan 2013 12:55:06 -0600 Subject: [PATCH 08/11] Fix incorrect HTML excape in Javadoc code tag --- runtime/Java/src/org/antlr/v4/runtime/IntStream.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runtime/Java/src/org/antlr/v4/runtime/IntStream.java b/runtime/Java/src/org/antlr/v4/runtime/IntStream.java index 0b0ca6ff8..cb25380d4 100644 --- a/runtime/Java/src/org/antlr/v4/runtime/IntStream.java +++ b/runtime/Java/src/org/antlr/v4/runtime/IntStream.java @@ -112,7 +112,7 @@ public interface IntStream { * If {@code i} represents a position at or beyond the end of the stream, * this method returns {@link #EOF}. *

- * The return value is unspecified if {@code i<0} and fewer than {@code -i} + * The return value is unspecified if {@code i<0} and fewer than {@code -i} * calls to {@link #consume consume()} have occurred from the beginning of * the stream before calling this method. * From 019cba7c4634f52329fe9006c0141098f1a9f76b Mon Sep 17 00:00:00 2001 From: Sam Harwell Date: Mon, 21 Jan 2013 12:57:50 -0600 Subject: [PATCH 09/11] Remove unused "true" and "false" templates --- .../org/antlr/v4/tool/templates/codegen/Java/Java.stg | 3 --- 1 file changed, 3 deletions(-) diff --git a/tool/resources/org/antlr/v4/tool/templates/codegen/Java/Java.stg b/tool/resources/org/antlr/v4/tool/templates/codegen/Java/Java.stg index a9a608c73..3797ed727 100644 --- a/tool/resources/org/antlr/v4/tool/templates/codegen/Java/Java.stg +++ b/tool/resources/org/antlr/v4/tool/templates/codegen/Java/Java.stg @@ -835,6 +835,3 @@ initValue(typeName) ::= << >> codeFileExtension() ::= ".java" - -true() ::= "true" -false() ::= "false" From 29495c4a04db67e25a3aaf4a6476dc49168e5ad2 Mon Sep 17 00:00:00 2001 From: Sam Harwell Date: Mon, 21 Jan 2013 13:04:23 -0600 Subject: [PATCH 10/11] Use hard tab in code generation template --- .../resources/org/antlr/v4/tool/templates/codegen/Java/Java.stg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tool/resources/org/antlr/v4/tool/templates/codegen/Java/Java.stg b/tool/resources/org/antlr/v4/tool/templates/codegen/Java/Java.stg index 3797ed727..e347dea08 100644 --- a/tool/resources/org/antlr/v4/tool/templates/codegen/Java/Java.stg +++ b/tool/resources/org/antlr/v4/tool/templates/codegen/Java/Java.stg @@ -820,7 +820,7 @@ public static final String _serializedATN = public static final ATN _ATN = ATNSimulator.deserialize(_serializedATN.toCharArray()); static { - _decisionToDFA = new DFA[_ATN.getNumberOfDecisions()]; + _decisionToDFA = new DFA[_ATN.getNumberOfDecisions()]; From 678927617ec21fb7f38f7e69587d30a240b10006 Mon Sep 17 00:00:00 2001 From: Sam Harwell Date: Mon, 21 Jan 2013 13:15:53 -0600 Subject: [PATCH 11/11] Update CHANGES.txt --- CHANGES.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGES.txt b/CHANGES.txt index ae541d6b0..9bb604968 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -2,6 +2,10 @@ ANTLR v4 Honey Badger January 21, 2013 -- Release 4.0 +* Updated PredictionContext Javadocs +* Updated Maven site documentation +* Minor tweaks in Java.stg + January 15, 2013 * Tweak error messages