Skip to content

Commit

Permalink
Internalize ANTLR sources; exclude from API checks
Browse files Browse the repository at this point in the history
  • Loading branch information
alancai98 committed Apr 30, 2024
1 parent 607c4c0 commit 223a94f
Show file tree
Hide file tree
Showing 14 changed files with 32 additions and 5,311 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ import org.jline.reader.LineReader
import org.jline.utils.AttributedString
import org.jline.utils.AttributedStringBuilder
import org.jline.utils.AttributedStyle
import org.partiql.parser.antlr.PartiQLParser
import org.partiql.parser.antlr.PartiQLTokens
import org.partiql.parser.internal.antlr.PartiQLParser
import org.partiql.parser.internal.antlr.PartiQLTokens
import java.nio.charset.StandardCharsets
import java.util.regex.Pattern

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ import org.partiql.lang.types.CustomType
import org.partiql.lang.util.checkThreadInterrupted
import org.partiql.lang.util.getAntlrDisplayString
import org.partiql.lang.util.getIonValue
import org.partiql.parser.antlr.PartiQLParser
import org.partiql.parser.antlr.PartiQLTokens
import org.partiql.parser.internal.antlr.PartiQLParser
import org.partiql.parser.internal.antlr.PartiQLTokens
import java.io.InputStream
import java.nio.channels.ClosedByInterruptException
import java.nio.charset.StandardCharsets
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ import org.partiql.lang.util.checkThreadInterrupted
import org.partiql.lang.util.error
import org.partiql.lang.util.getPrecisionFromTimeString
import org.partiql.lang.util.unaryMinus
import org.partiql.parser.antlr.PartiQLBaseVisitor
import org.partiql.parser.antlr.PartiQLParser
import org.partiql.parser.internal.antlr.PartiQLBaseVisitor
import org.partiql.parser.internal.antlr.PartiQLParser
import org.partiql.pig.runtime.SymbolPrimitive
import org.partiql.value.datetime.DateTimeException
import org.partiql.value.datetime.TimeZone
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import org.partiql.errors.ErrorCode
import org.partiql.errors.Property
import org.partiql.errors.PropertyValueMap
import org.partiql.lang.syntax.ParserException
import org.partiql.parser.antlr.PartiQLParser
import org.partiql.parser.internal.antlr.PartiQLParser
import java.math.BigInteger

// workaround until ErrorAndErrorContexts no longer uses IonSystem
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import org.partiql.errors.ErrorCode
import org.partiql.errors.Property
import org.partiql.lang.syntax.PartiQLParserTestBase
import org.partiql.lang.util.getAntlrDisplayString
import org.partiql.parser.antlr.PartiQLParser
import org.partiql.parser.internal.antlr.PartiQLParser

class ParserErrorsTest : PartiQLParserTestBase() {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import org.partiql.lang.domains.PartiqlAst
import org.partiql.lang.domains.id
import org.partiql.lang.util.getAntlrDisplayString
import org.partiql.lang.util.to
import org.partiql.parser.antlr.PartiQLParser
import org.partiql.parser.internal.antlr.PartiQLParser

class PartiQLParserDateTimeTests : PartiQLParserTestBase() {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import org.partiql.lang.ION
import org.partiql.lang.domains.PartiqlAst
import org.partiql.lang.util.ArgumentsProviderBase
import org.partiql.lang.util.getAntlrDisplayString
import org.partiql.parser.antlr.PartiQLParser
import org.partiql.parser.internal.antlr.PartiQLParser

class PartiQLParserExplainTest : PartiQLParserTestBase() {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import org.partiql.lang.ast.sourceLocation
import org.partiql.lang.domains.PartiqlAst
import org.partiql.lang.domains.id
import org.partiql.lang.util.getAntlrDisplayString
import org.partiql.parser.antlr.PartiQLParser
import org.partiql.parser.internal.antlr.PartiQLParser
import kotlin.concurrent.thread

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import org.junit.Test
import org.partiql.errors.ErrorCode
import org.partiql.errors.Property
import org.partiql.lang.util.getAntlrDisplayString
import org.partiql.parser.antlr.PartiQLParser
import org.partiql.parser.internal.antlr.PartiQLParser

class PartiQLParserWindowTests : PartiQLParserTestBase() {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import org.partiql.lang.StepContext
import org.partiql.lang.domains.PartiqlAst
import org.partiql.lang.eval.CompileOptions
import org.partiql.lang.eval.visitors.VisitorTransformBase
import org.partiql.parser.antlr.PartiQLTokens
import org.partiql.parser.internal.antlr.PartiQLTokens
import java.io.InputStream
import java.util.concurrent.atomic.AtomicBoolean
import kotlin.concurrent.thread
Expand Down
3 changes: 3 additions & 0 deletions partiql-parser/README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
The PartiQL Parser can be used to parse PartiQL queries into an AST (`org.partiql.ast`).
This interface expands the legacy `org.partiql.syntax.Parser` interface allowing for a richer return type as well as the latest AST.

ANTLR-generated code is under the `internal` package namespace. It is not intended to be used outside of code within
this library.

== Interfaces

[source,kotlin]
Expand Down
5,290 changes: 0 additions & 5,290 deletions partiql-parser/api/partiql-parser.api

Large diffs are not rendered by default.

10 changes: 9 additions & 1 deletion partiql-parser/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,21 @@ dependencies {
}

tasks.generateGrammarSource {
val antlrPackage = "org.partiql.parser.antlr"
val antlrPackage = "org.partiql.parser.internal.antlr"
val antlrSources = "$buildDir/generated-src/${antlrPackage.replace('.', '/')}"
maxHeapSize = "64m"
arguments = listOf("-visitor", "-long-messages", "-package", antlrPackage)
outputDirectory = File(antlrSources)
}

apiValidation {
ignoredPackages.addAll(
listOf(
"org.partiql.parser.internal"
)
)
}

tasks.javadoc {
exclude("**/antlr/**")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ import org.partiql.parser.PartiQLParserException
import org.partiql.parser.PartiQLSyntaxException
import org.partiql.parser.SourceLocation
import org.partiql.parser.SourceLocations
import org.partiql.parser.antlr.PartiQLBaseVisitor
import org.partiql.parser.internal.antlr.PartiQLBaseVisitor
import org.partiql.parser.internal.util.DateTimeUtils
import org.partiql.value.NumericValue
import org.partiql.value.PartiQLValueExperimental
Expand All @@ -239,8 +239,8 @@ import java.nio.charset.StandardCharsets
import java.time.LocalDate
import java.time.format.DateTimeFormatter
import java.time.format.DateTimeParseException
import org.partiql.parser.antlr.PartiQLParser as GeneratedParser
import org.partiql.parser.antlr.PartiQLTokens as GeneratedLexer
import org.partiql.parser.internal.antlr.PartiQLParser as GeneratedParser
import org.partiql.parser.internal.antlr.PartiQLTokens as GeneratedLexer

/**
* ANTLR Based Implementation of a PartiQLParser
Expand Down Expand Up @@ -574,7 +574,7 @@ internal class PartiQLParserDefault : PartiQLParser {
}
}

override fun visitQualifiedName(ctx: org.partiql.parser.antlr.PartiQLParser.QualifiedNameContext) = translate(ctx) {
override fun visitQualifiedName(ctx: org.partiql.parser.internal.antlr.PartiQLParser.QualifiedNameContext) = translate(ctx) {
val qualifier = ctx.qualifier.map { visitSymbolPrimitive(it) }
val name = visitSymbolPrimitive(ctx.name)
if (qualifier.isEmpty()) {
Expand Down Expand Up @@ -1134,12 +1134,12 @@ internal class PartiQLParserDefault : PartiQLParser {
excludeStepStructField(identifier)
}

override fun visitExcludeExprCollectionWildcard(ctx: org.partiql.parser.antlr.PartiQLParser.ExcludeExprCollectionWildcardContext) =
override fun visitExcludeExprCollectionWildcard(ctx: org.partiql.parser.internal.antlr.PartiQLParser.ExcludeExprCollectionWildcardContext) =
translate(ctx) {
excludeStepCollWildcard()
}

override fun visitExcludeExprTupleWildcard(ctx: org.partiql.parser.antlr.PartiQLParser.ExcludeExprTupleWildcardContext) =
override fun visitExcludeExprTupleWildcard(ctx: org.partiql.parser.internal.antlr.PartiQLParser.ExcludeExprTupleWildcardContext) =
translate(ctx) {
excludeStepStructWildcard()
}
Expand Down Expand Up @@ -1720,7 +1720,7 @@ internal class PartiQLParserDefault : PartiQLParser {
exprSessionAttribute(Expr.SessionAttribute.Attribute.CURRENT_USER)
}

override fun visitExprTermCurrentDate(ctx: org.partiql.parser.antlr.PartiQLParser.ExprTermCurrentDateContext) =
override fun visitExprTermCurrentDate(ctx: org.partiql.parser.internal.antlr.PartiQLParser.ExprTermCurrentDateContext) =
translate(ctx) {
exprSessionAttribute(Expr.SessionAttribute.Attribute.CURRENT_DATE)
}
Expand Down

0 comments on commit 223a94f

Please sign in to comment.