From a9b93e07391faede77dde4c0b3c21c9b3f97f8eb Mon Sep 17 00:00:00 2001 From: Herman van Hovell Date: Thu, 31 Mar 2016 09:25:09 -0700 Subject: [SPARK-14211][SQL] Remove ANTLR3 based parser ### What changes were proposed in this pull request? This PR removes the ANTLR3 based parser, and moves the new ANTLR4 based parser into the `org.apache.spark.sql.catalyst.parser package`. ### How was this patch tested? Existing unit tests. cc rxin andrewor14 yhuai Author: Herman van Hovell Closes #12071 from hvanhovell/SPARK-14211. --- project/SparkBuild.scala | 54 ++---------------------------------------------- project/plugins.sbt | 3 --- 2 files changed, 2 insertions(+), 55 deletions(-) (limited to 'project') diff --git a/project/SparkBuild.scala b/project/SparkBuild.scala index 39a9e16f7e..5d62b688b9 100644 --- a/project/SparkBuild.scala +++ b/project/SparkBuild.scala @@ -403,59 +403,9 @@ object OldDeps { object Catalyst { lazy val settings = antlr4Settings ++ Seq( - antlr4PackageName in Antlr4 := Some("org.apache.spark.sql.catalyst.parser.ng"), + antlr4PackageName in Antlr4 := Some("org.apache.spark.sql.catalyst.parser"), antlr4GenListener in Antlr4 := true, - antlr4GenVisitor in Antlr4 := true, - // ANTLR code-generation step. - // - // This has been heavily inspired by com.github.stefri.sbt-antlr (0.5.3). It fixes a number of - // build errors in the current plugin. - // Create Parser from ANTLR grammar files. - sourceGenerators in Compile += Def.task { - val log = streams.value.log - - val grammarFileNames = Seq( - "SparkSqlLexer.g", - "SparkSqlParser.g") - val sourceDir = (sourceDirectory in Compile).value / "antlr3" - val targetDir = (sourceManaged in Compile).value / "antlr3" - - // Create default ANTLR Tool. - val antlr = new org.antlr.Tool - - // Setup input and output directories. - antlr.setInputDirectory(sourceDir.getPath) - antlr.setOutputDirectory(targetDir.getPath) - antlr.setForceRelativeOutput(true) - antlr.setMake(true) - - // Add grammar files. - grammarFileNames.flatMap(gFileName => (sourceDir ** gFileName).get).foreach { gFilePath => - val relGFilePath = (gFilePath relativeTo sourceDir).get.getPath - log.info("ANTLR: Grammar file '%s' detected.".format(relGFilePath)) - antlr.addGrammarFile(relGFilePath) - // We will set library directory multiple times here. However, only the - // last one has effect. Because the grammar files are located under the same directory, - // We assume there is only one library directory. - antlr.setLibDirectory(gFilePath.getParent) - } - - // Generate the parser. - antlr.process() - val errorState = org.antlr.tool.ErrorManager.getErrorState - if (errorState.errors > 0) { - sys.error("ANTLR: Caught %d build errors.".format(errorState.errors)) - } else if (errorState.warnings > 0) { - sys.error("ANTLR: Caught %d build warnings.".format(errorState.warnings)) - } - - // Return all generated java files. - (targetDir ** "*.java").get.toSeq - }.taskValue, - // Include ANTLR tokens files. - resourceGenerators in Compile += Def.task { - ((sourceManaged in Compile).value ** "*.tokens").get.toSeq - }.taskValue + antlr4GenVisitor in Antlr4 := true ) } diff --git a/project/plugins.sbt b/project/plugins.sbt index d9ed7962bf..4929ba3c4d 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -22,9 +22,6 @@ libraryDependencies += "org.ow2.asm" % "asm" % "5.0.3" libraryDependencies += "org.ow2.asm" % "asm-commons" % "5.0.3" -libraryDependencies += "org.antlr" % "antlr" % "3.5.2" - - // TODO I am not sure we want such a dep. resolvers += "simplytyped" at "http://simplytyped.github.io/repo/releases" -- cgit v1.2.3