Skip to content
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
12 changes: 8 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,25 +12,25 @@ 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:

```xml
<dependency>
<groupId>net.vieiro</groupId>
<artifactId>toml-java</artifactId>
<version>13.4.1</version>
<version>13.4.2</version>
</dependency>
```

Gradle:

```groovy
implementation 'net.vieiro:toml-java:13.4.1'
implementation 'net.vieiro:toml-java:13.4.2'
```

## Basic usage
Expand Down Expand Up @@ -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.

2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>net.vieiro</groupId>
<artifactId>toml-java</artifactId>
<version>13.4.2-SNAPSHOT</version>
<version>13.4.3-SNAPSHOT</version>
<packaging>jar</packaging>

<name>toml-java</name>
Expand Down
6 changes: 6 additions & 0 deletions src/main/antlr4/net/vieiro/toml/antlr4/TOMLAntlrLexer.g4
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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;

34 changes: 34 additions & 0 deletions src/test/java/net/vieiro/toml/invalid/TOMLInvalidDocumentTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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));
}
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[plugins]
jooq-codegen = { id = "org.jooq.jooq-codegen-gradle", version.ref="jooq"

Loading