diff --git a/README.md b/README.md
index 8eacc28..351a684 100644
--- a/README.md
+++ b/README.md
@@ -12,10 +12,10 @@ A parser for [TOML](https://toml.io/en/) files with minimum dependencies.
## Maven & Gradle coordinates
-- Current version: 13.4.1
+- Current version: 13.4.2
- 13 - Dependency on Antlr 4.13.1
- 4 - TOML grammar version 4
- - 1 - Release 1
+ - 2 - Release 2
Maven:
@@ -23,14 +23,14 @@ Maven:
net.vieiro
toml-java
- 13.4.1
+ 13.4.2
```
Gradle:
```groovy
-implementation 'net.vieiro:toml-java:13.4.1'
+implementation 'net.vieiro:toml-java:13.4.2'
```
## Basic usage
@@ -228,3 +228,7 @@ This version depends on Antlr4 v4.11.1 (changed to adhere to NetBeans Antlr4 ver
- Downgrading to JDK8 class format.
- Grammar updated to version 4: lexer detects more unexpected tokens.
+## 13.4.2
+
+- Handling of unclosed inline-tables and arrays with invalid tokens for NetBeans.
+
diff --git a/pom.xml b/pom.xml
index 1b612e7..7dc19ba 100644
--- a/pom.xml
+++ b/pom.xml
@@ -3,7 +3,7 @@
4.0.0
net.vieiro
toml-java
- 13.4.2-SNAPSHOT
+ 13.4.3-SNAPSHOT
jar
toml-java
diff --git a/src/main/antlr4/net/vieiro/toml/antlr4/TOMLAntlrLexer.g4 b/src/main/antlr4/net/vieiro/toml/antlr4/TOMLAntlrLexer.g4
index adf92cc..fec1982 100644
--- a/src/main/antlr4/net/vieiro/toml/antlr4/TOMLAntlrLexer.g4
+++ b/src/main/antlr4/net/vieiro/toml/antlr4/TOMLAntlrLexer.g4
@@ -149,6 +149,9 @@ INLINE_TABLE_KEY_UNQUOTED: UNQUOTED_KEY -> type(UNQUOTED_KEY) ;
INLINE_TABLE_EQUALS : EQUALS -> type(EQUALS), pushMode(SIMPLE_VALUE_MODE) ;
+INLINE_TABLE_UNEXPECTED : . -> type(INVALID_VALUE), popMode;
+INLINE_TABLE_EOF: EOF -> type(INVALID_VALUE), popMode;
+
//----------------------------------------------------------------------
mode ARRAY_MODE;
@@ -185,3 +188,6 @@ ARRAY_LOCAL_DATE_TIME : LOCAL_DATE_TIME -> type(LOCAL_DATE_TIME) ;
ARRAY_LOCAL_DATE : LOCAL_DATE -> type(LOCAL_DATE) ;
ARRAY_LOCAL_TIME : LOCAL_TIME -> type(LOCAL_TIME) ;
+ARRAY_UNEXPECTED: . -> type(INVALID_VALUE), popMode;
+ARRAY_EOF : EOF -> type(INVALID_VALUE), popMode;
+
diff --git a/src/test/java/net/vieiro/toml/invalid/TOMLInvalidDocumentTest.java b/src/test/java/net/vieiro/toml/invalid/TOMLInvalidDocumentTest.java
index adb8260..edf8f9d 100644
--- a/src/test/java/net/vieiro/toml/invalid/TOMLInvalidDocumentTest.java
+++ b/src/test/java/net/vieiro/toml/invalid/TOMLInvalidDocumentTest.java
@@ -151,6 +151,7 @@ public class TOMLInvalidDocumentTest {
"invalid/inline-table/no-comma.toml",
"invalid/inline-table/overwrite.toml",
"invalid/inline-table/trailing-comma.toml",
+ "invalid/inline-table/unclosed-table.toml",
"invalid/integer/capital-bin.toml",
"invalid/integer/capital-hex.toml",
"invalid/integer/capital-oct.toml",
@@ -316,4 +317,37 @@ public void testShouldDetectErrorsInInvalidTOMLDocuments(String tomlInvalidDocum
}
}
+ @ParameterizedTest()
+ @ValueSource(strings = {
+ "invalid/inline-table/unclosed-table.toml",
+ })
+ public void testShouldBehaveOnUnclosedTable(String tomlInvalidDocumentName) {
+ System.out.format("testShouldDetectErrorsInInvalidTOMLDocuments - %s%n", tomlInvalidDocumentName);
+
+ boolean verbose = true;
+
+ // Given a TOML document with errors
+ TOML toml = null;
+
+ try {
+ toml = Util.parse(tomlInvalidDocumentName, verbose, true);
+ } catch (Exception e) {
+ String message = String.format("Test '%s failed with exception %s:%s", tomlInvalidDocumentName, e.getMessage(), e.getClass().getName());
+ fail(message, e);
+ }
+
+ // Then the number of detected errors should be equal to the number of expected errors.
+ int numberOfDetectedErrors = toml.getErrors().size();
+
+ if (numberOfDetectedErrors > 0) {
+ if (verbose) {
+ for (String error : toml.getErrors()) {
+ System.out.format(" - ERROR: %s: %s%n", tomlInvalidDocumentName, error);
+ }
+ }
+ } else {
+ fail(String.format(" Test %s must fail, but doesn't", tomlInvalidDocumentName));
+ }
+ }
+
}
diff --git a/src/test/resources/net/vieiro/toml/invalid/inline-table/unclosed-table.toml b/src/test/resources/net/vieiro/toml/invalid/inline-table/unclosed-table.toml
new file mode 100644
index 0000000..34375ea
--- /dev/null
+++ b/src/test/resources/net/vieiro/toml/invalid/inline-table/unclosed-table.toml
@@ -0,0 +1,3 @@
+[plugins]
+jooq-codegen = { id = "org.jooq.jooq-codegen-gradle", version.ref="jooq"
+