diff --git a/.env b/.env
index 82d9351..524ecbd 100644
--- a/.env
+++ b/.env
@@ -1,17 +1,16 @@
-# hhh
-# hhh \n \r\t abc
-
-
-# hhh
+# type int
INT=90898
-#hello
-DDD=
-#word
-DOUBLE=90898.909
-#hello
-BOOL=true
-#hhh
-
-BAC=18237
-CDB='18237'
-CDBD="18237"
+SIGNED_INT=-8898
+# type double
+DOUBLE=3.1415926
+SIGNED_DOUBLE=-.123
+# type bool
+BOOL=false
+# type string
+STRING=AAA
+NO_QUOTE_STRING=ABC9shj"\'\''';';;;'\n\r\thttps://google.com
+SINGLE_QUOTE_STRING='AB\r\n\ta\'\"C'
+DOUBLE_QUOTE_STRING="ABC"
+JSON={"a":1,"b":[1,true,"hello"]}
+EMPTY=
+EMPTY_COMMENT=#EMPTY
diff --git a/.env.prod b/.env.prod
index 9760d20..e5afae5 100644
--- a/.env.prod
+++ b/.env.prod
@@ -1,4 +1,5 @@
-#word
-DOUBLE=123456
+# covered
+BOOL=true
+# specical
QWERTY=-0.343
diff --git a/.run/env2dart.dart.run.xml b/.run/env2dart.dart.run.xml
index c3d608e..48e49da 100644
--- a/.run/env2dart.dart.run.xml
+++ b/.run/env2dart.dart.run.xml
@@ -1,7 +1,10 @@
+
-
+
+
+
\ No newline at end of file
diff --git a/LICENSE b/LICENSE
index 261eeb9..0ad5af0 100644
--- a/LICENSE
+++ b/LICENSE
@@ -186,7 +186,7 @@
same "printed page" as the copyright notice for easier
identification within third-party archives.
- Copyright [yyyy] [name of copyright owner]
+ Copyright 2023 IOTA9STAR
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
diff --git a/README-ZH.md b/README-ZH.md
index d1f5099..fa1798e 100644
--- a/README-ZH.md
+++ b/README-ZH.md
@@ -1,5 +1,7 @@
# Env2dart
+    
+
[English](README.md) | 简体中文
一种简单的方式将 `.env` 文件生成 `dart` 代码。
@@ -22,11 +24,273 @@ env2dart
```text
-p, --path 指定工作目录,CLI 将在当前目录中查找 .env 文件。
- (默认为 "./")
+ (默认为 "")
-o, --output 指定输出文件路径。
+ (默认为 "lib/env.g.dart")
-a, --active 指定要使用的环境变量。例如,如果指定了 `-active prod`,CLI 将查找 .env.prod 文件并将其与 .env 文件合并。
-c, --class 指定生成类的名称。
(默认为 "Env")
-h, --help 查看帮助选项。
```
+
+## 示例
+
+
+ 代码示例
+
+
+ .env
+
+#### [.env](.env)
+
+```dotenv
+# type int
+INT=90898
+SIGNED_INT=-8898
+# type double
+DOUBLE=3.1415926
+SIGNED_DOUBLE=-.123
+# type bool
+BOOL=false
+# type string
+STRING=AAA
+NO_QUOTE_STRING=ABC9shj"\'\''';';;;'\n\r\thttps://google.com
+SINGLE_QUOTE_STRING='AB\r\n\ta\'\"C'
+DOUBLE_QUOTE_STRING="ABC"
+JSON={"a":1,"b":[1,true,"hello"]}
+EMPTY=
+EMPTY_COMMENT=#EMPTY
+```
+
+
+
+
+ .env.prod
+
+#### [.env.prod](.env.prod)
+
+```dotenv
+# covered
+BOOL=true
+
+# specical
+QWERTY=-0.343
+```
+
+
+
+
+ env.g.dart
+
+
+#### [env.g.dart](example/env.g.dart)
+
+```dart
+// coverage:ignore-file
+// ignore_for_file: camel_case_types, non_constant_identifier_names, prefer_single_quotes
+// ======================================
+// GENERATED CODE - DO NOT MODIFY BY HAND
+// ======================================
+
+abstract class Env {
+ const factory Env() = _Prod._;
+
+ static final String active = 'prod';
+
+ /// From .env
+ ///
+ /// >> INT = 90898
+ ///
+ /// type int
+ ///
+ int get INT;
+
+ /// From .env
+ ///
+ /// >> SIGNED_INT = -8898
+ ///
+ int get SIGNED_INT;
+
+ /// From .env
+ ///
+ /// >> DOUBLE = 3.1415926
+ ///
+ /// type double
+ ///
+ double get DOUBLE;
+
+ /// From .env
+ ///
+ /// >> SIGNED_DOUBLE = -.123
+ ///
+ double get SIGNED_DOUBLE;
+
+ /// Covered the default value
+ ///
+ /// false => true
+ /// ========================================
+ /// From .env
+ ///
+ /// >> BOOL = false
+ ///
+ /// type bool
+ ///
+ /// ========================================
+ /// From .env.prod
+ ///
+ /// >> BOOL = true
+ ///
+ /// covered
+ ///
+ bool get BOOL;
+
+ /// From .env
+ ///
+ /// >> STRING = AAA
+ ///
+ /// type string
+ ///
+ String get STRING;
+
+ /// From .env
+ ///
+ /// >> NO_QUOTE_STRING = ABC9shj"\'\''';';;;'\n\r\thttps://google.com
+ ///
+ String get NO_QUOTE_STRING;
+
+ /// From .env
+ ///
+ /// >> SINGLE_QUOTE_STRING = 'AB\r\n\ta\'\"C'
+ ///
+ String get SINGLE_QUOTE_STRING;
+
+ /// From .env
+ ///
+ /// >> DOUBLE_QUOTE_STRING = "ABC"
+ ///
+ String get DOUBLE_QUOTE_STRING;
+
+ /// From .env
+ ///
+ /// >> JSON = {"a":1,"b":[1,true,"hello"]}
+ ///
+ String get JSON;
+
+ /// From .env
+ ///
+ /// >> EMPTY =
+ ///
+ String get EMPTY;
+
+ /// From .env
+ ///
+ /// >> EMPTY_COMMENT =
+ ///
+ /// EMPTY
+ ///
+ String get EMPTY_COMMENT;
+
+ /// From .env.prod
+ ///
+ /// >> QWERTY = -0.343
+ ///
+ /// specical
+ ///
+ double get QWERTY;
+
+ Map toJson();
+}
+
+class _Prod implements Env {
+ const _Prod._();
+
+ @override
+ int get INT => 90898;
+
+ @override
+ int get SIGNED_INT => -8898;
+
+ @override
+ double get DOUBLE => 3.1415926;
+
+ @override
+ double get SIGNED_DOUBLE => -0.123;
+
+ @override
+ bool get BOOL => true;
+
+ @override
+ String get STRING => "AAA";
+
+ @override
+ String get NO_QUOTE_STRING =>
+ "ABC9shj\"\\'\\''';';;;'\\n\\r\\thttps://google.com";
+
+ @override
+ String get SINGLE_QUOTE_STRING => "'AB\\r\\n\\ta\\'\\\"C'";
+
+ @override
+ String get DOUBLE_QUOTE_STRING => "ABC";
+
+ @override
+ String get JSON => "{\"a\":1,\"b\":[1,true,\"hello\"]}";
+
+ @override
+ String get EMPTY => '';
+
+ @override
+ String get EMPTY_COMMENT => '';
+
+ @override
+ double get QWERTY => -0.343;
+
+ @override
+ Map toJson() {
+ return {
+ 'INT': 90898,
+ 'SIGNED_INT': -8898,
+ 'DOUBLE': 3.1415926,
+ 'SIGNED_DOUBLE': -0.123,
+ 'BOOL': true,
+ 'STRING': "AAA",
+ 'NO_QUOTE_STRING': "ABC9shj\"\\'\\''';';;;'\\n\\r\\thttps://google.com",
+ 'SINGLE_QUOTE_STRING': "'AB\\r\\n\\ta\\'\\\"C'",
+ 'DOUBLE_QUOTE_STRING': "ABC",
+ 'JSON': "{\"a\":1,\"b\":[1,true,\"hello\"]}",
+ 'EMPTY': '',
+ 'EMPTY_COMMENT': '',
+ 'QWERTY': -0.343,
+ };
+ }
+}
+```
+
+
+
+
+
+## 统计
+
+
+
+[](https://stars.medv.io/fluttercandies/env2dart)
+
+## Licenses
+
+``` text
+Copyright 2023 iota9star
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ https://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+```
+
diff --git a/README.md b/README.md
index 0dd5691..0ac05d1 100644
--- a/README.md
+++ b/README.md
@@ -1,5 +1,7 @@
# Env2dart
+    
+
English | [简体中文](README-ZH.md)
A simple way to generate `dart` code from a `.env` file.
@@ -18,14 +20,275 @@ dart pub global activate env2dart
env2dart
```
-## Command-line Arguments
+## CLI
```text
-p, --path Specify working directory, the CLI will look for the .env file in the current directory.
- (defaults to "./")
+ (defaults to "")
-o, --output Specify the output file path.
+ (defaults to "lib/env.g.dart")
-a, --active Specify the environment variables to use. For example, if -active prod is specified, the CLI will look for the .env.prod file and merge it with the .env file.
-c, --class Specify the name for the generated class
(defaults to "Env")
-h, --help View help options.
```
+
+## Example
+
+
+ Code Example
+
+
+ .env
+
+#### [.env](.env)
+
+```dotenv
+# type int
+INT=90898
+SIGNED_INT=-8898
+# type double
+DOUBLE=3.1415926
+SIGNED_DOUBLE=-.123
+# type bool
+BOOL=false
+# type string
+STRING=AAA
+NO_QUOTE_STRING=ABC9shj"\'\''';';;;'\n\r\thttps://google.com
+SINGLE_QUOTE_STRING='AB\r\n\ta\'\"C'
+DOUBLE_QUOTE_STRING="ABC"
+JSON={"a":1,"b":[1,true,"hello"]}
+EMPTY=
+EMPTY_COMMENT=#EMPTY
+```
+
+
+
+
+ .env.prod
+
+#### [.env.prod](.env.prod)
+
+```dotenv
+# covered
+BOOL=true
+
+# specical
+QWERTY=-0.343
+```
+
+
+
+
+ env.g.dart
+
+
+#### [env.g.dart](example/env.g.dart)
+
+```dart
+// coverage:ignore-file
+// ignore_for_file: camel_case_types, non_constant_identifier_names, prefer_single_quotes
+// ======================================
+// GENERATED CODE - DO NOT MODIFY BY HAND
+// ======================================
+
+abstract class Env {
+ const factory Env() = _Prod._;
+
+ static final String active = 'prod';
+
+ /// From .env
+ ///
+ /// >> INT = 90898
+ ///
+ /// type int
+ ///
+ int get INT;
+
+ /// From .env
+ ///
+ /// >> SIGNED_INT = -8898
+ ///
+ int get SIGNED_INT;
+
+ /// From .env
+ ///
+ /// >> DOUBLE = 3.1415926
+ ///
+ /// type double
+ ///
+ double get DOUBLE;
+
+ /// From .env
+ ///
+ /// >> SIGNED_DOUBLE = -.123
+ ///
+ double get SIGNED_DOUBLE;
+
+ /// Covered the default value
+ ///
+ /// false => true
+ /// ========================================
+ /// From .env
+ ///
+ /// >> BOOL = false
+ ///
+ /// type bool
+ ///
+ /// ========================================
+ /// From .env.prod
+ ///
+ /// >> BOOL = true
+ ///
+ /// covered
+ ///
+ bool get BOOL;
+
+ /// From .env
+ ///
+ /// >> STRING = AAA
+ ///
+ /// type string
+ ///
+ String get STRING;
+
+ /// From .env
+ ///
+ /// >> NO_QUOTE_STRING = ABC9shj"\'\''';';;;'\n\r\thttps://google.com
+ ///
+ String get NO_QUOTE_STRING;
+
+ /// From .env
+ ///
+ /// >> SINGLE_QUOTE_STRING = 'AB\r\n\ta\'\"C'
+ ///
+ String get SINGLE_QUOTE_STRING;
+
+ /// From .env
+ ///
+ /// >> DOUBLE_QUOTE_STRING = "ABC"
+ ///
+ String get DOUBLE_QUOTE_STRING;
+
+ /// From .env
+ ///
+ /// >> JSON = {"a":1,"b":[1,true,"hello"]}
+ ///
+ String get JSON;
+
+ /// From .env
+ ///
+ /// >> EMPTY =
+ ///
+ String get EMPTY;
+
+ /// From .env
+ ///
+ /// >> EMPTY_COMMENT =
+ ///
+ /// EMPTY
+ ///
+ String get EMPTY_COMMENT;
+
+ /// From .env.prod
+ ///
+ /// >> QWERTY = -0.343
+ ///
+ /// specical
+ ///
+ double get QWERTY;
+
+ Map toJson();
+}
+
+class _Prod implements Env {
+ const _Prod._();
+
+ @override
+ int get INT => 90898;
+
+ @override
+ int get SIGNED_INT => -8898;
+
+ @override
+ double get DOUBLE => 3.1415926;
+
+ @override
+ double get SIGNED_DOUBLE => -0.123;
+
+ @override
+ bool get BOOL => true;
+
+ @override
+ String get STRING => "AAA";
+
+ @override
+ String get NO_QUOTE_STRING =>
+ "ABC9shj\"\\'\\''';';;;'\\n\\r\\thttps://google.com";
+
+ @override
+ String get SINGLE_QUOTE_STRING => "'AB\\r\\n\\ta\\'\\\"C'";
+
+ @override
+ String get DOUBLE_QUOTE_STRING => "ABC";
+
+ @override
+ String get JSON => "{\"a\":1,\"b\":[1,true,\"hello\"]}";
+
+ @override
+ String get EMPTY => '';
+
+ @override
+ String get EMPTY_COMMENT => '';
+
+ @override
+ double get QWERTY => -0.343;
+
+ @override
+ Map toJson() {
+ return {
+ 'INT': 90898,
+ 'SIGNED_INT': -8898,
+ 'DOUBLE': 3.1415926,
+ 'SIGNED_DOUBLE': -0.123,
+ 'BOOL': true,
+ 'STRING': "AAA",
+ 'NO_QUOTE_STRING': "ABC9shj\"\\'\\''';';;;'\\n\\r\\thttps://google.com",
+ 'SINGLE_QUOTE_STRING': "'AB\\r\\n\\ta\\'\\\"C'",
+ 'DOUBLE_QUOTE_STRING': "ABC",
+ 'JSON': "{\"a\":1,\"b\":[1,true,\"hello\"]}",
+ 'EMPTY': '',
+ 'EMPTY_COMMENT': '',
+ 'QWERTY': -0.343,
+ };
+ }
+}
+```
+
+
+
+
+
+## Statistics
+
+
+
+[](https://stars.medv.io/fluttercandies/env2dart)
+
+## Licenses
+
+``` text
+Copyright 2023 iota9star
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ https://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+```
diff --git a/antlr/Env.g4 b/antlr/Env.g4
index 597a43a..4f10c8b 100644
--- a/antlr/Env.g4
+++ b/antlr/Env.g4
@@ -5,14 +5,13 @@ line: (comment NEWLINE)* key '=' value? comment? | NEWLINE;
key: KEY;
value: INT | DOUBLE | BOOLEAN | string;
comment: COMMENT;
+string: SINGLE_QUOTE_STRING | DOUBLE_QUOTE_STRING | NO_QUOTE_STRING | KEY;
KEY: [A-Z_][A-Z0-9_]*;
NEWLINE: [\r\n]+;
-NOTLINE: ~[\r\n];
COMMENT: '#' ~[\r\n]*;
INT: '-'? [0-9]+;
-DOUBLE: '-'? [0-9]+ '.' [0-9]+;
+DOUBLE: '-'? [0-9]? '.' [0-9]+;
BOOLEAN: 'true' | 'false';
-string: SINGLE_QUOTE_STRING | DOUBLE_QUOTE_STRING | NO_QUOTE_STRING;
fragment ESC : '\\' ["\\/bfnrt];
SINGLE_QUOTE_STRING : '\'' (ESC | ~['\\])* '\'';
DOUBLE_QUOTE_STRING : '"' (ESC | ~["\\])* '"';
diff --git a/example/env.g.dart b/example/env.g.dart
new file mode 100644
index 0000000..ffe1932
--- /dev/null
+++ b/example/env.g.dart
@@ -0,0 +1,163 @@
+// coverage:ignore-file
+// ignore_for_file: camel_case_types, non_constant_identifier_names, prefer_single_quotes
+// ======================================
+// GENERATED CODE - DO NOT MODIFY BY HAND
+// ======================================
+
+abstract class Env {
+ const factory Env() = _Prod._;
+
+ static final String active = 'prod';
+
+ /// From .env
+ ///
+ /// >> INT = 90898
+ ///
+ /// type int
+ ///
+ int get INT;
+
+ /// From .env
+ ///
+ /// >> SIGNED_INT = -8898
+ ///
+ int get SIGNED_INT;
+
+ /// From .env
+ ///
+ /// >> DOUBLE = 3.1415926
+ ///
+ /// type double
+ ///
+ double get DOUBLE;
+
+ /// From .env
+ ///
+ /// >> SIGNED_DOUBLE = -.123
+ ///
+ double get SIGNED_DOUBLE;
+
+ /// Covered the default value
+ ///
+ /// false => true
+ /// ========================================
+ /// From .env
+ ///
+ /// >> BOOL = false
+ ///
+ /// type bool
+ ///
+ /// ========================================
+ /// From .env.prod
+ ///
+ /// >> BOOL = true
+ ///
+ /// covered
+ ///
+ bool get BOOL;
+
+ /// From .env
+ ///
+ /// >> STRING = AAA
+ ///
+ /// type string
+ ///
+ String get STRING;
+
+ /// From .env
+ ///
+ /// >> NO_QUOTE_STRING = ABC9shj"\'\''';';;;'\n\r\thttps://google.com
+ ///
+ String get NO_QUOTE_STRING;
+
+ /// From .env
+ ///
+ /// >> SINGLE_QUOTE_STRING = 'AB\r\n\ta\'\"C'
+ ///
+ String get SINGLE_QUOTE_STRING;
+
+ /// From .env
+ ///
+ /// >> DOUBLE_QUOTE_STRING = "ABC"
+ ///
+ String get DOUBLE_QUOTE_STRING;
+
+ /// From .env
+ ///
+ /// >> JSON = {"a":1,"b":[1,true,"hello"]}
+ ///
+ String get JSON;
+
+ /// From .env
+ ///
+ /// >> EMPTY =
+ ///
+ String get EMPTY;
+
+ /// From .env
+ ///
+ /// >> EMPTY_COMMENT =
+ ///
+ /// EMPTY
+ ///
+ String get EMPTY_COMMENT;
+
+ /// From .env.prod
+ ///
+ /// >> QWERTY = -0.343
+ ///
+ /// specical
+ ///
+ double get QWERTY;
+ Map toJson();
+}
+
+class _Prod implements Env {
+ const _Prod._();
+
+ @override
+ int get INT => 90898;
+ @override
+ int get SIGNED_INT => -8898;
+ @override
+ double get DOUBLE => 3.1415926;
+ @override
+ double get SIGNED_DOUBLE => -0.123;
+ @override
+ bool get BOOL => true;
+ @override
+ String get STRING => "AAA";
+ @override
+ String get NO_QUOTE_STRING =>
+ "ABC9shj\"\\'\\''';';;;'\\n\\r\\thttps://google.com";
+ @override
+ String get SINGLE_QUOTE_STRING => "'AB\\r\\n\\ta\\'\\\"C'";
+ @override
+ String get DOUBLE_QUOTE_STRING => "ABC";
+ @override
+ String get JSON => "{\"a\":1,\"b\":[1,true,\"hello\"]}";
+ @override
+ String get EMPTY => '';
+ @override
+ String get EMPTY_COMMENT => '';
+ @override
+ double get QWERTY => -0.343;
+ @override
+ Map toJson() {
+ return {
+ 'INT': 90898,
+ 'SIGNED_INT': -8898,
+ 'DOUBLE': 3.1415926,
+ 'SIGNED_DOUBLE': -0.123,
+ 'BOOL': true,
+ 'STRING': "AAA",
+ 'NO_QUOTE_STRING': "ABC9shj\"\\'\\''';';;;'\\n\\r\\thttps://google.com",
+ 'SINGLE_QUOTE_STRING': "'AB\\r\\n\\ta\\'\\\"C'",
+ 'DOUBLE_QUOTE_STRING': "ABC",
+ 'JSON': "{\"a\":1,\"b\":[1,true,\"hello\"]}",
+ 'EMPTY': '',
+ 'EMPTY_COMMENT': '',
+ 'QWERTY': -0.343,
+ };
+ }
+}
diff --git a/example/main.dart b/example/main.dart
new file mode 100644
index 0000000..f5259d1
--- /dev/null
+++ b/example/main.dart
@@ -0,0 +1,3 @@
+import 'package:env2dart/env2dart.dart';
+
+void main() => parseAndGen(["-o", "./lib/env.g.dart"]);
diff --git a/lib/antlr/Env.interp b/lib/antlr/Env.interp
index 29662bf..3b82ff0 100644
--- a/lib/antlr/Env.interp
+++ b/lib/antlr/Env.interp
@@ -11,14 +11,12 @@ null
null
null
null
-null
token symbolic names:
null
null
KEY
NEWLINE
-NOTLINE
COMMENT
INT
DOUBLE
@@ -38,4 +36,4 @@ string
atn:
-[4, 1, 12, 50, 2, 0, 7, 0, 2, 1, 7, 1, 2, 2, 7, 2, 2, 3, 7, 3, 2, 4, 7, 4, 2, 5, 7, 5, 1, 0, 5, 0, 14, 8, 0, 10, 0, 12, 0, 17, 9, 0, 1, 1, 1, 1, 1, 1, 5, 1, 22, 8, 1, 10, 1, 12, 1, 25, 9, 1, 1, 1, 1, 1, 1, 1, 3, 1, 30, 8, 1, 1, 1, 3, 1, 33, 8, 1, 1, 1, 3, 1, 36, 8, 1, 1, 2, 1, 2, 1, 3, 1, 3, 1, 3, 1, 3, 3, 3, 44, 8, 3, 1, 4, 1, 4, 1, 5, 1, 5, 1, 5, 0, 0, 6, 0, 2, 4, 6, 8, 10, 0, 1, 1, 0, 9, 11, 51, 0, 15, 1, 0, 0, 0, 2, 35, 1, 0, 0, 0, 4, 37, 1, 0, 0, 0, 6, 43, 1, 0, 0, 0, 8, 45, 1, 0, 0, 0, 10, 47, 1, 0, 0, 0, 12, 14, 3, 2, 1, 0, 13, 12, 1, 0, 0, 0, 14, 17, 1, 0, 0, 0, 15, 13, 1, 0, 0, 0, 15, 16, 1, 0, 0, 0, 16, 1, 1, 0, 0, 0, 17, 15, 1, 0, 0, 0, 18, 19, 3, 8, 4, 0, 19, 20, 5, 3, 0, 0, 20, 22, 1, 0, 0, 0, 21, 18, 1, 0, 0, 0, 22, 25, 1, 0, 0, 0, 23, 21, 1, 0, 0, 0, 23, 24, 1, 0, 0, 0, 24, 26, 1, 0, 0, 0, 25, 23, 1, 0, 0, 0, 26, 27, 3, 4, 2, 0, 27, 29, 5, 1, 0, 0, 28, 30, 3, 6, 3, 0, 29, 28, 1, 0, 0, 0, 29, 30, 1, 0, 0, 0, 30, 32, 1, 0, 0, 0, 31, 33, 3, 8, 4, 0, 32, 31, 1, 0, 0, 0, 32, 33, 1, 0, 0, 0, 33, 36, 1, 0, 0, 0, 34, 36, 5, 3, 0, 0, 35, 23, 1, 0, 0, 0, 35, 34, 1, 0, 0, 0, 36, 3, 1, 0, 0, 0, 37, 38, 5, 2, 0, 0, 38, 5, 1, 0, 0, 0, 39, 44, 5, 6, 0, 0, 40, 44, 5, 7, 0, 0, 41, 44, 5, 8, 0, 0, 42, 44, 3, 10, 5, 0, 43, 39, 1, 0, 0, 0, 43, 40, 1, 0, 0, 0, 43, 41, 1, 0, 0, 0, 43, 42, 1, 0, 0, 0, 44, 7, 1, 0, 0, 0, 45, 46, 5, 5, 0, 0, 46, 9, 1, 0, 0, 0, 47, 48, 7, 0, 0, 0, 48, 11, 1, 0, 0, 0, 6, 15, 23, 29, 32, 35, 43]
\ No newline at end of file
+[4, 1, 11, 50, 2, 0, 7, 0, 2, 1, 7, 1, 2, 2, 7, 2, 2, 3, 7, 3, 2, 4, 7, 4, 2, 5, 7, 5, 1, 0, 5, 0, 14, 8, 0, 10, 0, 12, 0, 17, 9, 0, 1, 1, 1, 1, 1, 1, 5, 1, 22, 8, 1, 10, 1, 12, 1, 25, 9, 1, 1, 1, 1, 1, 1, 1, 3, 1, 30, 8, 1, 1, 1, 3, 1, 33, 8, 1, 1, 1, 3, 1, 36, 8, 1, 1, 2, 1, 2, 1, 3, 1, 3, 1, 3, 1, 3, 3, 3, 44, 8, 3, 1, 4, 1, 4, 1, 5, 1, 5, 1, 5, 0, 0, 6, 0, 2, 4, 6, 8, 10, 0, 1, 2, 0, 2, 2, 8, 10, 51, 0, 15, 1, 0, 0, 0, 2, 35, 1, 0, 0, 0, 4, 37, 1, 0, 0, 0, 6, 43, 1, 0, 0, 0, 8, 45, 1, 0, 0, 0, 10, 47, 1, 0, 0, 0, 12, 14, 3, 2, 1, 0, 13, 12, 1, 0, 0, 0, 14, 17, 1, 0, 0, 0, 15, 13, 1, 0, 0, 0, 15, 16, 1, 0, 0, 0, 16, 1, 1, 0, 0, 0, 17, 15, 1, 0, 0, 0, 18, 19, 3, 8, 4, 0, 19, 20, 5, 3, 0, 0, 20, 22, 1, 0, 0, 0, 21, 18, 1, 0, 0, 0, 22, 25, 1, 0, 0, 0, 23, 21, 1, 0, 0, 0, 23, 24, 1, 0, 0, 0, 24, 26, 1, 0, 0, 0, 25, 23, 1, 0, 0, 0, 26, 27, 3, 4, 2, 0, 27, 29, 5, 1, 0, 0, 28, 30, 3, 6, 3, 0, 29, 28, 1, 0, 0, 0, 29, 30, 1, 0, 0, 0, 30, 32, 1, 0, 0, 0, 31, 33, 3, 8, 4, 0, 32, 31, 1, 0, 0, 0, 32, 33, 1, 0, 0, 0, 33, 36, 1, 0, 0, 0, 34, 36, 5, 3, 0, 0, 35, 23, 1, 0, 0, 0, 35, 34, 1, 0, 0, 0, 36, 3, 1, 0, 0, 0, 37, 38, 5, 2, 0, 0, 38, 5, 1, 0, 0, 0, 39, 44, 5, 5, 0, 0, 40, 44, 5, 6, 0, 0, 41, 44, 5, 7, 0, 0, 42, 44, 3, 10, 5, 0, 43, 39, 1, 0, 0, 0, 43, 40, 1, 0, 0, 0, 43, 41, 1, 0, 0, 0, 43, 42, 1, 0, 0, 0, 44, 7, 1, 0, 0, 0, 45, 46, 5, 4, 0, 0, 46, 9, 1, 0, 0, 0, 47, 48, 7, 0, 0, 0, 48, 11, 1, 0, 0, 0, 6, 15, 23, 29, 32, 35, 43]
\ No newline at end of file
diff --git a/lib/antlr/Env.tokens b/lib/antlr/Env.tokens
index e73191c..ccc4aa6 100644
--- a/lib/antlr/Env.tokens
+++ b/lib/antlr/Env.tokens
@@ -1,13 +1,12 @@
T__0=1
KEY=2
NEWLINE=3
-NOTLINE=4
-COMMENT=5
-INT=6
-DOUBLE=7
-BOOLEAN=8
-SINGLE_QUOTE_STRING=9
-DOUBLE_QUOTE_STRING=10
-NO_QUOTE_STRING=11
-WS=12
+COMMENT=4
+INT=5
+DOUBLE=6
+BOOLEAN=7
+SINGLE_QUOTE_STRING=8
+DOUBLE_QUOTE_STRING=9
+NO_QUOTE_STRING=10
+WS=11
'='=1
diff --git a/lib/antlr/EnvLexer.dart b/lib/antlr/EnvLexer.dart
index e468428..e4e0205 100644
--- a/lib/antlr/EnvLexer.dart
+++ b/lib/antlr/EnvLexer.dart
@@ -10,10 +10,9 @@ class EnvLexer extends Lexer {
_ATN.numberOfDecisions, (i) => DFA(_ATN.getDecisionState(i), i));
static final PredictionContextCache _sharedContextCache = PredictionContextCache();
static const int
- TOKEN_T__0 = 1, TOKEN_KEY = 2, TOKEN_NEWLINE = 3, TOKEN_NOTLINE = 4,
- TOKEN_COMMENT = 5, TOKEN_INT = 6, TOKEN_DOUBLE = 7, TOKEN_BOOLEAN = 8,
- TOKEN_SINGLE_QUOTE_STRING = 9, TOKEN_DOUBLE_QUOTE_STRING = 10, TOKEN_NO_QUOTE_STRING = 11,
- TOKEN_WS = 12;
+ TOKEN_T__0 = 1, TOKEN_KEY = 2, TOKEN_NEWLINE = 3, TOKEN_COMMENT = 4,
+ TOKEN_INT = 5, TOKEN_DOUBLE = 6, TOKEN_BOOLEAN = 7, TOKEN_SINGLE_QUOTE_STRING = 8,
+ TOKEN_DOUBLE_QUOTE_STRING = 9, TOKEN_NO_QUOTE_STRING = 10, TOKEN_WS = 11;
@override
final List channelNames = [
'DEFAULT_TOKEN_CHANNEL', 'HIDDEN'
@@ -26,18 +25,16 @@ class EnvLexer extends Lexer {
@override
final List ruleNames = [
- 'T__0', 'KEY', 'NEWLINE', 'NOTLINE', 'COMMENT', 'INT', 'DOUBLE', 'BOOLEAN',
- 'ESC', 'SINGLE_QUOTE_STRING', 'DOUBLE_QUOTE_STRING', 'NO_QUOTE_STRING',
- 'WS'
+ 'T__0', 'KEY', 'NEWLINE', 'COMMENT', 'INT', 'DOUBLE', 'BOOLEAN', 'ESC',
+ 'SINGLE_QUOTE_STRING', 'DOUBLE_QUOTE_STRING', 'NO_QUOTE_STRING', 'WS'
];
static final List _LITERAL_NAMES = [
null, "'='"
];
static final List _SYMBOLIC_NAMES = [
- null, null, "KEY", "NEWLINE", "NOTLINE", "COMMENT", "INT", "DOUBLE",
- "BOOLEAN", "SINGLE_QUOTE_STRING", "DOUBLE_QUOTE_STRING", "NO_QUOTE_STRING",
- "WS"
+ null, null, "KEY", "NEWLINE", "COMMENT", "INT", "DOUBLE", "BOOLEAN",
+ "SINGLE_QUOTE_STRING", "DOUBLE_QUOTE_STRING", "NO_QUOTE_STRING", "WS"
];
static final Vocabulary VOCABULARY = VocabularyImpl(_LITERAL_NAMES, _SYMBOLIC_NAMES);
@@ -61,47 +58,45 @@ class EnvLexer extends Lexer {
ATN getATN() { return _ATN; }
static const List _serializedATN = [
- 4,0,12,115,6,-1,2,0,7,0,2,1,7,1,2,2,7,2,2,3,7,3,2,4,7,4,2,5,7,5,2,
- 6,7,6,2,7,7,7,2,8,7,8,2,9,7,9,2,10,7,10,2,11,7,11,2,12,7,12,1,0,1,
- 0,1,1,1,1,5,1,32,8,1,10,1,12,1,35,9,1,1,2,4,2,38,8,2,11,2,12,2,39,
- 1,3,1,3,1,4,1,4,5,4,46,8,4,10,4,12,4,49,9,4,1,5,3,5,52,8,5,1,5,4,5,
- 55,8,5,11,5,12,5,56,1,6,3,6,60,8,6,1,6,4,6,63,8,6,11,6,12,6,64,1,6,
- 1,6,4,6,69,8,6,11,6,12,6,70,1,7,1,7,1,7,1,7,1,7,1,7,1,7,1,7,1,7,3,
- 7,82,8,7,1,8,1,8,1,8,1,9,1,9,1,9,5,9,90,8,9,10,9,12,9,93,9,9,1,9,1,
- 9,1,10,1,10,1,10,5,10,100,8,10,10,10,12,10,103,9,10,1,10,1,10,1,11,
- 4,11,108,8,11,11,11,12,11,109,1,12,1,12,1,12,1,12,0,0,13,1,1,3,2,5,
- 3,7,4,9,5,11,6,13,7,15,8,17,0,19,9,21,10,23,11,25,12,1,0,9,2,0,65,
- 90,95,95,3,0,48,57,65,90,95,95,2,0,10,10,13,13,1,0,48,57,8,0,34,34,
- 47,47,92,92,98,98,102,102,110,110,114,114,116,116,2,0,39,39,92,92,
- 2,0,34,34,92,92,5,0,9,10,13,13,32,32,35,35,61,61,2,0,9,9,32,32,127,
- 0,1,1,0,0,0,0,3,1,0,0,0,0,5,1,0,0,0,0,7,1,0,0,0,0,9,1,0,0,0,0,11,1,
- 0,0,0,0,13,1,0,0,0,0,15,1,0,0,0,0,19,1,0,0,0,0,21,1,0,0,0,0,23,1,0,
- 0,0,0,25,1,0,0,0,1,27,1,0,0,0,3,29,1,0,0,0,5,37,1,0,0,0,7,41,1,0,0,
- 0,9,43,1,0,0,0,11,51,1,0,0,0,13,59,1,0,0,0,15,81,1,0,0,0,17,83,1,0,
- 0,0,19,86,1,0,0,0,21,96,1,0,0,0,23,107,1,0,0,0,25,111,1,0,0,0,27,28,
- 5,61,0,0,28,2,1,0,0,0,29,33,7,0,0,0,30,32,7,1,0,0,31,30,1,0,0,0,32,
- 35,1,0,0,0,33,31,1,0,0,0,33,34,1,0,0,0,34,4,1,0,0,0,35,33,1,0,0,0,
- 36,38,7,2,0,0,37,36,1,0,0,0,38,39,1,0,0,0,39,37,1,0,0,0,39,40,1,0,
- 0,0,40,6,1,0,0,0,41,42,8,2,0,0,42,8,1,0,0,0,43,47,5,35,0,0,44,46,8,
- 2,0,0,45,44,1,0,0,0,46,49,1,0,0,0,47,45,1,0,0,0,47,48,1,0,0,0,48,10,
- 1,0,0,0,49,47,1,0,0,0,50,52,5,45,0,0,51,50,1,0,0,0,51,52,1,0,0,0,52,
- 54,1,0,0,0,53,55,7,3,0,0,54,53,1,0,0,0,55,56,1,0,0,0,56,54,1,0,0,0,
- 56,57,1,0,0,0,57,12,1,0,0,0,58,60,5,45,0,0,59,58,1,0,0,0,59,60,1,0,
- 0,0,60,62,1,0,0,0,61,63,7,3,0,0,62,61,1,0,0,0,63,64,1,0,0,0,64,62,
- 1,0,0,0,64,65,1,0,0,0,65,66,1,0,0,0,66,68,5,46,0,0,67,69,7,3,0,0,68,
- 67,1,0,0,0,69,70,1,0,0,0,70,68,1,0,0,0,70,71,1,0,0,0,71,14,1,0,0,0,
- 72,73,5,116,0,0,73,74,5,114,0,0,74,75,5,117,0,0,75,82,5,101,0,0,76,
- 77,5,102,0,0,77,78,5,97,0,0,78,79,5,108,0,0,79,80,5,115,0,0,80,82,
- 5,101,0,0,81,72,1,0,0,0,81,76,1,0,0,0,82,16,1,0,0,0,83,84,5,92,0,0,
- 84,85,7,4,0,0,85,18,1,0,0,0,86,91,5,39,0,0,87,90,3,17,8,0,88,90,8,
- 5,0,0,89,87,1,0,0,0,89,88,1,0,0,0,90,93,1,0,0,0,91,89,1,0,0,0,91,92,
- 1,0,0,0,92,94,1,0,0,0,93,91,1,0,0,0,94,95,5,39,0,0,95,20,1,0,0,0,96,
- 101,5,34,0,0,97,100,3,17,8,0,98,100,8,6,0,0,99,97,1,0,0,0,99,98,1,
- 0,0,0,100,103,1,0,0,0,101,99,1,0,0,0,101,102,1,0,0,0,102,104,1,0,0,
- 0,103,101,1,0,0,0,104,105,5,34,0,0,105,22,1,0,0,0,106,108,8,7,0,0,
- 107,106,1,0,0,0,108,109,1,0,0,0,109,107,1,0,0,0,109,110,1,0,0,0,110,
- 24,1,0,0,0,111,112,7,8,0,0,112,113,1,0,0,0,113,114,6,12,0,0,114,26,
- 1,0,0,0,15,0,33,39,47,51,56,59,64,70,81,89,91,99,101,109,1,6,0,0
+ 4,0,11,109,6,-1,2,0,7,0,2,1,7,1,2,2,7,2,2,3,7,3,2,4,7,4,2,5,7,5,2,
+ 6,7,6,2,7,7,7,2,8,7,8,2,9,7,9,2,10,7,10,2,11,7,11,1,0,1,0,1,1,1,1,
+ 5,1,30,8,1,10,1,12,1,33,9,1,1,2,4,2,36,8,2,11,2,12,2,37,1,3,1,3,5,
+ 3,42,8,3,10,3,12,3,45,9,3,1,4,3,4,48,8,4,1,4,4,4,51,8,4,11,4,12,4,
+ 52,1,5,3,5,56,8,5,1,5,3,5,59,8,5,1,5,1,5,4,5,63,8,5,11,5,12,5,64,1,
+ 6,1,6,1,6,1,6,1,6,1,6,1,6,1,6,1,6,3,6,76,8,6,1,7,1,7,1,7,1,8,1,8,1,
+ 8,5,8,84,8,8,10,8,12,8,87,9,8,1,8,1,8,1,9,1,9,1,9,5,9,94,8,9,10,9,
+ 12,9,97,9,9,1,9,1,9,1,10,4,10,102,8,10,11,10,12,10,103,1,11,1,11,1,
+ 11,1,11,0,0,12,1,1,3,2,5,3,7,4,9,5,11,6,13,7,15,0,17,8,19,9,21,10,
+ 23,11,1,0,9,2,0,65,90,95,95,3,0,48,57,65,90,95,95,2,0,10,10,13,13,
+ 1,0,48,57,8,0,34,34,47,47,92,92,98,98,102,102,110,110,114,114,116,
+ 116,2,0,39,39,92,92,2,0,34,34,92,92,5,0,9,10,13,13,32,32,35,35,61,
+ 61,2,0,9,9,32,32,121,0,1,1,0,0,0,0,3,1,0,0,0,0,5,1,0,0,0,0,7,1,0,0,
+ 0,0,9,1,0,0,0,0,11,1,0,0,0,0,13,1,0,0,0,0,17,1,0,0,0,0,19,1,0,0,0,
+ 0,21,1,0,0,0,0,23,1,0,0,0,1,25,1,0,0,0,3,27,1,0,0,0,5,35,1,0,0,0,7,
+ 39,1,0,0,0,9,47,1,0,0,0,11,55,1,0,0,0,13,75,1,0,0,0,15,77,1,0,0,0,
+ 17,80,1,0,0,0,19,90,1,0,0,0,21,101,1,0,0,0,23,105,1,0,0,0,25,26,5,
+ 61,0,0,26,2,1,0,0,0,27,31,7,0,0,0,28,30,7,1,0,0,29,28,1,0,0,0,30,33,
+ 1,0,0,0,31,29,1,0,0,0,31,32,1,0,0,0,32,4,1,0,0,0,33,31,1,0,0,0,34,
+ 36,7,2,0,0,35,34,1,0,0,0,36,37,1,0,0,0,37,35,1,0,0,0,37,38,1,0,0,0,
+ 38,6,1,0,0,0,39,43,5,35,0,0,40,42,8,2,0,0,41,40,1,0,0,0,42,45,1,0,
+ 0,0,43,41,1,0,0,0,43,44,1,0,0,0,44,8,1,0,0,0,45,43,1,0,0,0,46,48,5,
+ 45,0,0,47,46,1,0,0,0,47,48,1,0,0,0,48,50,1,0,0,0,49,51,7,3,0,0,50,
+ 49,1,0,0,0,51,52,1,0,0,0,52,50,1,0,0,0,52,53,1,0,0,0,53,10,1,0,0,0,
+ 54,56,5,45,0,0,55,54,1,0,0,0,55,56,1,0,0,0,56,58,1,0,0,0,57,59,7,3,
+ 0,0,58,57,1,0,0,0,58,59,1,0,0,0,59,60,1,0,0,0,60,62,5,46,0,0,61,63,
+ 7,3,0,0,62,61,1,0,0,0,63,64,1,0,0,0,64,62,1,0,0,0,64,65,1,0,0,0,65,
+ 12,1,0,0,0,66,67,5,116,0,0,67,68,5,114,0,0,68,69,5,117,0,0,69,76,5,
+ 101,0,0,70,71,5,102,0,0,71,72,5,97,0,0,72,73,5,108,0,0,73,74,5,115,
+ 0,0,74,76,5,101,0,0,75,66,1,0,0,0,75,70,1,0,0,0,76,14,1,0,0,0,77,78,
+ 5,92,0,0,78,79,7,4,0,0,79,16,1,0,0,0,80,85,5,39,0,0,81,84,3,15,7,0,
+ 82,84,8,5,0,0,83,81,1,0,0,0,83,82,1,0,0,0,84,87,1,0,0,0,85,83,1,0,
+ 0,0,85,86,1,0,0,0,86,88,1,0,0,0,87,85,1,0,0,0,88,89,5,39,0,0,89,18,
+ 1,0,0,0,90,95,5,34,0,0,91,94,3,15,7,0,92,94,8,6,0,0,93,91,1,0,0,0,
+ 93,92,1,0,0,0,94,97,1,0,0,0,95,93,1,0,0,0,95,96,1,0,0,0,96,98,1,0,
+ 0,0,97,95,1,0,0,0,98,99,5,34,0,0,99,20,1,0,0,0,100,102,8,7,0,0,101,
+ 100,1,0,0,0,102,103,1,0,0,0,103,101,1,0,0,0,103,104,1,0,0,0,104,22,
+ 1,0,0,0,105,106,7,8,0,0,106,107,1,0,0,0,107,108,6,11,0,0,108,24,1,
+ 0,0,0,15,0,31,37,43,47,52,55,58,64,75,83,85,93,95,103,1,6,0,0
];
static final ATN _ATN =
diff --git a/lib/antlr/EnvLexer.interp b/lib/antlr/EnvLexer.interp
index 787d2d9..fb62d25 100644
--- a/lib/antlr/EnvLexer.interp
+++ b/lib/antlr/EnvLexer.interp
@@ -11,14 +11,12 @@ null
null
null
null
-null
token symbolic names:
null
null
KEY
NEWLINE
-NOTLINE
COMMENT
INT
DOUBLE
@@ -32,7 +30,6 @@ rule names:
T__0
KEY
NEWLINE
-NOTLINE
COMMENT
INT
DOUBLE
@@ -51,4 +48,4 @@ mode names:
DEFAULT_MODE
atn:
-[4, 0, 12, 115, 6, -1, 2, 0, 7, 0, 2, 1, 7, 1, 2, 2, 7, 2, 2, 3, 7, 3, 2, 4, 7, 4, 2, 5, 7, 5, 2, 6, 7, 6, 2, 7, 7, 7, 2, 8, 7, 8, 2, 9, 7, 9, 2, 10, 7, 10, 2, 11, 7, 11, 2, 12, 7, 12, 1, 0, 1, 0, 1, 1, 1, 1, 5, 1, 32, 8, 1, 10, 1, 12, 1, 35, 9, 1, 1, 2, 4, 2, 38, 8, 2, 11, 2, 12, 2, 39, 1, 3, 1, 3, 1, 4, 1, 4, 5, 4, 46, 8, 4, 10, 4, 12, 4, 49, 9, 4, 1, 5, 3, 5, 52, 8, 5, 1, 5, 4, 5, 55, 8, 5, 11, 5, 12, 5, 56, 1, 6, 3, 6, 60, 8, 6, 1, 6, 4, 6, 63, 8, 6, 11, 6, 12, 6, 64, 1, 6, 1, 6, 4, 6, 69, 8, 6, 11, 6, 12, 6, 70, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 3, 7, 82, 8, 7, 1, 8, 1, 8, 1, 8, 1, 9, 1, 9, 1, 9, 5, 9, 90, 8, 9, 10, 9, 12, 9, 93, 9, 9, 1, 9, 1, 9, 1, 10, 1, 10, 1, 10, 5, 10, 100, 8, 10, 10, 10, 12, 10, 103, 9, 10, 1, 10, 1, 10, 1, 11, 4, 11, 108, 8, 11, 11, 11, 12, 11, 109, 1, 12, 1, 12, 1, 12, 1, 12, 0, 0, 13, 1, 1, 3, 2, 5, 3, 7, 4, 9, 5, 11, 6, 13, 7, 15, 8, 17, 0, 19, 9, 21, 10, 23, 11, 25, 12, 1, 0, 9, 2, 0, 65, 90, 95, 95, 3, 0, 48, 57, 65, 90, 95, 95, 2, 0, 10, 10, 13, 13, 1, 0, 48, 57, 8, 0, 34, 34, 47, 47, 92, 92, 98, 98, 102, 102, 110, 110, 114, 114, 116, 116, 2, 0, 39, 39, 92, 92, 2, 0, 34, 34, 92, 92, 5, 0, 9, 10, 13, 13, 32, 32, 35, 35, 61, 61, 2, 0, 9, 9, 32, 32, 127, 0, 1, 1, 0, 0, 0, 0, 3, 1, 0, 0, 0, 0, 5, 1, 0, 0, 0, 0, 7, 1, 0, 0, 0, 0, 9, 1, 0, 0, 0, 0, 11, 1, 0, 0, 0, 0, 13, 1, 0, 0, 0, 0, 15, 1, 0, 0, 0, 0, 19, 1, 0, 0, 0, 0, 21, 1, 0, 0, 0, 0, 23, 1, 0, 0, 0, 0, 25, 1, 0, 0, 0, 1, 27, 1, 0, 0, 0, 3, 29, 1, 0, 0, 0, 5, 37, 1, 0, 0, 0, 7, 41, 1, 0, 0, 0, 9, 43, 1, 0, 0, 0, 11, 51, 1, 0, 0, 0, 13, 59, 1, 0, 0, 0, 15, 81, 1, 0, 0, 0, 17, 83, 1, 0, 0, 0, 19, 86, 1, 0, 0, 0, 21, 96, 1, 0, 0, 0, 23, 107, 1, 0, 0, 0, 25, 111, 1, 0, 0, 0, 27, 28, 5, 61, 0, 0, 28, 2, 1, 0, 0, 0, 29, 33, 7, 0, 0, 0, 30, 32, 7, 1, 0, 0, 31, 30, 1, 0, 0, 0, 32, 35, 1, 0, 0, 0, 33, 31, 1, 0, 0, 0, 33, 34, 1, 0, 0, 0, 34, 4, 1, 0, 0, 0, 35, 33, 1, 0, 0, 0, 36, 38, 7, 2, 0, 0, 37, 36, 1, 0, 0, 0, 38, 39, 1, 0, 0, 0, 39, 37, 1, 0, 0, 0, 39, 40, 1, 0, 0, 0, 40, 6, 1, 0, 0, 0, 41, 42, 8, 2, 0, 0, 42, 8, 1, 0, 0, 0, 43, 47, 5, 35, 0, 0, 44, 46, 8, 2, 0, 0, 45, 44, 1, 0, 0, 0, 46, 49, 1, 0, 0, 0, 47, 45, 1, 0, 0, 0, 47, 48, 1, 0, 0, 0, 48, 10, 1, 0, 0, 0, 49, 47, 1, 0, 0, 0, 50, 52, 5, 45, 0, 0, 51, 50, 1, 0, 0, 0, 51, 52, 1, 0, 0, 0, 52, 54, 1, 0, 0, 0, 53, 55, 7, 3, 0, 0, 54, 53, 1, 0, 0, 0, 55, 56, 1, 0, 0, 0, 56, 54, 1, 0, 0, 0, 56, 57, 1, 0, 0, 0, 57, 12, 1, 0, 0, 0, 58, 60, 5, 45, 0, 0, 59, 58, 1, 0, 0, 0, 59, 60, 1, 0, 0, 0, 60, 62, 1, 0, 0, 0, 61, 63, 7, 3, 0, 0, 62, 61, 1, 0, 0, 0, 63, 64, 1, 0, 0, 0, 64, 62, 1, 0, 0, 0, 64, 65, 1, 0, 0, 0, 65, 66, 1, 0, 0, 0, 66, 68, 5, 46, 0, 0, 67, 69, 7, 3, 0, 0, 68, 67, 1, 0, 0, 0, 69, 70, 1, 0, 0, 0, 70, 68, 1, 0, 0, 0, 70, 71, 1, 0, 0, 0, 71, 14, 1, 0, 0, 0, 72, 73, 5, 116, 0, 0, 73, 74, 5, 114, 0, 0, 74, 75, 5, 117, 0, 0, 75, 82, 5, 101, 0, 0, 76, 77, 5, 102, 0, 0, 77, 78, 5, 97, 0, 0, 78, 79, 5, 108, 0, 0, 79, 80, 5, 115, 0, 0, 80, 82, 5, 101, 0, 0, 81, 72, 1, 0, 0, 0, 81, 76, 1, 0, 0, 0, 82, 16, 1, 0, 0, 0, 83, 84, 5, 92, 0, 0, 84, 85, 7, 4, 0, 0, 85, 18, 1, 0, 0, 0, 86, 91, 5, 39, 0, 0, 87, 90, 3, 17, 8, 0, 88, 90, 8, 5, 0, 0, 89, 87, 1, 0, 0, 0, 89, 88, 1, 0, 0, 0, 90, 93, 1, 0, 0, 0, 91, 89, 1, 0, 0, 0, 91, 92, 1, 0, 0, 0, 92, 94, 1, 0, 0, 0, 93, 91, 1, 0, 0, 0, 94, 95, 5, 39, 0, 0, 95, 20, 1, 0, 0, 0, 96, 101, 5, 34, 0, 0, 97, 100, 3, 17, 8, 0, 98, 100, 8, 6, 0, 0, 99, 97, 1, 0, 0, 0, 99, 98, 1, 0, 0, 0, 100, 103, 1, 0, 0, 0, 101, 99, 1, 0, 0, 0, 101, 102, 1, 0, 0, 0, 102, 104, 1, 0, 0, 0, 103, 101, 1, 0, 0, 0, 104, 105, 5, 34, 0, 0, 105, 22, 1, 0, 0, 0, 106, 108, 8, 7, 0, 0, 107, 106, 1, 0, 0, 0, 108, 109, 1, 0, 0, 0, 109, 107, 1, 0, 0, 0, 109, 110, 1, 0, 0, 0, 110, 24, 1, 0, 0, 0, 111, 112, 7, 8, 0, 0, 112, 113, 1, 0, 0, 0, 113, 114, 6, 12, 0, 0, 114, 26, 1, 0, 0, 0, 15, 0, 33, 39, 47, 51, 56, 59, 64, 70, 81, 89, 91, 99, 101, 109, 1, 6, 0, 0]
\ No newline at end of file
+[4, 0, 11, 109, 6, -1, 2, 0, 7, 0, 2, 1, 7, 1, 2, 2, 7, 2, 2, 3, 7, 3, 2, 4, 7, 4, 2, 5, 7, 5, 2, 6, 7, 6, 2, 7, 7, 7, 2, 8, 7, 8, 2, 9, 7, 9, 2, 10, 7, 10, 2, 11, 7, 11, 1, 0, 1, 0, 1, 1, 1, 1, 5, 1, 30, 8, 1, 10, 1, 12, 1, 33, 9, 1, 1, 2, 4, 2, 36, 8, 2, 11, 2, 12, 2, 37, 1, 3, 1, 3, 5, 3, 42, 8, 3, 10, 3, 12, 3, 45, 9, 3, 1, 4, 3, 4, 48, 8, 4, 1, 4, 4, 4, 51, 8, 4, 11, 4, 12, 4, 52, 1, 5, 3, 5, 56, 8, 5, 1, 5, 3, 5, 59, 8, 5, 1, 5, 1, 5, 4, 5, 63, 8, 5, 11, 5, 12, 5, 64, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 3, 6, 76, 8, 6, 1, 7, 1, 7, 1, 7, 1, 8, 1, 8, 1, 8, 5, 8, 84, 8, 8, 10, 8, 12, 8, 87, 9, 8, 1, 8, 1, 8, 1, 9, 1, 9, 1, 9, 5, 9, 94, 8, 9, 10, 9, 12, 9, 97, 9, 9, 1, 9, 1, 9, 1, 10, 4, 10, 102, 8, 10, 11, 10, 12, 10, 103, 1, 11, 1, 11, 1, 11, 1, 11, 0, 0, 12, 1, 1, 3, 2, 5, 3, 7, 4, 9, 5, 11, 6, 13, 7, 15, 0, 17, 8, 19, 9, 21, 10, 23, 11, 1, 0, 9, 2, 0, 65, 90, 95, 95, 3, 0, 48, 57, 65, 90, 95, 95, 2, 0, 10, 10, 13, 13, 1, 0, 48, 57, 8, 0, 34, 34, 47, 47, 92, 92, 98, 98, 102, 102, 110, 110, 114, 114, 116, 116, 2, 0, 39, 39, 92, 92, 2, 0, 34, 34, 92, 92, 5, 0, 9, 10, 13, 13, 32, 32, 35, 35, 61, 61, 2, 0, 9, 9, 32, 32, 121, 0, 1, 1, 0, 0, 0, 0, 3, 1, 0, 0, 0, 0, 5, 1, 0, 0, 0, 0, 7, 1, 0, 0, 0, 0, 9, 1, 0, 0, 0, 0, 11, 1, 0, 0, 0, 0, 13, 1, 0, 0, 0, 0, 17, 1, 0, 0, 0, 0, 19, 1, 0, 0, 0, 0, 21, 1, 0, 0, 0, 0, 23, 1, 0, 0, 0, 1, 25, 1, 0, 0, 0, 3, 27, 1, 0, 0, 0, 5, 35, 1, 0, 0, 0, 7, 39, 1, 0, 0, 0, 9, 47, 1, 0, 0, 0, 11, 55, 1, 0, 0, 0, 13, 75, 1, 0, 0, 0, 15, 77, 1, 0, 0, 0, 17, 80, 1, 0, 0, 0, 19, 90, 1, 0, 0, 0, 21, 101, 1, 0, 0, 0, 23, 105, 1, 0, 0, 0, 25, 26, 5, 61, 0, 0, 26, 2, 1, 0, 0, 0, 27, 31, 7, 0, 0, 0, 28, 30, 7, 1, 0, 0, 29, 28, 1, 0, 0, 0, 30, 33, 1, 0, 0, 0, 31, 29, 1, 0, 0, 0, 31, 32, 1, 0, 0, 0, 32, 4, 1, 0, 0, 0, 33, 31, 1, 0, 0, 0, 34, 36, 7, 2, 0, 0, 35, 34, 1, 0, 0, 0, 36, 37, 1, 0, 0, 0, 37, 35, 1, 0, 0, 0, 37, 38, 1, 0, 0, 0, 38, 6, 1, 0, 0, 0, 39, 43, 5, 35, 0, 0, 40, 42, 8, 2, 0, 0, 41, 40, 1, 0, 0, 0, 42, 45, 1, 0, 0, 0, 43, 41, 1, 0, 0, 0, 43, 44, 1, 0, 0, 0, 44, 8, 1, 0, 0, 0, 45, 43, 1, 0, 0, 0, 46, 48, 5, 45, 0, 0, 47, 46, 1, 0, 0, 0, 47, 48, 1, 0, 0, 0, 48, 50, 1, 0, 0, 0, 49, 51, 7, 3, 0, 0, 50, 49, 1, 0, 0, 0, 51, 52, 1, 0, 0, 0, 52, 50, 1, 0, 0, 0, 52, 53, 1, 0, 0, 0, 53, 10, 1, 0, 0, 0, 54, 56, 5, 45, 0, 0, 55, 54, 1, 0, 0, 0, 55, 56, 1, 0, 0, 0, 56, 58, 1, 0, 0, 0, 57, 59, 7, 3, 0, 0, 58, 57, 1, 0, 0, 0, 58, 59, 1, 0, 0, 0, 59, 60, 1, 0, 0, 0, 60, 62, 5, 46, 0, 0, 61, 63, 7, 3, 0, 0, 62, 61, 1, 0, 0, 0, 63, 64, 1, 0, 0, 0, 64, 62, 1, 0, 0, 0, 64, 65, 1, 0, 0, 0, 65, 12, 1, 0, 0, 0, 66, 67, 5, 116, 0, 0, 67, 68, 5, 114, 0, 0, 68, 69, 5, 117, 0, 0, 69, 76, 5, 101, 0, 0, 70, 71, 5, 102, 0, 0, 71, 72, 5, 97, 0, 0, 72, 73, 5, 108, 0, 0, 73, 74, 5, 115, 0, 0, 74, 76, 5, 101, 0, 0, 75, 66, 1, 0, 0, 0, 75, 70, 1, 0, 0, 0, 76, 14, 1, 0, 0, 0, 77, 78, 5, 92, 0, 0, 78, 79, 7, 4, 0, 0, 79, 16, 1, 0, 0, 0, 80, 85, 5, 39, 0, 0, 81, 84, 3, 15, 7, 0, 82, 84, 8, 5, 0, 0, 83, 81, 1, 0, 0, 0, 83, 82, 1, 0, 0, 0, 84, 87, 1, 0, 0, 0, 85, 83, 1, 0, 0, 0, 85, 86, 1, 0, 0, 0, 86, 88, 1, 0, 0, 0, 87, 85, 1, 0, 0, 0, 88, 89, 5, 39, 0, 0, 89, 18, 1, 0, 0, 0, 90, 95, 5, 34, 0, 0, 91, 94, 3, 15, 7, 0, 92, 94, 8, 6, 0, 0, 93, 91, 1, 0, 0, 0, 93, 92, 1, 0, 0, 0, 94, 97, 1, 0, 0, 0, 95, 93, 1, 0, 0, 0, 95, 96, 1, 0, 0, 0, 96, 98, 1, 0, 0, 0, 97, 95, 1, 0, 0, 0, 98, 99, 5, 34, 0, 0, 99, 20, 1, 0, 0, 0, 100, 102, 8, 7, 0, 0, 101, 100, 1, 0, 0, 0, 102, 103, 1, 0, 0, 0, 103, 101, 1, 0, 0, 0, 103, 104, 1, 0, 0, 0, 104, 22, 1, 0, 0, 0, 105, 106, 7, 8, 0, 0, 106, 107, 1, 0, 0, 0, 107, 108, 6, 11, 0, 0, 108, 24, 1, 0, 0, 0, 15, 0, 31, 37, 43, 47, 52, 55, 58, 64, 75, 83, 85, 93, 95, 103, 1, 6, 0, 0]
\ No newline at end of file
diff --git a/lib/antlr/EnvLexer.tokens b/lib/antlr/EnvLexer.tokens
index e73191c..ccc4aa6 100644
--- a/lib/antlr/EnvLexer.tokens
+++ b/lib/antlr/EnvLexer.tokens
@@ -1,13 +1,12 @@
T__0=1
KEY=2
NEWLINE=3
-NOTLINE=4
-COMMENT=5
-INT=6
-DOUBLE=7
-BOOLEAN=8
-SINGLE_QUOTE_STRING=9
-DOUBLE_QUOTE_STRING=10
-NO_QUOTE_STRING=11
-WS=12
+COMMENT=4
+INT=5
+DOUBLE=6
+BOOLEAN=7
+SINGLE_QUOTE_STRING=8
+DOUBLE_QUOTE_STRING=9
+NO_QUOTE_STRING=10
+WS=11
'='=1
diff --git a/lib/antlr/EnvParser.dart b/lib/antlr/EnvParser.dart
index 349a8c7..9c6c864 100644
--- a/lib/antlr/EnvParser.dart
+++ b/lib/antlr/EnvParser.dart
@@ -13,10 +13,10 @@ class EnvParser extends Parser {
static final List _decisionToDFA = List.generate(
_ATN.numberOfDecisions, (i) => DFA(_ATN.getDecisionState(i), i));
static final PredictionContextCache _sharedContextCache = PredictionContextCache();
- static const int TOKEN_T__0 = 1, TOKEN_KEY = 2, TOKEN_NEWLINE = 3, TOKEN_NOTLINE = 4,
- TOKEN_COMMENT = 5, TOKEN_INT = 6, TOKEN_DOUBLE = 7, TOKEN_BOOLEAN = 8,
- TOKEN_SINGLE_QUOTE_STRING = 9, TOKEN_DOUBLE_QUOTE_STRING = 10,
- TOKEN_NO_QUOTE_STRING = 11, TOKEN_WS = 12;
+ static const int TOKEN_T__0 = 1, TOKEN_KEY = 2, TOKEN_NEWLINE = 3, TOKEN_COMMENT = 4,
+ TOKEN_INT = 5, TOKEN_DOUBLE = 6, TOKEN_BOOLEAN = 7, TOKEN_SINGLE_QUOTE_STRING = 8,
+ TOKEN_DOUBLE_QUOTE_STRING = 9, TOKEN_NO_QUOTE_STRING = 10,
+ TOKEN_WS = 11;
@override
final List ruleNames = [
@@ -27,9 +27,8 @@ class EnvParser extends Parser {
null, "'='"
];
static final List _SYMBOLIC_NAMES = [
- null, null, "KEY", "NEWLINE", "NOTLINE", "COMMENT", "INT", "DOUBLE",
- "BOOLEAN", "SINGLE_QUOTE_STRING", "DOUBLE_QUOTE_STRING", "NO_QUOTE_STRING",
- "WS"
+ null, null, "KEY", "NEWLINE", "COMMENT", "INT", "DOUBLE", "BOOLEAN",
+ "SINGLE_QUOTE_STRING", "DOUBLE_QUOTE_STRING", "NO_QUOTE_STRING", "WS"
];
static final Vocabulary VOCABULARY = VocabularyImpl(_LITERAL_NAMES, _SYMBOLIC_NAMES);
@@ -62,7 +61,7 @@ class EnvParser extends Parser {
state = 15;
errorHandler.sync(this);
_la = tokenStream.LA(1)!;
- while ((((_la) & ~0x3f) == 0 && ((1 << _la) & 44) != 0)) {
+ while ((((_la) & ~0x3f) == 0 && ((1 << _la) & 28) != 0)) {
state = 12;
line();
state = 17;
@@ -108,12 +107,12 @@ class EnvParser extends Parser {
match(TOKEN_T__0);
state = 29;
errorHandler.sync(this);
- _la = tokenStream.LA(1)!;
- if ((((_la) & ~0x3f) == 0 && ((1 << _la) & 4032) != 0)) {
+ switch (interpreter!.adaptivePredict(tokenStream, 2, context)) {
+ case 1:
state = 28;
value();
+ break;
}
-
state = 32;
errorHandler.sync(this);
switch (interpreter!.adaptivePredict(tokenStream, 3, context)) {
@@ -180,6 +179,7 @@ class EnvParser extends Parser {
state = 41;
match(TOKEN_BOOLEAN);
break;
+ case TOKEN_KEY:
case TOKEN_SINGLE_QUOTE_STRING:
case TOKEN_DOUBLE_QUOTE_STRING:
case TOKEN_NO_QUOTE_STRING:
@@ -225,7 +225,7 @@ class EnvParser extends Parser {
enterOuterAlt(_localctx, 1);
state = 47;
_la = tokenStream.LA(1)!;
- if (!((((_la) & ~0x3f) == 0 && ((1 << _la) & 3584) != 0))) {
+ if (!((((_la) & ~0x3f) == 0 && ((1 << _la) & 1796) != 0))) {
errorHandler.recoverInline(this);
} else {
if ( tokenStream.LA(1)! == IntStream.EOF ) matchedEOF = true;
@@ -243,21 +243,22 @@ class EnvParser extends Parser {
}
static const List _serializedATN = [
- 4,1,12,50,2,0,7,0,2,1,7,1,2,2,7,2,2,3,7,3,2,4,7,4,2,5,7,5,1,0,5,0,
+ 4,1,11,50,2,0,7,0,2,1,7,1,2,2,7,2,2,3,7,3,2,4,7,4,2,5,7,5,1,0,5,0,
14,8,0,10,0,12,0,17,9,0,1,1,1,1,1,1,5,1,22,8,1,10,1,12,1,25,9,1,1,
1,1,1,1,1,3,1,30,8,1,1,1,3,1,33,8,1,1,1,3,1,36,8,1,1,2,1,2,1,3,1,3,
- 1,3,1,3,3,3,44,8,3,1,4,1,4,1,5,1,5,1,5,0,0,6,0,2,4,6,8,10,0,1,1,0,
- 9,11,51,0,15,1,0,0,0,2,35,1,0,0,0,4,37,1,0,0,0,6,43,1,0,0,0,8,45,1,
- 0,0,0,10,47,1,0,0,0,12,14,3,2,1,0,13,12,1,0,0,0,14,17,1,0,0,0,15,13,
- 1,0,0,0,15,16,1,0,0,0,16,1,1,0,0,0,17,15,1,0,0,0,18,19,3,8,4,0,19,
- 20,5,3,0,0,20,22,1,0,0,0,21,18,1,0,0,0,22,25,1,0,0,0,23,21,1,0,0,0,
- 23,24,1,0,0,0,24,26,1,0,0,0,25,23,1,0,0,0,26,27,3,4,2,0,27,29,5,1,
- 0,0,28,30,3,6,3,0,29,28,1,0,0,0,29,30,1,0,0,0,30,32,1,0,0,0,31,33,
- 3,8,4,0,32,31,1,0,0,0,32,33,1,0,0,0,33,36,1,0,0,0,34,36,5,3,0,0,35,
- 23,1,0,0,0,35,34,1,0,0,0,36,3,1,0,0,0,37,38,5,2,0,0,38,5,1,0,0,0,39,
- 44,5,6,0,0,40,44,5,7,0,0,41,44,5,8,0,0,42,44,3,10,5,0,43,39,1,0,0,
- 0,43,40,1,0,0,0,43,41,1,0,0,0,43,42,1,0,0,0,44,7,1,0,0,0,45,46,5,5,
- 0,0,46,9,1,0,0,0,47,48,7,0,0,0,48,11,1,0,0,0,6,15,23,29,32,35,43
+ 1,3,1,3,3,3,44,8,3,1,4,1,4,1,5,1,5,1,5,0,0,6,0,2,4,6,8,10,0,1,2,0,
+ 2,2,8,10,51,0,15,1,0,0,0,2,35,1,0,0,0,4,37,1,0,0,0,6,43,1,0,0,0,8,
+ 45,1,0,0,0,10,47,1,0,0,0,12,14,3,2,1,0,13,12,1,0,0,0,14,17,1,0,0,0,
+ 15,13,1,0,0,0,15,16,1,0,0,0,16,1,1,0,0,0,17,15,1,0,0,0,18,19,3,8,4,
+ 0,19,20,5,3,0,0,20,22,1,0,0,0,21,18,1,0,0,0,22,25,1,0,0,0,23,21,1,
+ 0,0,0,23,24,1,0,0,0,24,26,1,0,0,0,25,23,1,0,0,0,26,27,3,4,2,0,27,29,
+ 5,1,0,0,28,30,3,6,3,0,29,28,1,0,0,0,29,30,1,0,0,0,30,32,1,0,0,0,31,
+ 33,3,8,4,0,32,31,1,0,0,0,32,33,1,0,0,0,33,36,1,0,0,0,34,36,5,3,0,0,
+ 35,23,1,0,0,0,35,34,1,0,0,0,36,3,1,0,0,0,37,38,5,2,0,0,38,5,1,0,0,
+ 0,39,44,5,5,0,0,40,44,5,6,0,0,41,44,5,7,0,0,42,44,3,10,5,0,43,39,1,
+ 0,0,0,43,40,1,0,0,0,43,41,1,0,0,0,43,42,1,0,0,0,44,7,1,0,0,0,45,46,
+ 5,4,0,0,46,9,1,0,0,0,47,48,7,0,0,0,48,11,1,0,0,0,6,15,23,29,32,35,
+ 43
];
static final ATN _ATN =
@@ -351,6 +352,7 @@ class StringContext extends ParserRuleContext {
TerminalNode? SINGLE_QUOTE_STRING() => getToken(EnvParser.TOKEN_SINGLE_QUOTE_STRING, 0);
TerminalNode? DOUBLE_QUOTE_STRING() => getToken(EnvParser.TOKEN_DOUBLE_QUOTE_STRING, 0);
TerminalNode? NO_QUOTE_STRING() => getToken(EnvParser.TOKEN_NO_QUOTE_STRING, 0);
+ TerminalNode? KEY() => getToken(EnvParser.TOKEN_KEY, 0);
StringContext([ParserRuleContext? parent, int? invokingState]) : super(parent, invokingState);
@override
int get ruleIndex => RULE_string;
diff --git a/lib/env2dart.dart b/lib/env2dart.dart
index 65d5258..2bf7d74 100644
--- a/lib/env2dart.dart
+++ b/lib/env2dart.dart
@@ -25,6 +25,7 @@ EnvParser _newParser(String contents) {
const kIgnoreLints = [
'camel_case_types',
'non_constant_identifier_names',
+ 'prefer_single_quotes',
];
void _codegen(
@@ -33,10 +34,10 @@ void _codegen(
String? active,
String? output,
}) {
- active ??= name;
- active = active.pascalCase;
+ var activeClass = (active ?? name).pascalCase;
var fields = [];
var getters = [];
+ var toJson = StringBuffer();
for (var field in pairs.values) {
getters.add(Method((b) => b
..name = field.name
@@ -47,28 +48,49 @@ void _codegen(
..name = field.name
..type = MethodType.getter
..annotations = ListBuilder([CodeExpression(Code("override"))])
- ..body = Code(field.value == null ? "''" : field.value.toString())
+ ..body = Code(field.value.toString())
..lambda = true
..returns = Reference(field.type)));
+ toJson.write("'${field.name}':${field.value},");
}
var abs = Class(
(b) => b
..name = name
..abstract = true
- ..methods = ListBuilder(getters)
+ ..fields = ListBuilder([
+ Field((b) => b
+ ..name = 'active'
+ ..type = Reference(active == null ? "String?" : "String")
+ ..static = true
+ ..modifier = FieldModifier.final$
+ ..assignment = active == null ? null : Code("'$active'"))
+ ])
+ ..methods = ListBuilder([
+ ...getters,
+ Method((b) => b
+ ..name = "toJson"
+ ..returns = Reference("Map"))
+ ])
..constructors = ListBuilder([
Constructor((b) => b
..factory = true
- ..redirect = Reference("_$active._")
+ ..redirect = Reference("_$activeClass._")
..constant = true),
]),
);
var impl = Class(
(b) => b
- ..name = '_$active'
+ ..name = '_$activeClass'
..implements = ListBuilder([Reference(name)])
- ..methods = ListBuilder(fields)
+ ..methods = ListBuilder([
+ ...fields,
+ Method((b) => b
+ ..name = "toJson"
+ ..annotations = ListBuilder([CodeExpression(Code("override"))])
+ ..returns = Reference("Map")
+ ..body = Code("return {$toJson};"))
+ ])
..constructors = ListBuilder([
Constructor((b) => b
..constant = true
@@ -106,7 +128,7 @@ void _codegen(
}
Map _toPairs(Directory dir, String file) {
- var input = File(path.join(dir.path, file)).readAsStringSync();
+ var input = File(path.join(dir.absolute.path, file)).readAsStringSync();
var parser = _newParser(input);
var visitor = DefaultVisitor(file);
visitor.visit(parser.env());
@@ -133,7 +155,7 @@ void _mergeActive(
var table = [
"Covered the default value",
"",
- "${old.value ?? ''} => ${value.value ?? ''}",
+ "${old.value} => ${value.value}",
"========================================",
];
value.comments = table..addAll(comments);
@@ -167,7 +189,7 @@ void parseAndGen(List arguments) {
args.addOption(
"path",
abbr: "p",
- defaultsTo: "./",
+ defaultsTo: "",
help:
"Specify working directory, the CLI will look for the .env file in the current directory.",
);
@@ -175,6 +197,7 @@ void parseAndGen(List arguments) {
"output",
abbr: "o",
help: "Specify the output file path.",
+ defaultsTo: "lib/env.g.dart",
);
args.addOption(
"active",
diff --git a/lib/visitor.dart b/lib/visitor.dart
index fdceec8..58d38e8 100644
--- a/lib/visitor.dart
+++ b/lib/visitor.dart
@@ -51,7 +51,7 @@ extension ValueContextExtension on ValueContext? {
dynamic get value {
var ctx = this;
if (ctx == null) {
- return null;
+ return "''";
} else if (ctx.INT() != null) {
return int.parse(ctx.text);
} else if (ctx.DOUBLE() != null) {
@@ -60,8 +60,8 @@ extension ValueContextExtension on ValueContext? {
return ctx.text == 'true';
} else if (ctx.string() != null) {
var str = ctx.string()!;
- if (str.NO_QUOTE_STRING() != null) {
- return "'${ctx.text}'";
+ if (str.NO_QUOTE_STRING() != null || str.KEY() != null) {
+ return jsonEncode(ctx.text);
}
return ctx.text;
}
diff --git a/test/envgen_test.dart b/test/envgen_test.dart
index 970f7f7..9a81a7d 100644
--- a/test/envgen_test.dart
+++ b/test/envgen_test.dart
@@ -3,6 +3,6 @@ import 'package:test/test.dart';
void main() {
test('test', () {
- parseAndGen(["-o", "env", "-a", "prod"]);
+ parseAndGen(["-o", "./example/env.g.dart", "-a", "prod"]);
});
}