Skip to content

v0.1.5 Hotfix Release #393

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

Merged
merged 2 commits into from
Apr 27, 2021
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ This project is published to [Maven Central](https://search.maven.org/artifact/o

| Group ID | Artifact ID | Recommended Version |
|----------|-------------|---------------------|
| `org.partiql` | `partiql-lang-kotlin` | `0.1.4`
| `org.partiql` | `partiql-lang-kotlin` | `0.1.5`


For Maven builds, add this to your `pom.xml`:
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ allprojects {

subprojects {
group = 'org.partiql'
version = '0.1.4'
version = '0.1.5'
}

buildDir = new File(rootProject.projectDir, "gradle-build/" + project.name)
Expand Down
33 changes: 19 additions & 14 deletions lang/src/org/partiql/lang/ast/ast.kt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import org.partiql.lang.util.*
import java.util.*

/**
* Base type for all AST nodes.
* Base type for all AST nodes.
*/
sealed class AstNode : Iterable<AstNode> {

Expand All @@ -32,10 +32,15 @@ sealed class AstNode : Iterable<AstNode> {
* Depth first iterator over all nodes.
*/
override operator fun iterator(): Iterator<AstNode> {
fun depthFirstSequence(node: AstNode): Sequence<AstNode> =
sequenceOf(node) + node.children.asSequence().flatMap { depthFirstSequence(it) }

return depthFirstSequence(this).iterator();
val allNodes = mutableListOf<AstNode>()

fun depthFirstSequence(node: AstNode) {
allNodes.add(node)
node.children.map { depthFirstSequence(it) }
}

depthFirstSequence(this)
return allNodes.toList().iterator()
}
}

Expand All @@ -44,7 +49,7 @@ sealed class AstNode : Iterable<AstNode> {
* place a value is allowed.
*/
sealed class ExprNode : AstNode(), HasMetas {

fun copy(newMetas: MetaContainer? = null): ExprNode {
// This looks like duplication but really isn't: each branch executes a different compiler-generated `copy` function.
val metas = newMetas ?: this.metas
Expand Down Expand Up @@ -113,7 +118,7 @@ data class Literal(
data class LiteralMissing(
override val metas: MetaContainer
) : ExprNode() {

override val children: List<AstNode> = listOf()
}

Expand Down Expand Up @@ -366,15 +371,15 @@ sealed class SelectProjection : AstNode()
data class SelectProjectionList(
val items: List<SelectListItem>
) : SelectProjection() {
override val children: List<AstNode> = items

override val children: List<AstNode> = items
}

/** For `SELECT VALUE <expr>` */
data class SelectProjectionValue(
val expr: ExprNode
) : SelectProjection() {

override val children: List<AstNode> = listOf(expr)
}

Expand All @@ -383,7 +388,7 @@ data class SelectProjectionPivot(
val valueExpr: ExprNode,
val nameExpr: ExprNode
) : SelectProjection() {

override val children: List<AstNode> = listOf(valueExpr, nameExpr)
}

Expand All @@ -404,7 +409,7 @@ data class SelectListItemExpr(
val expr: ExprNode,
val asName: SymbolicName? = null
) : SelectListItem() {

override val children: List<AstNode> = listOf(expr)
}

Expand Down Expand Up @@ -451,7 +456,7 @@ data class FromSourceJoin(
val condition: ExprNode,
override val metas: MetaContainer
) : FromSource(), HasMetas {

override val children: List<AstNode> = listOf(leftRef, rightRef, condition)
}

Expand All @@ -469,7 +474,7 @@ data class FromSourceUnpivot(
val atName: SymbolicName?,
override val metas: MetaContainer
) : FromSource(), HasMetas {

override val children: List<AstNode> = listOf(expr)
}

Expand Down