Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initialize partiql-parser package with partiql-ast IR #1142

Merged
merged 10 commits into from
Jul 13, 2023
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@ on:
- '**'
- '!docs/**'
- '!**/*.md'
- '!**/*.adoc'
pull_request:
paths:
- '**'
- '!docs/**'
- '!**.*.md'
- '!**/*.md'
- '!**/*.adoc'

jobs:
test:
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ Thank you to all who have contributed!
### Added
- Adds `org.partiql.value` (experimental) package for reading/writing PartiQL
values
- Adds `org.partiql.ast` package and usage documentation
- Adds `org.partiql.parser` package and usage documentation

### Changed

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ class KotlinUtilsPoem(symbols: KotlinSymbols) : KotlinPoem(symbols) {
private val suppressUnused = AnnotationSpec.builder(Suppress::class)
.useSiteTarget(AnnotationSpec.UseSiteTarget.FILE)
.addMember("%S", "UNUSED_PARAMETER")
.addMember("%S", "UNUSED_VARIABLE")
.build()

// Not taking a dep on builder or visitor poems, as this is temporary
Expand Down Expand Up @@ -107,8 +108,8 @@ class KotlinUtilsPoem(symbols: KotlinSymbols) : KotlinPoem(symbols) {
// Node N -> visitN(node.n, ctx) as N
// Node N? -> node.n?.let { visitN(it, ctx) as N }
// Collection<N> -> rewrite(node, ctx, ::method)
// Collection?<N> -> node.n?.let { rewrite(it, ctx, ::method) }
// Collection?<N?> -> node.n?.let { rewrite(it, ctx, ::method) }
// Collection<N>? -> node.n?.let { rewrite(it, ctx, ::method) }
// Collection<N?>? -> node.n?.let { rewrite(it, ctx, ::method) }
// Collection<N?> -> rewrite(node, ctx, ::method)

private fun KotlinNodeSpec.Product.rewriter(): FunSpec {
Expand Down Expand Up @@ -139,17 +140,25 @@ class KotlinUtilsPoem(symbols: KotlinSymbols) : KotlinPoem(symbols) {
(ref is TypeRef.List && isNode(ref.type)) -> {
// Collections
val method = (ref.type as TypeRef.Path).visitMethodName()
val helper = when (ref.type.nullable) {
true -> "_visitListNull"
else -> "_visitList"
}
when (ref.nullable) {
true -> addStatement("val $name = $child?.let { _visitListNull(it, ctx, ::$method) }")
false -> addStatement("val $name = _visitList($child, ctx, ::$method)")
true -> addStatement("val $name = $child?.let { $helper(it, ctx, ::$method) }")
false -> addStatement("val $name = $helper($child, ctx, ::$method)")
}
}
(ref is TypeRef.Set && isNode(ref.type)) -> {
// Collections
val method = (ref.type as TypeRef.Path).visitMethodName()
val helper = when (ref.type.nullable) {
true -> "_visitSetNull"
else -> "_visitSet"
}
when (ref.nullable) {
true -> addStatement("val $name = $child?.let { _visitSetNull(it, ctx, ::$method) }")
false -> addStatement("val $name = _visitSet($child, ctx, ::$method)")
true -> addStatement("val $name = $child?.let { $helper(it, ctx, ::$method) }")
false -> addStatement("val $name = $helper($child, ctx, ::$method)")
}
}
else -> {
Expand Down
Loading