@cparra/apex-reflection 0.1.0-alpha.0 → 0.1.1-alpha.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (158) hide show
  1. package/__tests__/end-to-end.test.ts +256 -0
  2. package/coverage/clover.xml +12857 -0
  3. package/coverage/coverage-final.json +3 -0
  4. package/coverage/lcov-report/base.css +224 -0
  5. package/coverage/lcov-report/block-navigation.js +79 -0
  6. package/coverage/lcov-report/favicon.png +0 -0
  7. package/coverage/lcov-report/index.html +126 -0
  8. package/coverage/lcov-report/index.js.html +104 -0
  9. package/coverage/lcov-report/out.js.html +41126 -0
  10. package/coverage/lcov-report/prettify.css +1 -0
  11. package/coverage/lcov-report/prettify.js +2 -0
  12. package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
  13. package/coverage/lcov-report/sorter.js +170 -0
  14. package/coverage/lcov.info +24801 -0
  15. package/index.d.ts +118 -0
  16. package/index.js +8 -0
  17. package/index.ts +141 -0
  18. package/jest.config.js +11 -0
  19. package/out.js +13708 -0
  20. package/package.json +22 -17
  21. package/tsconfig.json +5 -3
  22. package/.idea/apexdocs-dart.iml +0 -18
  23. package/.idea/jsLibraryMappings.xml +0 -6
  24. package/.idea/libraries/Dart_Packages.xml +0 -556
  25. package/.idea/libraries/Dart_SDK.xml +0 -28
  26. package/.idea/misc.xml +0 -6
  27. package/.idea/modules.xml +0 -8
  28. package/.idea/runConfigurations/_template__of_Dart_Test.xml +0 -6
  29. package/.idea/vcs.xml +0 -6
  30. package/CHANGELOG.md +0 -3
  31. package/README.md +0 -26
  32. package/TODO.md +0 -5
  33. package/analysis_options.yaml +0 -30
  34. package/antlr4-4.9.2/CHANGELOG.md +0 -4
  35. package/antlr4-4.9.2/LICENSE +0 -52
  36. package/antlr4-4.9.2/README.md +0 -11
  37. package/antlr4-4.9.2/analysis_options.yaml +0 -1
  38. package/antlr4-4.9.2/lib/antlr4.dart +0 -21
  39. package/antlr4-4.9.2/lib/src/atn/atn.dart +0 -18
  40. package/antlr4-4.9.2/lib/src/atn/src/atn.dart +0 -170
  41. package/antlr4-4.9.2/lib/src/atn/src/atn_config.dart +0 -242
  42. package/antlr4-4.9.2/lib/src/atn/src/atn_config_set.dart +0 -283
  43. package/antlr4-4.9.2/lib/src/atn/src/atn_deserializer.dart +0 -809
  44. package/antlr4-4.9.2/lib/src/atn/src/atn_simulator.dart +0 -95
  45. package/antlr4-4.9.2/lib/src/atn/src/atn_state.dart +0 -296
  46. package/antlr4-4.9.2/lib/src/atn/src/atn_type.dart +0 -14
  47. package/antlr4-4.9.2/lib/src/atn/src/info.dart +0 -553
  48. package/antlr4-4.9.2/lib/src/atn/src/lexer_action.dart +0 -601
  49. package/antlr4-4.9.2/lib/src/atn/src/lexer_action_executor.dart +0 -167
  50. package/antlr4-4.9.2/lib/src/atn/src/lexer_atn_simulator.dart +0 -731
  51. package/antlr4-4.9.2/lib/src/atn/src/parser_atn_simulator.dart +0 -2630
  52. package/antlr4-4.9.2/lib/src/atn/src/profiling_atn_simulator.dart +0 -229
  53. package/antlr4-4.9.2/lib/src/atn/src/semantic_context.dart +0 -404
  54. package/antlr4-4.9.2/lib/src/atn/src/transition.dart +0 -305
  55. package/antlr4-4.9.2/lib/src/dfa/dfa.dart +0 -8
  56. package/antlr4-4.9.2/lib/src/dfa/src/dfa.dart +0 -138
  57. package/antlr4-4.9.2/lib/src/dfa/src/dfa_serializer.dart +0 -76
  58. package/antlr4-4.9.2/lib/src/dfa/src/dfa_state.dart +0 -151
  59. package/antlr4-4.9.2/lib/src/error/error.dart +0 -10
  60. package/antlr4-4.9.2/lib/src/error/src/diagnostic_error_listener.dart +0 -116
  61. package/antlr4-4.9.2/lib/src/error/src/error_listener.dart +0 -241
  62. package/antlr4-4.9.2/lib/src/error/src/error_strategy.dart +0 -902
  63. package/antlr4-4.9.2/lib/src/error/src/errors.dart +0 -204
  64. package/antlr4-4.9.2/lib/src/input_stream.dart +0 -335
  65. package/antlr4-4.9.2/lib/src/interval_set.dart +0 -735
  66. package/antlr4-4.9.2/lib/src/lexer.dart +0 -343
  67. package/antlr4-4.9.2/lib/src/ll1_analyzer.dart +0 -204
  68. package/antlr4-4.9.2/lib/src/misc/multi_map.dart +0 -32
  69. package/antlr4-4.9.2/lib/src/misc/pair.dart +0 -34
  70. package/antlr4-4.9.2/lib/src/parser.dart +0 -777
  71. package/antlr4-4.9.2/lib/src/parser_interpreter.dart +0 -393
  72. package/antlr4-4.9.2/lib/src/parser_rule_context.dart +0 -275
  73. package/antlr4-4.9.2/lib/src/prediction_context.dart +0 -877
  74. package/antlr4-4.9.2/lib/src/recognizer.dart +0 -182
  75. package/antlr4-4.9.2/lib/src/rule_context.dart +0 -192
  76. package/antlr4-4.9.2/lib/src/runtime_meta_data.dart +0 -188
  77. package/antlr4-4.9.2/lib/src/token.dart +0 -431
  78. package/antlr4-4.9.2/lib/src/token_factory.dart +0 -88
  79. package/antlr4-4.9.2/lib/src/token_source.dart +0 -241
  80. package/antlr4-4.9.2/lib/src/token_stream.dart +0 -627
  81. package/antlr4-4.9.2/lib/src/tree/src/pattern/chunk.dart +0 -90
  82. package/antlr4-4.9.2/lib/src/tree/src/pattern/parse_tree_match.dart +0 -635
  83. package/antlr4-4.9.2/lib/src/tree/src/tree.dart +0 -370
  84. package/antlr4-4.9.2/lib/src/tree/src/trees.dart +0 -226
  85. package/antlr4-4.9.2/lib/src/tree/tree.dart +0 -10
  86. package/antlr4-4.9.2/lib/src/util/bit_set.dart +0 -308
  87. package/antlr4-4.9.2/lib/src/util/murmur_hash.dart +0 -77
  88. package/antlr4-4.9.2/lib/src/util/utils.dart +0 -31
  89. package/antlr4-4.9.2/lib/src/vocabulary.dart +0 -254
  90. package/antlr4-4.9.2/pubspec.yaml +0 -13
  91. package/example/node_example/index.js +0 -8
  92. package/example/node_example/package.json +0 -12
  93. package/example/node_example_ts/package-lock.json +0 -70
  94. package/example/node_example_ts/package.json +0 -19
  95. package/example/node_example_ts/src/index.js +0 -5
  96. package/example/node_example_ts/src/index.ts +0 -9
  97. package/example/node_example_ts/tsconfig.json +0 -79
  98. package/js/dart2jsout.js +0 -25898
  99. package/js/dart2jsout.js.map +0 -16
  100. package/js/index.d.ts +0 -1
  101. package/js/index.js +0 -4
  102. package/js/out.js +0 -26023
  103. package/js/out.js.map +0 -16
  104. package/js/package-lock.json +0 -57
  105. package/js/preamble.js +0 -125
  106. package/lib/apexdocs_dart.dart +0 -28
  107. package/lib/src/antlr/grammars/Apexdoc/ApexdocLexer.g4 +0 -120
  108. package/lib/src/antlr/grammars/Apexdoc/ApexdocParser.g4 +0 -158
  109. package/lib/src/antlr/grammars/Apexdoc/gen/ApexdocLexer.interp +0 -95
  110. package/lib/src/antlr/grammars/Apexdoc/gen/ApexdocLexer.java +0 -238
  111. package/lib/src/antlr/grammars/Apexdoc/gen/ApexdocLexer.tokens +0 -23
  112. package/lib/src/antlr/grammars/apex/ApexLexer.g4 +0 -255
  113. package/lib/src/antlr/grammars/apex/ApexParser.g4 +0 -567
  114. package/lib/src/antlr/grammars/apex/examples/ApexClass.cls +0 -6
  115. package/lib/src/antlr/lib/apex/ApexLexer.dart +0 -1223
  116. package/lib/src/antlr/lib/apex/ApexLexer.interp +0 -393
  117. package/lib/src/antlr/lib/apex/ApexLexer.tokens +0 -212
  118. package/lib/src/antlr/lib/apex/ApexParser.dart +0 -9349
  119. package/lib/src/antlr/lib/apex/ApexParser.interp +0 -326
  120. package/lib/src/antlr/lib/apex/ApexParser.tokens +0 -212
  121. package/lib/src/antlr/lib/apex/ApexParserBaseListener.dart +0 -1036
  122. package/lib/src/antlr/lib/apex/ApexParserListener.dart +0 -975
  123. package/lib/src/antlr/lib/apexdoc/ApexdocLexer.dart +0 -373
  124. package/lib/src/antlr/lib/apexdoc/ApexdocLexer.interp +0 -95
  125. package/lib/src/antlr/lib/apexdoc/ApexdocLexer.tokens +0 -23
  126. package/lib/src/antlr/lib/apexdoc/ApexdocParser.dart +0 -2471
  127. package/lib/src/antlr/lib/apexdoc/ApexdocParser.interp +0 -69
  128. package/lib/src/antlr/lib/apexdoc/ApexdocParser.tokens +0 -23
  129. package/lib/src/antlr/lib/apexdoc/ApexdocParserBaseListener.dart +0 -252
  130. package/lib/src/antlr/lib/apexdoc/ApexdocParserListener.dart +0 -215
  131. package/lib/src/builders/builders.dart +0 -32
  132. package/lib/src/model/apex_file_manifest.dart +0 -37
  133. package/lib/src/model/apex_file_manifest.g.dart +0 -18
  134. package/lib/src/model/declaration.dart +0 -50
  135. package/lib/src/model/doc_comment.dart +0 -117
  136. package/lib/src/model/doc_comment.g.dart +0 -118
  137. package/lib/src/model/members.dart +0 -143
  138. package/lib/src/model/members.g.dart +0 -105
  139. package/lib/src/model/types.dart +0 -159
  140. package/lib/src/model/types.g.dart +0 -111
  141. package/lib/src/service/apex_listener.dart +0 -226
  142. package/lib/src/service/apexdoc_listener.dart +0 -82
  143. package/lib/src/service/parsers.dart +0 -33
  144. package/lib/src/service/utils/parsing/access_modifiers_parser.dart +0 -33
  145. package/lib/src/service/utils/parsing/parameters_parser.dart +0 -18
  146. package/lib/src/service/utils/parsing/parsing_utils.dart +0 -2
  147. package/lib/src/service/walker.dart +0 -82
  148. package/pubspec.yaml +0 -19
  149. package/test/apex_file_manifest_test.dart +0 -16
  150. package/test/apex_listener_test.dart +0 -703
  151. package/test/apexdoc_parser_test.dart +0 -179
  152. package/test/doc_comment_test.dart +0 -89
  153. package/test/members_serialization_test.dart +0 -158
  154. package/test/members_test.dart +0 -178
  155. package/test/types_serialization_test.dart +0 -191
  156. package/test/types_test.dart +0 -311
  157. package/test/walker_test.dart +0 -58
  158. package/tool/grind.dart +0 -20
@@ -1,28 +0,0 @@
1
- <component name="libraryTable">
2
- <library name="Dart SDK">
3
- <CLASSES>
4
- <root url="file://$PROJECT_DIR$/../../../../flutter/flutter/bin/cache/dart-sdk/lib/async" />
5
- <root url="file://$PROJECT_DIR$/../../../../flutter/flutter/bin/cache/dart-sdk/lib/cli" />
6
- <root url="file://$PROJECT_DIR$/../../../../flutter/flutter/bin/cache/dart-sdk/lib/collection" />
7
- <root url="file://$PROJECT_DIR$/../../../../flutter/flutter/bin/cache/dart-sdk/lib/convert" />
8
- <root url="file://$PROJECT_DIR$/../../../../flutter/flutter/bin/cache/dart-sdk/lib/core" />
9
- <root url="file://$PROJECT_DIR$/../../../../flutter/flutter/bin/cache/dart-sdk/lib/developer" />
10
- <root url="file://$PROJECT_DIR$/../../../../flutter/flutter/bin/cache/dart-sdk/lib/ffi" />
11
- <root url="file://$PROJECT_DIR$/../../../../flutter/flutter/bin/cache/dart-sdk/lib/html" />
12
- <root url="file://$PROJECT_DIR$/../../../../flutter/flutter/bin/cache/dart-sdk/lib/indexed_db" />
13
- <root url="file://$PROJECT_DIR$/../../../../flutter/flutter/bin/cache/dart-sdk/lib/io" />
14
- <root url="file://$PROJECT_DIR$/../../../../flutter/flutter/bin/cache/dart-sdk/lib/isolate" />
15
- <root url="file://$PROJECT_DIR$/../../../../flutter/flutter/bin/cache/dart-sdk/lib/js" />
16
- <root url="file://$PROJECT_DIR$/../../../../flutter/flutter/bin/cache/dart-sdk/lib/js_util" />
17
- <root url="file://$PROJECT_DIR$/../../../../flutter/flutter/bin/cache/dart-sdk/lib/math" />
18
- <root url="file://$PROJECT_DIR$/../../../../flutter/flutter/bin/cache/dart-sdk/lib/mirrors" />
19
- <root url="file://$PROJECT_DIR$/../../../../flutter/flutter/bin/cache/dart-sdk/lib/svg" />
20
- <root url="file://$PROJECT_DIR$/../../../../flutter/flutter/bin/cache/dart-sdk/lib/typed_data" />
21
- <root url="file://$PROJECT_DIR$/../../../../flutter/flutter/bin/cache/dart-sdk/lib/web_audio" />
22
- <root url="file://$PROJECT_DIR$/../../../../flutter/flutter/bin/cache/dart-sdk/lib/web_gl" />
23
- <root url="file://$PROJECT_DIR$/../../../../flutter/flutter/bin/cache/dart-sdk/lib/web_sql" />
24
- </CLASSES>
25
- <JAVADOC />
26
- <SOURCES />
27
- </library>
28
- </component>
package/.idea/misc.xml DELETED
@@ -1,6 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <project version="4">
3
- <component name="ProjectRootManager">
4
- <output url="file://$PROJECT_DIR$/out" />
5
- </component>
6
- </project>
package/.idea/modules.xml DELETED
@@ -1,8 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <project version="4">
3
- <component name="ProjectModuleManager">
4
- <modules>
5
- <module fileurl="file://$PROJECT_DIR$/.idea/apexdocs-dart.iml" filepath="$PROJECT_DIR$/.idea/apexdocs-dart.iml" />
6
- </modules>
7
- </component>
8
- </project>
@@ -1,6 +0,0 @@
1
- <component name="ProjectRunConfigurationManager">
2
- <configuration default="true" type="DartTestRunConfigurationType" factoryName="Dart Test">
3
- <option name="VMOptions" value="--no-sound-null-safety" />
4
- <method v="2" />
5
- </configuration>
6
- </component>
package/.idea/vcs.xml DELETED
@@ -1,6 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <project version="4">
3
- <component name="VcsDirectoryMappings">
4
- <mapping directory="" vcs="Git" />
5
- </component>
6
- </project>
package/CHANGELOG.md DELETED
@@ -1,3 +0,0 @@
1
- ## 1.0.0
2
-
3
- - Initial version.
package/README.md DELETED
@@ -1,26 +0,0 @@
1
- # Creating JS from Dart code:
2
-
3
- To generate the JS file from the Dart code:
4
-
5
- 1. Run
6
-
7
- ```
8
- dart2js lib/apexdocs_dart.dart -o js/out.js
9
- ```
10
-
11
- 2. Copy the `js/preamble.js` contents to the top of the `js/out.js` file
12
- 3. Edit the `index.d.ts` files according to the changes to provide TS typings
13
-
14
- # Running Antlr4
15
-
16
- To generate the Antlr4 Apex output run:
17
-
18
- ```
19
- antlr4 -Dlanguage=Dart lib/src/antlr/grammars/apex/ApexLexer.g4 lib/src/antlr/grammars/apex/ApexParser.g4 -o lib/src/antlr/lib/apex/
20
- ```
21
-
22
- To generate the Antlr4 Apexdoc output run:
23
-
24
- ```
25
- antlr4 -Dlanguage=Dart lib/src/antlr/grammars/apexdoc/ApexdocLexer.g4 lib/src/antlr/grammars/apexdoc/ApexdocParser.g4 -o lib/src/antlr/lib/apexdoc/
26
- ```
package/TODO.md DELETED
@@ -1,5 +0,0 @@
1
- * generate JSON manifest
2
- * Create MDX style documentation, or using Vue if using docsify
3
- * Javadoc style inline references: https://stackoverflow.com/questions/5915992/how-to-reference-a-method-in-javadoc
4
- * Everything should be case insensitive, including references to classes, methods and such. That way something can be
5
- declared uppercased somethere but lowercased somewhere else and the references still work.
@@ -1,30 +0,0 @@
1
- # This file configures the static analysis results for your project (errors,
2
- # warnings, and lints).
3
- #
4
- # This enables the 'recommended' set of lints from `package:lints`.
5
- # This set helps identify many issues that may lead to problems when running
6
- # or consuming Dart code, and enforces writing Dart using a single, idiomatic
7
- # style and format.
8
- #
9
- # If you want a smaller set of lints you can change this to specify
10
- # 'package:lints/core.yaml'. These are just the most critical lints
11
- # (the recommended set includes the core lints).
12
- # The core lints are also what is used by pub.dev for scoring packages.
13
-
14
- include: package:lints/recommended.yaml
15
-
16
- # Uncomment the following section to specify additional rules.
17
-
18
- # linter:
19
- # rules:
20
- # - camel_case_types
21
-
22
- # analyzer:
23
- # exclude:
24
- # - path/to/excluded/files/**
25
-
26
- # For more information about the core and recommended set of lints, see
27
- # https://dart.dev/go/core-lints
28
-
29
- # For additional information about configuring this file, see
30
- # https://dart.dev/guides/language/analysis-options
@@ -1,4 +0,0 @@
1
-
2
- ## 4.9.0
3
-
4
- * Initial release
@@ -1,52 +0,0 @@
1
- [The "BSD 3-clause license"]
2
- Copyright (c) 2012-2017 The ANTLR Project. All rights reserved.
3
-
4
- Redistribution and use in source and binary forms, with or without
5
- modification, are permitted provided that the following conditions
6
- are met:
7
-
8
- 1. Redistributions of source code must retain the above copyright
9
- notice, this list of conditions and the following disclaimer.
10
- 2. Redistributions in binary form must reproduce the above copyright
11
- notice, this list of conditions and the following disclaimer in the
12
- documentation and/or other materials provided with the distribution.
13
- 3. Neither the name of the copyright holder nor the names of its contributors
14
- may be used to endorse or promote products derived from this software
15
- without specific prior written permission.
16
-
17
- THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18
- IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19
- OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20
- IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21
- INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22
- NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23
- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24
- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25
- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26
- THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
-
28
- =====
29
-
30
- MIT License for codepointat.js from https://git.io/codepointat
31
- MIT License for fromcodepoint.js from https://git.io/vDW1m
32
-
33
- Copyright Mathias Bynens <https://mathiasbynens.be/>
34
-
35
- Permission is hereby granted, free of charge, to any person obtaining
36
- a copy of this software and associated documentation files (the
37
- "Software"), to deal in the Software without restriction, including
38
- without limitation the rights to use, copy, modify, merge, publish,
39
- distribute, sublicense, and/or sell copies of the Software, and to
40
- permit persons to whom the Software is furnished to do so, subject to
41
- the following conditions:
42
-
43
- The above copyright notice and this permission notice shall be
44
- included in all copies or substantial portions of the Software.
45
-
46
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
47
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
48
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
49
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
50
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
51
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
52
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -1,11 +0,0 @@
1
- # Dart target for ANTLR 4
2
-
3
- Dart runtime libraries for ANTLR 4
4
-
5
- This runtime is available through [pub](https://pub.dev). The package name is 'antlr4'.
6
-
7
- See www.antlr.org for more information on ANTLR.
8
-
9
- See https://github.com/antlr/antlr4/blob/master/doc/dart-target.md for more information on using ANTLR in Dart.
10
-
11
-
@@ -1 +0,0 @@
1
- include: package:pedantic/analysis_options.yaml
@@ -1,21 +0,0 @@
1
- /*
2
- * Copyright (c) 2012-2017 The ANTLR Project. All rights reserved.
3
- * Use of this file is governed by the BSD 3-clause license that
4
- * can be found in the LICENSE.txt file in the project root.
5
- */
6
-
7
- library antlr4;
8
-
9
- export 'src/atn/atn.dart';
10
- export 'src/dfa/dfa.dart';
11
- export 'src/tree/tree.dart';
12
- export 'src/error/error.dart';
13
- export 'src/rule_context.dart';
14
- export 'src/input_stream.dart';
15
- export 'src/token_stream.dart';
16
- export 'src/lexer.dart';
17
- export 'src/parser.dart';
18
- export 'src/parser_rule_context.dart';
19
- export 'src/vocabulary.dart';
20
- export 'src/runtime_meta_data.dart';
21
- export 'src/token.dart';
@@ -1,18 +0,0 @@
1
- /*
2
- * Copyright (c) 2012-2017 The ANTLR Project. All rights reserved.
3
- * Use of this file is governed by the BSD 3-clause license that
4
- * can be found in the LICENSE.txt file in the project root.
5
- */
6
-
7
- export 'src/atn.dart';
8
- export 'src/atn_config.dart';
9
- export 'src/atn_config_set.dart';
10
- export 'src/atn_deserializer.dart';
11
- export 'src/atn_simulator.dart';
12
- export 'src/atn_state.dart';
13
- export 'src/info.dart';
14
- export 'src/lexer_action_executor.dart';
15
- export 'src/lexer_atn_simulator.dart';
16
- export 'src/parser_atn_simulator.dart';
17
- export 'src/profiling_atn_simulator.dart';
18
- export 'src/transition.dart';
@@ -1,170 +0,0 @@
1
- /*
2
- * Copyright (c) 2012-2017 The ANTLR Project. All rights reserved.
3
- * Use of this file is governed by the BSD 3-clause license that
4
- * can be found in the LICENSE.txt file in the project root.
5
- */
6
-
7
- import '../../interval_set.dart';
8
- import '../../ll1_analyzer.dart';
9
- import '../../rule_context.dart';
10
- import '../../token.dart';
11
- import 'atn_state.dart';
12
- import 'atn_type.dart';
13
- import 'lexer_action.dart';
14
- import 'transition.dart';
15
-
16
- class ATN {
17
- static final INVALID_ALT_NUMBER = 0;
18
-
19
- List<ATNState> states = [];
20
-
21
- /// Each subrule/rule is a decision point and we must track them so we
22
- /// can go back later and build DFA predictors for them. This includes
23
- /// all the rules, subrules, optional blocks, ()+, ()* etc...
24
- List<DecisionState> decisionToState = [];
25
-
26
- /// Maps from rule index to starting state number.
27
- List<RuleStartState> ruleToStartState;
28
-
29
- /// Maps from rule index to stop state number.
30
- List<RuleStopState> ruleToStopState;
31
-
32
- Map<String, TokensStartState> modeNameToStartState = {};
33
-
34
- /// The type of the ATN.
35
- final ATNType grammarType;
36
-
37
- /// The maximum value for any symbol recognized by a transition in the ATN.
38
- final int maxTokenType;
39
-
40
- /// For lexer ATNs, this maps the rule index to the resulting token type.
41
- /// For parser ATNs, this maps the rule index to the generated bypass token
42
- /// type if the
43
- /// {@link ATNDeserializationOptions#isGenerateRuleBypassTransitions}
44
- /// deserialization option was specified; otherwise, this is null.
45
- List<int> ruleToTokenType;
46
-
47
- /// For lexer ATNs, this is an array of [LexerAction] objects which may
48
- /// be referenced by action transitions in the ATN.
49
- List<LexerAction> lexerActions;
50
-
51
- List<TokensStartState> modeToStartState = [];
52
-
53
- /// Used for runtime deserialization of ATNs from strings */
54
- ATN(this.grammarType, this.maxTokenType);
55
-
56
- /// TODO merge doc comment
57
- /// Compute the set of valid tokens that can occur starting in state [s].
58
- /// If [ctx] is null, the set of tokens will not include what can follow
59
- /// the rule surrounding [s]. In other words, the set will be
60
- /// restricted to tokens reachable staying within [s]'s rule.
61
- ///
62
- /// Compute the set of valid tokens that can occur starting in [s] and
63
- /// staying in same rule. {@link Token#EPSILON} is in set if we reach end of
64
- /// rule.
65
- IntervalSet nextTokens(ATNState s, [RuleContext ctx]) {
66
- if (ctx != null) {
67
- return LL1Analyzer(this).LOOK(s, ctx);
68
- }
69
- if (s.nextTokenWithinRule != null) return s.nextTokenWithinRule;
70
- s.nextTokenWithinRule = LL1Analyzer(this).LOOK(s, null);
71
- s.nextTokenWithinRule.setReadonly(true);
72
- return s.nextTokenWithinRule;
73
- }
74
-
75
- void addState(ATNState state) {
76
- if (state != null) {
77
- state.atn = this;
78
- state.stateNumber = states.length;
79
- }
80
-
81
- states.add(state);
82
- }
83
-
84
- void removeState(ATNState state) {
85
- states[state.stateNumber] =
86
- null; // just free mem, don't shift states in list
87
- }
88
-
89
- int defineDecisionState(DecisionState s) {
90
- decisionToState.add(s);
91
- s.decision = decisionToState.length - 1;
92
- return s.decision;
93
- }
94
-
95
- DecisionState getDecisionState(int decision) {
96
- if (decisionToState.isNotEmpty) {
97
- return decisionToState[decision];
98
- }
99
- return null;
100
- }
101
-
102
- int get numberOfDecisions {
103
- return decisionToState.length;
104
- }
105
-
106
- /// Computes the set of input symbols which could follow ATN state number
107
- /// [stateNumber] in the specified full [context]. This method
108
- /// considers the complete parser context, but does not evaluate semantic
109
- /// predicates (i.e. all predicates encountered during the calculation are
110
- /// assumed true). If a path in the ATN exists from the starting state to the
111
- /// [RuleStopState] of the outermost context without matching any
112
- /// symbols, {@link Token#EOF} is added to the returned set.
113
- ///
114
- /// <p>If [context] is null, it is treated as {@link ParserRuleContext#EMPTY}.</p>
115
- ///
116
- /// Note that this does NOT give you the set of all tokens that could
117
- /// appear at a given token position in the input phrase. In other words,
118
- /// it does not answer:
119
- ///
120
- /// "Given a specific partial input phrase, return the set of all tokens
121
- /// that can follow the last token in the input phrase."
122
- ///
123
- /// The big difference is that with just the input, the parser could
124
- /// land right in the middle of a lookahead decision. Getting
125
- /// all *possible* tokens given a partial input stream is a separate
126
- /// computation. See https://github.com/antlr/antlr4/issues/1428
127
- ///
128
- /// For this function, we are specifying an ATN state and call stack to compute
129
- /// what token(s) can come next and specifically: outside of a lookahead decision.
130
- /// That is what you want for error reporting and recovery upon parse error.
131
- ///
132
- /// @param stateNumber the ATN state number
133
- /// @param context the full parse context
134
- /// @return The set of potentially valid input symbols which could follow the
135
- /// specified state in the specified context.
136
- /// @throws IllegalArgumentException if the ATN does not contain a state with
137
- /// number [stateNumber]
138
- IntervalSet getExpectedTokens(int stateNumber, RuleContext context) {
139
- if (stateNumber < 0 || stateNumber >= states.length) {
140
- throw RangeError.index(stateNumber, states, 'stateNumber');
141
- }
142
-
143
- var ctx = context;
144
- final s = states[stateNumber];
145
- var following = nextTokens(s);
146
- if (!following.contains(Token.EPSILON)) {
147
- return following;
148
- }
149
-
150
- final expected = IntervalSet();
151
- expected.addAll(following);
152
- expected.remove(Token.EPSILON);
153
- while (ctx != null &&
154
- ctx.invokingState >= 0 &&
155
- following.contains(Token.EPSILON)) {
156
- final invokingState = states[ctx.invokingState];
157
- RuleTransition rt = invokingState.transition(0);
158
- following = nextTokens(rt.followState);
159
- expected.addAll(following);
160
- expected.remove(Token.EPSILON);
161
- ctx = ctx.parent;
162
- }
163
-
164
- if (following.contains(Token.EPSILON)) {
165
- expected.addOne(Token.EOF);
166
- }
167
-
168
- return expected;
169
- }
170
- }
@@ -1,242 +0,0 @@
1
- /*
2
- * Copyright (c) 2012-2017 The ANTLR Project. All rights reserved.
3
- * Use of this file is governed by the BSD 3-clause license that
4
- * can be found in the LICENSE.txt file in the project root.
5
- */
6
-
7
- import '../../prediction_context.dart';
8
- import '../../recognizer.dart';
9
- import '../../util/murmur_hash.dart';
10
- import 'atn_state.dart';
11
- import 'lexer_action_executor.dart';
12
- import 'semantic_context.dart';
13
-
14
- Map<String, dynamic> checkParams(params, isCfg) {
15
- if (params == null) {
16
- final result = <String, dynamic>{
17
- 'state': null,
18
- 'alt': null,
19
- 'context': null,
20
- 'semanticContext': null
21
- };
22
- if (isCfg) {
23
- result['reachesIntoOuterContext'] = 0;
24
- }
25
- return result;
26
- } else {
27
- final props = <String, dynamic>{};
28
- props['state'] = params.state;
29
- props['alt'] = (params.alt == null) ? null : params.alt;
30
- props['context'] = params.context;
31
- props['semanticContext'] = params.semanticContext;
32
- if (isCfg) {
33
- props['reachesIntoOuterContext'] = params.reachesIntoOuterContext ?? 0;
34
- props['precedenceFilterSuppressed'] =
35
- params.precedenceFilterSuppressed ?? false;
36
- }
37
- return props;
38
- }
39
- }
40
-
41
- /// A tuple: (ATN state, predicted alt, syntactic, semantic context).
42
- /// The syntactic context is a graph-structured stack node whose
43
- /// path(s) to the root is the rule invocation(s)
44
- /// chain used to arrive at the state. The semantic context is
45
- /// the tree of semantic predicates encountered before reaching
46
- /// an ATN state.
47
- class ATNConfig {
48
- /// This field stores the bit mask for implementing the
49
- /// {@link #isPrecedenceFilterSuppressed} property as a bit within the
50
- /// existing {@link #reachesIntoOuterContext} field.
51
- static final int SUPPRESS_PRECEDENCE_FILTER = 0x40000000;
52
-
53
- /// The ATN state associated with this configuration */
54
- ATNState state;
55
-
56
- /// What alt (or lexer rule) is predicted by this configuration */
57
- int alt;
58
-
59
- /// The stack of invoking states leading to the rule/states associated
60
- /// with this config. We track only those contexts pushed during
61
- /// execution of the ATN simulator.
62
- PredictionContext context;
63
-
64
- /// We cannot execute predicates dependent upon local context unless
65
- /// we know for sure we are in the correct context. Because there is
66
- /// no way to do this efficiently, we simply cannot evaluate
67
- /// dependent predicates unless we are in the rule that initially
68
- /// invokes the ATN simulator.
69
- ///
70
- /// <p>
71
- /// closure() tracks the depth of how far we dip into the outer context:
72
- /// depth &gt; 0. Note that it may not be totally accurate depth since I
73
- /// don't ever decrement. TODO: make it a bool then</p>
74
- ///
75
- /// <p>
76
- /// For memory efficiency, the {@link #isPrecedenceFilterSuppressed} method
77
- /// is also backed by this field. Since the field is ly accessible, the
78
- /// highest bit which would not cause the value to become negative is used to
79
- /// store this field. This choice minimizes the risk that code which only
80
- /// compares this value to 0 would be affected by the new purpose of the
81
- /// flag. It also ensures the performance of the existing [ATNConfig]
82
- /// constructors as well as certain operations like
83
- /// {@link ATNConfigSet#add(ATNConfig, DoubleKeyMap)} method are
84
- /// <em>completely</em> unaffected by the change.</p>
85
- int reachesIntoOuterContext = 0;
86
-
87
- SemanticContext semanticContext;
88
-
89
- ATNConfig(this.state, this.alt, this.context,
90
- [this.semanticContext = SemanticContext.NONE]);
91
-
92
- ATNConfig.dup(ATNConfig c,
93
- {this.state, this.alt, this.context, this.semanticContext}) {
94
- state = state ?? c.state;
95
- alt = alt ?? c.alt;
96
- context = context ?? c.context;
97
- semanticContext = semanticContext ?? c.semanticContext;
98
- reachesIntoOuterContext =
99
- c.reachesIntoOuterContext ?? reachesIntoOuterContext;
100
- }
101
-
102
- /// This method gets the value of the {@link #reachesIntoOuterContext} field
103
- /// as it existed prior to the introduction of the
104
- /// {@link #isPrecedenceFilterSuppressed} method.
105
- int get outerContextDepth {
106
- return reachesIntoOuterContext & ~SUPPRESS_PRECEDENCE_FILTER;
107
- }
108
-
109
- bool isPrecedenceFilterSuppressed() {
110
- return (reachesIntoOuterContext & SUPPRESS_PRECEDENCE_FILTER) != 0;
111
- }
112
-
113
- void setPrecedenceFilterSuppressed(bool value) {
114
- if (value) {
115
- reachesIntoOuterContext |= 0x40000000;
116
- } else {
117
- reachesIntoOuterContext &= ~SUPPRESS_PRECEDENCE_FILTER;
118
- }
119
- }
120
-
121
- /// An ATN configuration is equal to another if both have
122
- /// the same state, they predict the same alternative, and
123
- /// syntactic/semantic contexts are the same.
124
- @override
125
- bool operator ==(Object other) {
126
- if (other is ATNConfig && other != null) {
127
- return state.stateNumber == other.state.stateNumber &&
128
- alt == other.alt &&
129
- (context == other.context ||
130
- (context != null && context == other.context)) &&
131
- semanticContext == other.semanticContext &&
132
- isPrecedenceFilterSuppressed() ==
133
- other.isPrecedenceFilterSuppressed();
134
- }
135
- return false;
136
- }
137
-
138
- @override
139
- int get hashCode {
140
- var hashCode = MurmurHash.initialize(7);
141
- hashCode = MurmurHash.update(hashCode, state.stateNumber);
142
- hashCode = MurmurHash.update(hashCode, alt);
143
- hashCode = MurmurHash.update(hashCode, context);
144
- hashCode = MurmurHash.update(hashCode, semanticContext);
145
- hashCode = MurmurHash.finish(hashCode, 4);
146
- return hashCode;
147
- }
148
-
149
- @override
150
- String toString([Recognizer recog, bool showAlt = true]) {
151
- final buf = StringBuffer();
152
- // if ( state.ruleIndex>=0 ) {
153
- // if ( recog!=null ) buf.write(recog.ruleNames[state.ruleIndex]+":");
154
- // else buf.write(state.ruleIndex+":");
155
- // }
156
- buf.write('(');
157
- buf.write(state);
158
- if (showAlt) {
159
- buf.write(',');
160
- buf.write(alt);
161
- }
162
- if (context != null) {
163
- buf.write(',[');
164
- buf.write(context.toString());
165
- buf.write(']');
166
- }
167
- if (semanticContext != null && semanticContext != SemanticContext.NONE) {
168
- buf.write(',');
169
- buf.write(semanticContext);
170
- }
171
- if (outerContextDepth > 0) {
172
- buf.write(',up=');
173
- buf.write(outerContextDepth);
174
- }
175
- buf.write(')');
176
- return buf.toString();
177
- }
178
- }
179
-
180
- class LexerATNConfig extends ATNConfig {
181
- /// Gets the [LexerActionExecutor] capable of executing the embedded
182
- /// action(s) for the current configuration.
183
- LexerActionExecutor lexerActionExecutor;
184
-
185
- bool passedThroughNonGreedyDecision = false;
186
-
187
- LexerATNConfig(ATNState state, int alt, PredictionContext context,
188
- [this.lexerActionExecutor])
189
- : super(state, alt, context, SemanticContext.NONE) {
190
- passedThroughNonGreedyDecision = false;
191
- }
192
-
193
- LexerATNConfig.dup(LexerATNConfig c, ATNState state,
194
- {this.lexerActionExecutor, PredictionContext context})
195
- : super.dup(c, state: state, context: context) {
196
- lexerActionExecutor = lexerActionExecutor ?? c.lexerActionExecutor;
197
- passedThroughNonGreedyDecision = checkNonGreedyDecision(c, state);
198
- }
199
-
200
- bool hasPassedThroughNonGreedyDecision() {
201
- return passedThroughNonGreedyDecision;
202
- }
203
-
204
- @override
205
- int get hashCode {
206
- var hashCode = MurmurHash.initialize(7);
207
- hashCode = MurmurHash.update(hashCode, state.stateNumber);
208
- hashCode = MurmurHash.update(hashCode, alt);
209
- hashCode = MurmurHash.update(hashCode, context);
210
- hashCode = MurmurHash.update(hashCode, semanticContext);
211
- hashCode =
212
- MurmurHash.update(hashCode, passedThroughNonGreedyDecision ? 1 : 0);
213
- hashCode = MurmurHash.update(hashCode, lexerActionExecutor);
214
- hashCode = MurmurHash.finish(hashCode, 6);
215
- return hashCode;
216
- }
217
-
218
- @override
219
- bool operator ==(Object other) {
220
- if (identical(this, other)) {
221
- return true;
222
- } else if (other is LexerATNConfig) {
223
- final lexerOther = other;
224
- if (passedThroughNonGreedyDecision !=
225
- lexerOther.passedThroughNonGreedyDecision) {
226
- return false;
227
- }
228
-
229
- if (lexerActionExecutor != lexerOther.lexerActionExecutor) {
230
- return false;
231
- }
232
-
233
- return super == other;
234
- }
235
- return false;
236
- }
237
-
238
- static bool checkNonGreedyDecision(LexerATNConfig source, ATNState target) {
239
- return source.passedThroughNonGreedyDecision ||
240
- target is DecisionState && target.nonGreedy;
241
- }
242
- }