Last active
November 2, 2019 13:44
-
-
Save jnorthrup/dd88da7d4715379bf357788e6a6ca9e3 to your computer and use it in GitHub Desktop.
simplest possible grammar
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | |
<modelVersion>4.0.0</modelVersion> | |
<groupId>com.fnreport</groupId> | |
<artifactId>lownal</artifactId> | |
<version>1.0-SNAPSHOT</version> | |
<repositories> | |
<repository> | |
<id>bintray-kotlin-kotlinx</id> | |
<name>bintray</name> | |
<url>https://kotlin.bintray.com/kotlinx</url> | |
</repository> | |
</repositories> | |
<properties> | |
<kotlin.version>1.3.50</kotlin.version> | |
<serialization.version>0.13.0</serialization.version> | |
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | |
<maven.compiler.source>11</maven.compiler.source> | |
<maven.compiler.target>11</maven.compiler.target> | |
</properties> | |
<dependencies> | |
<dependency> | |
<groupId>org.jetbrains.kotlinx</groupId> | |
<artifactId>kotlinx-coroutines-core</artifactId> | |
<version>1.3.2</version> | |
</dependency> | |
<dependency> | |
<groupId>org.jetbrains.kotlinx</groupId> | |
<artifactId>kotlinx-coroutines-core-common</artifactId> | |
<version>1.3.2</version> | |
</dependency> | |
<dependency> | |
<groupId>org.jetbrains.kotlinx</groupId> | |
<artifactId>kotlinx-coroutines-jdk8</artifactId> | |
<version>1.3.2</version> | |
</dependency> | |
<dependency> | |
<groupId>org.jetbrains.kotlin</groupId> | |
<artifactId>kotlin-stdlib</artifactId> | |
<version>${kotlin.version}</version> | |
</dependency> | |
<dependency> | |
<groupId>org.jetbrains.kotlin</groupId> | |
<artifactId>kotlin-stdlib-common</artifactId> | |
<version>${kotlin.version}</version> | |
</dependency> | |
<dependency> | |
<groupId>org.jetbrains.kotlin</groupId> | |
<artifactId>kotlin-stdlib-jdk8</artifactId> | |
<version>${kotlin.version}</version> | |
</dependency> | |
<dependency> | |
<groupId>org.jetbrains.kotlin</groupId> | |
<artifactId>kotlin-test</artifactId> | |
<version>${kotlin.version}</version> | |
<scope>test</scope> | |
</dependency> | |
<dependency> | |
<groupId>io.kotlintest</groupId> | |
<artifactId>kotlintest</artifactId> | |
<version>2.0.7</version> | |
<scope>test</scope> | |
</dependency> | |
<dependency> | |
<groupId>io.kotlintest</groupId> | |
<artifactId>kotlintest-core</artifactId> | |
<version>3.4.1</version> | |
<scope>test</scope> | |
</dependency> | |
<!-- com/github/h0tk3y/betterParse/better-parse-multiplatform-jvm/0.4.2/better-parse-multiplatform-jvm-0.4.2--> | |
<dependency> | |
<groupId>com.github.h0tk3y.betterParse</groupId> | |
<artifactId>better-parse-multiplatform</artifactId> | |
<version>0.4.2</version> <exclusions> | |
<exclusion> | |
<groupId>org.jetbrains.kotlin</groupId> | |
<artifactId>kotlin-stdlib</artifactId> | |
</exclusion> | |
<exclusion> | |
<groupId>org.jetbrains.kotlin</groupId> | |
<artifactId>kotlin-stdlib-commmon</artifactId> | |
</exclusion> | |
</exclusions> | |
</dependency> | |
<dependency> | |
<groupId>com.github.h0tk3y.betterParse</groupId> | |
<artifactId>better-parse-multiplatform-jvm</artifactId> | |
<version>0.4.2</version> | |
<exclusions> | |
<exclusion> | |
<groupId>org.jetbrains.kotlin</groupId> | |
<artifactId>kotlin-stdlib</artifactId> | |
</exclusion> | |
<exclusion> | |
<groupId>org.jetbrains.kotlin</groupId> | |
<artifactId>kotlin-stdlib-commmon</artifactId> | |
</exclusion> | |
</exclusions> | |
</dependency> | |
</dependencies> | |
<build> | |
<plugins> | |
<plugin> | |
<groupId>org.jetbrains.kotlin</groupId> | |
<artifactId>kotlin-maven-plugin</artifactId> | |
<version>${kotlin.version}</version> | |
<executions> | |
<execution> | |
<id>compile</id> | |
<phase>compile</phase> | |
<goals> | |
<goal>compile</goal> | |
</goals> | |
</execution> | |
<execution> | |
<id>test-compile</id> | |
<phase>test-compile</phase> | |
<goals> | |
<goal>test-compile</goal> | |
</goals> | |
</execution> | |
</executions> | |
<configuration> | |
<compilerPlugins> | |
<plugin>kotlinx-serialization</plugin> | |
</compilerPlugins> | |
<jvmTarget>11</jvmTarget> | |
</configuration> | |
<dependencies> | |
<dependency> | |
<groupId>org.jetbrains.kotlin</groupId> | |
<artifactId>kotlin-maven-serialization</artifactId> | |
<version>${kotlin.version}</version> | |
</dependency> | |
</dependencies> | |
</plugin> | |
</plugins> | |
</build> | |
</project> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.fnreport | |
import com.github.h0tk3y.betterParse.combinators.use | |
import com.github.h0tk3y.betterParse.grammar.Grammar | |
import com.github.h0tk3y.betterParse.grammar.tryParseToEnd | |
import com.github.h0tk3y.betterParse.lexer.LiteralToken | |
import com.github.h0tk3y.betterParse.lexer.regexToken | |
import com.github.h0tk3y.betterParse.parser.Parser | |
import io.kotlintest.specs.StringSpec | |
object grammar: Grammar<String?>() { | |
val lit = regexToken("word","[^\\s]+") | |
val word2 = lit use { text} | |
override val rootParser: Parser<String?> by word2 | |
} | |
class sentenceTest : StringSpec() { | |
val in1: String = "<(&&,<$1-->(/,REPRESENT,_,$2)>,<(*,$3,$4)-->REPRESENT>)==><$1-->(/,(/,REPRESENT,_,<(*,$4,$2)-->FOOD>),$3,eat,_)>>.%1.00;0.45%" | |
init { | |
"capture"{ | |
val tryParseToEnd = grammar.tryParseToEnd("word") | |
System.err.println(tryParseToEnd) | |
} | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/usr/lib/jvm/java-12-oracle/bin/java -agentlib:jdwp=transport=dt_socket,address=127.0.0.1:51175,suspend=y,server=n -ea -Didea.test.cyclic.buffer.size=1048576 -javaagent:/home/jim/.local/share/JetBrains/Toolbox/apps/IDEA-U/ch-1/193.4932.9/plugins/java/lib/rt/debugger-agent.jar -agentpath:/tmp/libmemory_agent1138.so= -Dfile.encoding=UTF-8 -classpath /home/jim/.local/share/JetBrains/Toolbox/apps/IDEA-U/ch-1/193.4932.9/lib/idea_rt.jar:/home/jim/.local/share/JetBrains/Toolbox/apps/IDEA-U/ch-1/193.4932.9/plugins/junit/lib/junit5-rt.jar:/home/jim/.local/share/JetBrains/Toolbox/apps/IDEA-U/ch-1/193.4932.9/plugins/junit/lib/junit-rt.jar:/home/jim/work/photon/lownal/target/test-classes:/home/jim/work/photon/lownal/target/classes:/home/jim/.local/share/JetBrains/Toolbox/apps/IDEA-U/ch-1/193.4932.9/lib/groovy-all-2.4.17.jar:/home/jim/.m2/repository/org/jetbrains/kotlinx/kotlinx-coroutines-core/1.3.2/kotlinx-coroutines-core-1.3.2.jar:/home/jim/.m2/repository/org/jetbrains/kotlinx/kotlinx-coroutines-core-common/1.3.2/kotlinx-coroutines-core-common-1.3.2.jar:/home/jim/.m2/repository/org/jetbrains/kotlinx/kotlinx-coroutines-jdk8/1.3.2/kotlinx-coroutines-jdk8-1.3.2.jar:/home/jim/.m2/repository/org/jetbrains/kotlin/kotlin-stdlib/1.3.50/kotlin-stdlib-1.3.50.jar:/home/jim/.m2/repository/org/jetbrains/annotations/13.0/annotations-13.0.jar:/home/jim/.m2/repository/org/jetbrains/kotlin/kotlin-stdlib-common/1.3.50/kotlin-stdlib-common-1.3.50.jar:/home/jim/.m2/repository/org/jetbrains/kotlin/kotlin-stdlib-jdk8/1.3.50/kotlin-stdlib-jdk8-1.3.50.jar:/home/jim/.m2/repository/org/jetbrains/kotlin/kotlin-stdlib-jdk7/1.3.50/kotlin-stdlib-jdk7-1.3.50.jar:/home/jim/.m2/repository/org/jetbrains/kotlin/kotlin-test/1.3.50/kotlin-test-1.3.50.jar:/home/jim/.m2/repository/org/jetbrains/kotlin/kotlin-test-common/1.3.50/kotlin-test-common-1.3.50.jar:/home/jim/.m2/repository/io/kotlintest/kotlintest/2.0.7/kotlintest-2.0.7.jar:/home/jim/.m2/repository/junit/junit/4.12/junit-4.12.jar:/home/jim/.m2/repository/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3.jar:/home/jim/.m2/repository/org/jetbrains/kotlin/kotlin-reflect/1.1.51/kotlin-reflect-1.1.51.jar:/home/jim/.m2/repository/org/mockito/mockito-core/2.7.11/mockito-core-2.7.11.jar:/home/jim/.m2/repository/net/bytebuddy/byte-buddy/1.6.5/byte-buddy-1.6.5.jar:/home/jim/.m2/repository/net/bytebuddy/byte-buddy-agent/1.6.5/byte-buddy-agent-1.6.5.jar:/home/jim/.m2/repository/org/objenesis/objenesis/2.5/objenesis-2.5.jar:/home/jim/.m2/repository/org/reflections/reflections/0.9.11/reflections-0.9.11.jar:/home/jim/.m2/repository/com/google/guava/guava/20.0/guava-20.0.jar:/home/jim/.m2/repository/org/javassist/javassist/3.21.0-GA/javassist-3.21.0-GA.jar:/home/jim/.m2/repository/io/kotlintest/kotlintest-core/3.4.1/kotlintest-core-3.4.1.jar:/home/jim/.m2/repository/org/slf4j/slf4j-api/1.7.25/slf4j-api-1.7.25.jar:/home/jim/.m2/repository/org/junit/jupiter/junit-jupiter-api/5.5.1/junit-jupiter-api-5.5.1.jar:/home/jim/.m2/repository/org/apiguardian/apiguardian-api/1.1.0/apiguardian-api-1.1.0.jar:/home/jim/.m2/repository/org/opentest4j/opentest4j/1.2.0/opentest4j-1.2.0.jar:/home/jim/.m2/repository/org/junit/platform/junit-platform-commons/1.5.1/junit-platform-commons-1.5.1.jar:/home/jim/.m2/repository/io/kotlintest/kotlintest-assertions/3.4.1/kotlintest-assertions-3.4.1.jar:/home/jim/.m2/repository/io/arrow-kt/arrow-core-data/0.9.0/arrow-core-data-0.9.0.jar:/home/jim/.m2/repository/io/arrow-kt/arrow-annotations/0.9.0/arrow-annotations-0.9.0.jar:/home/jim/.m2/repository/io/kindedj/kindedj/1.1.0/kindedj-1.1.0.jar:/home/jim/.m2/repository/com/univocity/univocity-parsers/2.8.1/univocity-parsers-2.8.1.jar:/home/jim/.m2/repository/com/github/wumpz/diffutils/2.2/diffutils-2.2.jar:/home/jim/.m2/repository/org/eclipse/jgit/org.eclipse.jgit/4.4.1.201607150455-r/org.eclipse.jgit-4.4.1.201607150455-r.jar:/home/jim/.m2/repository/com/github/h0tk3y/betterParse/better-parse-multiplatform-jvm/0.4.2/better-parse-multiplatform-jvm-0.4.2.jar com.intellij.rt.junit.JUnitStarter -ideVersion5 -junit4 com.fnreport.sentenceTest | |
Connected to the target VM, address: '127.0.0.1:0', transport: 'socket' | |
Java HotSpot(TM) 64-Bit Server VM warning: Sharing is only supported for boot loader classes because bootstrap classpath has been appended | |
java.lang.IllegalArgumentException: The tokens list should not be empty | |
at com.github.h0tk3y.betterParse.lexer.DefaultTokenizer.<init>(DefaultTokenizer.kt:9) | |
at com.github.h0tk3y.betterParse.grammar.Grammar$tokenizer$2.invoke(Grammar.kt:31) | |
at com.github.h0tk3y.betterParse.grammar.Grammar$tokenizer$2.invoke(Grammar.kt:17) | |
at kotlin.SynchronizedLazyImpl.getValue(LazyJVM.kt:74) | |
at com.github.h0tk3y.betterParse.grammar.Grammar.getTokenizer(Grammar.kt) | |
at com.github.h0tk3y.betterParse.grammar.GrammarKt.tryParseToEnd(Grammar.kt:63) | |
at com.fnreport.sentenceTest$1.invoke(sentenceTest.kt:23) | |
at com.fnreport.sentenceTest$1.invoke(sentenceTest.kt:18) | |
at io.kotlintest.Spec$runTest$callable$1$1.invoke(Spec.kt:124) | |
at io.kotlintest.Spec$runTest$callable$1$1.invoke(Spec.kt:15) | |
at io.kotlintest.Spec$runTest$initialInterceptor$1$1.invoke(Spec.kt:116) | |
at io.kotlintest.Spec$runTest$initialInterceptor$1$1.invoke(Spec.kt:15) | |
at io.kotlintest.Spec.interceptTestCase(Spec.kt:78) | |
at io.kotlintest.Spec$runTest$initialInterceptor$1.invoke(Spec.kt:116) | |
at io.kotlintest.Spec$runTest$initialInterceptor$1.invoke(Spec.kt:15) | |
at io.kotlintest.Spec$runTest$callable$1.call(Spec.kt:124) | |
at java.base/java.util.concurrent.FutureTask.run$$$capture(FutureTask.java:264) | |
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java) | |
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) | |
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) | |
at java.base/java.lang.Thread.run(Thread.java:835) | |
Disconnected from the target VM, address: '127.0.0.1:0', transport: 'socket' | |
Process finished with exit code 255 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment