From 48c2edb295808e781c3250d235c8f127126503bd Mon Sep 17 00:00:00 2001 From: Sergey Igushkin Date: Sun, 29 Oct 2017 16:09:16 +0300 Subject: [PATCH] Advance version to 0.3.1, fix non-nullable `structureParsers` and tests. --- README.md | 2 +- build.gradle | 2 +- .../com/github/h0tk3y/betterParse/st/LiftToSyntaxTree.kt | 2 +- src/main/kotlin/generated/andFunctions.kt | 2 +- src/test/kotlin/TestLiftToAst.kt | 6 +++--- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 68819a4..244d7d0 100644 --- a/README.md +++ b/README.md @@ -34,7 +34,7 @@ repositories { } dependencies { - compile 'com.github.h0tk3y.betterParse:better-parse:0.3.0' + compile 'com.github.h0tk3y.betterParse:better-parse:0.3.1' } ``` diff --git a/build.gradle b/build.gradle index bfaff09..6b2cdc6 100644 --- a/build.gradle +++ b/build.gradle @@ -1,5 +1,5 @@ group 'com.github.h0tk3y.betterParse' -version '0.3.0' +version '0.3.1' buildscript { ext.kotlin_version = '1.1.51' diff --git a/src/main/kotlin/com/github/h0tk3y/betterParse/st/LiftToSyntaxTree.kt b/src/main/kotlin/com/github/h0tk3y/betterParse/st/LiftToSyntaxTree.kt index 821f309..fd2041d 100644 --- a/src/main/kotlin/com/github/h0tk3y/betterParse/st/LiftToSyntaxTree.kt +++ b/src/main/kotlin/com/github/h0tk3y/betterParse/st/LiftToSyntaxTree.kt @@ -47,7 +47,7 @@ fun Parser.liftToSyntaxTreeParser( /** Converts a [Grammar] so that its [Grammar.rootParser] parses a [SyntaxTree]. See: [liftToSyntaxTreeParser]. */ fun Grammar.liftToSyntaxTreeGrammar( liftOptions: LiftToSyntaxTreeOptions = LiftToSyntaxTreeOptions(), - structureParsers: Set> = declaredParsers, + structureParsers: Set>? = declaredParsers, transformer: LiftToSyntaxTreeTransformer? = null ) = object : Grammar>() { override val rootParser: Parser> = this@liftToSyntaxTreeGrammar.rootParser diff --git a/src/main/kotlin/generated/andFunctions.kt b/src/main/kotlin/generated/andFunctions.kt index 9f334fa..f017d40 100644 --- a/src/main/kotlin/generated/andFunctions.kt +++ b/src/main/kotlin/generated/andFunctions.kt @@ -1,6 +1,6 @@ package com.github.h0tk3y.betterParse.combinators -import com.github.h0tk3y.betterParse.parser.Parser import com.github.h0tk3y.betterParse.utils.* +import com.github.h0tk3y.betterParse.parser.* @JvmName("and2") inline infix fun AndCombinator>.and(p3: Parser) = diff --git a/src/test/kotlin/TestLiftToAst.kt b/src/test/kotlin/TestLiftToAst.kt index 5952f02..a1abd89 100644 --- a/src/test/kotlin/TestLiftToAst.kt +++ b/src/test/kotlin/TestLiftToAst.kt @@ -66,14 +66,14 @@ private fun SyntaxTree<*>.toTopDownStrings() = topDownNodesSequence() class TestLiftToAst { @Test fun continuousRange() { - val astParser = booleanGrammar.liftToSyntaxTreeGrammar(LiftToSyntaxTreeOptions(retainSkipped = true), structureParsers = emptySet()) + val astParser = booleanGrammar.liftToSyntaxTreeGrammar(LiftToSyntaxTreeOptions(retainSkipped = true), structureParsers = null) val ast = astParser.parseToEnd("a&(b1->c1)|a1&!b|!(a1->a2)->a") checkAstContinuousRange(ast) } @Test fun astStructure() { - val astParser = booleanGrammar.liftToSyntaxTreeGrammar(LiftToSyntaxTreeOptions(retainSkipped = true), structureParsers = emptySet()) + val astParser = booleanGrammar.liftToSyntaxTreeGrammar(LiftToSyntaxTreeOptions(retainSkipped = true), structureParsers = null) val ast = astParser.parseToEnd("(!(a)->((b)|(!c))->!(!a)&!(d))") val types = ast.toTopDownStrings() @@ -86,7 +86,7 @@ class TestLiftToAst { @Test fun testDropSkipped() { - val astParser = booleanGrammar.liftToSyntaxTreeGrammar(LiftToSyntaxTreeOptions(retainSkipped = false), structureParsers = emptySet()) + val astParser = booleanGrammar.liftToSyntaxTreeGrammar(LiftToSyntaxTreeOptions(retainSkipped = false), structureParsers = null) val ast = astParser.parseToEnd("(!(a)->((b)|(!c))->!(!a)&!(d))") val types = ast.toTopDownStrings()