@@ -403,59 +403,9 @@ object OldDeps {
403403
404404object Catalyst {
405405 lazy val settings = antlr4Settings ++ Seq (
406- antlr4PackageName in Antlr4 := Some (" org.apache.spark.sql.catalyst.parser.ng " ),
406+ antlr4PackageName in Antlr4 := Some (" org.apache.spark.sql.catalyst.parser" ),
407407 antlr4GenListener in Antlr4 := true ,
408- antlr4GenVisitor in Antlr4 := true ,
409- // ANTLR code-generation step.
410- //
411- // This has been heavily inspired by com.github.stefri.sbt-antlr (0.5.3). It fixes a number of
412- // build errors in the current plugin.
413- // Create Parser from ANTLR grammar files.
414- sourceGenerators in Compile += Def .task {
415- val log = streams.value.log
416-
417- val grammarFileNames = Seq (
418- " SparkSqlLexer.g" ,
419- " SparkSqlParser.g" )
420- val sourceDir = (sourceDirectory in Compile ).value / " antlr3"
421- val targetDir = (sourceManaged in Compile ).value / " antlr3"
422-
423- // Create default ANTLR Tool.
424- val antlr = new org.antlr.Tool
425-
426- // Setup input and output directories.
427- antlr.setInputDirectory(sourceDir.getPath)
428- antlr.setOutputDirectory(targetDir.getPath)
429- antlr.setForceRelativeOutput(true )
430- antlr.setMake(true )
431-
432- // Add grammar files.
433- grammarFileNames.flatMap(gFileName => (sourceDir ** gFileName).get).foreach { gFilePath =>
434- val relGFilePath = (gFilePath relativeTo sourceDir).get.getPath
435- log.info(" ANTLR: Grammar file '%s' detected." .format(relGFilePath))
436- antlr.addGrammarFile(relGFilePath)
437- // We will set library directory multiple times here. However, only the
438- // last one has effect. Because the grammar files are located under the same directory,
439- // We assume there is only one library directory.
440- antlr.setLibDirectory(gFilePath.getParent)
441- }
442-
443- // Generate the parser.
444- antlr.process()
445- val errorState = org.antlr.tool.ErrorManager .getErrorState
446- if (errorState.errors > 0 ) {
447- sys.error(" ANTLR: Caught %d build errors." .format(errorState.errors))
448- } else if (errorState.warnings > 0 ) {
449- sys.error(" ANTLR: Caught %d build warnings." .format(errorState.warnings))
450- }
451-
452- // Return all generated java files.
453- (targetDir ** " *.java" ).get.toSeq
454- }.taskValue,
455- // Include ANTLR tokens files.
456- resourceGenerators in Compile += Def .task {
457- ((sourceManaged in Compile ).value ** " *.tokens" ).get.toSeq
458- }.taskValue
408+ antlr4GenVisitor in Antlr4 := true
459409 )
460410}
461411
0 commit comments