From 2665bda5639db1830225a6236b5d4066bc76ec78 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Koz=C5=82owski?= Date: Thu, 18 Jul 2024 02:21:15 +0200 Subject: [PATCH] update json syntax & remove error listener --- modules/parser/src/main/antlr4/Tokens.g4 | 6 +++--- .../playground/smithyql/parser/v3/Demo.scala | 15 +++++++-------- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/modules/parser/src/main/antlr4/Tokens.g4 b/modules/parser/src/main/antlr4/Tokens.g4 index d9df2323..e56ed32a 100644 --- a/modules/parser/src/main/antlr4/Tokens.g4 +++ b/modules/parser/src/main/antlr4/Tokens.g4 @@ -18,7 +18,7 @@ NULL: 'null'; ID: [a-zA-Z][a-zA-Z_0-9]*; // string and number tokens stolen from JSON -// https://github.com/antlr/grammars-v4/blob/c9e5c8caca0b562805711b22d04a8ce39d012461/json/JSON.g4 +// https://github.com/antlr/grammars-v4/blob/b2a35350cbce75b2d47c659ccbadba78a89310ef/json/JSON.g4 STRING: '"' (ESC | SAFECODEPOINT)* '"'; fragment ESC: '\\' (["\\/bfnrt] | UNICODE); @@ -37,6 +37,6 @@ fragment INT: // integer part forbids leading 0s (e.g. `01`) // no leading zeros fragment EXP: // exponent number permits leading 0s (e.g. `1e01`) - [Ee] [+\-]? [0-9]+; + [Ee] [+-]? [0-9]+; -WS: [ \t\n\r\f]+ -> skip; +WS: [ \t\n\r]+ -> skip; diff --git a/modules/parser/src/main/scala/playground/smithyql/parser/v3/Demo.scala b/modules/parser/src/main/scala/playground/smithyql/parser/v3/Demo.scala index 17b4e33e..56aef7be 100644 --- a/modules/parser/src/main/scala/playground/smithyql/parser/v3/Demo.scala +++ b/modules/parser/src/main/scala/playground/smithyql/parser/v3/Demo.scala @@ -23,14 +23,12 @@ object Demo { args: Array[String] ): Unit = { val input = - """ - use - use service ..# - use service x# - use service a#oho - use service b - use service #foo - """.stripMargin + """|use + |use service ..# + |use service x# + |use service a#oho + |use service b + |use service #foo""".stripMargin val l = new Tokens(CharStreams.fromString(input)) @@ -163,6 +161,7 @@ object Demo { println("result: " + r.map(_.sequence)) p.reset() + p.removeErrorListeners() val r2 = new YikesBaseVisitor[EitherNel[String, Any]] { override def visitSource_file(