@danielblomma/cortex-mcp 1.3.2 → 1.4.1

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 (154) hide show
  1. package/README.md +62 -14
  2. package/bin/cortex.mjs +10 -1
  3. package/package.json +2 -2
  4. package/scaffold/mcp/package-lock.json +3 -7
  5. package/scaffold/mcp/package.json +1 -1
  6. package/scaffold/scripts/dashboard.mjs +15 -1
  7. package/scaffold/scripts/ingest.mjs +323 -50
  8. package/scaffold/scripts/parsers/bash-treesitter.mjs +229 -0
  9. package/scaffold/scripts/parsers/cpp-dispatch.mjs +56 -0
  10. package/scaffold/scripts/parsers/cpp-treesitter.mjs +333 -0
  11. package/scaffold/scripts/parsers/csharp.mjs +197 -10
  12. package/scaffold/scripts/parsers/dotnet/CSharpParser/CSharpParser.csproj +1 -0
  13. package/scaffold/scripts/parsers/dotnet/CSharpParser/Program.cs +126 -21
  14. package/scaffold/scripts/parsers/go-treesitter.mjs +283 -0
  15. package/scaffold/scripts/parsers/java-treesitter.mjs +250 -0
  16. package/scaffold/scripts/parsers/javascript/ast.mjs +118 -12
  17. package/scaffold/scripts/parsers/javascript/chunks.mjs +4 -0
  18. package/scaffold/scripts/parsers/javascript/patterns.mjs +6 -0
  19. package/scaffold/scripts/parsers/javascript.mjs +4 -19
  20. package/scaffold/scripts/parsers/node_modules/.package-lock.json +57 -0
  21. package/scaffold/scripts/parsers/node_modules/acorn/CHANGELOG.md +972 -0
  22. package/scaffold/scripts/parsers/node_modules/acorn/LICENSE +21 -0
  23. package/scaffold/scripts/parsers/node_modules/acorn/README.md +301 -0
  24. package/scaffold/scripts/parsers/node_modules/acorn/bin/acorn +4 -0
  25. package/scaffold/scripts/parsers/node_modules/acorn/dist/acorn.d.mts +883 -0
  26. package/scaffold/scripts/parsers/node_modules/acorn/dist/acorn.d.ts +883 -0
  27. package/scaffold/scripts/parsers/node_modules/acorn/dist/acorn.js +6295 -0
  28. package/scaffold/scripts/parsers/node_modules/acorn/dist/acorn.mjs +6266 -0
  29. package/scaffold/scripts/parsers/node_modules/acorn/dist/bin.js +90 -0
  30. package/scaffold/scripts/parsers/node_modules/acorn/package.json +50 -0
  31. package/scaffold/scripts/parsers/node_modules/acorn-typescript/CHANGELOG.md +421 -0
  32. package/scaffold/scripts/parsers/node_modules/acorn-typescript/LICENSE +21 -0
  33. package/scaffold/scripts/parsers/node_modules/acorn-typescript/README.md +81 -0
  34. package/scaffold/scripts/parsers/node_modules/acorn-typescript/lib/error.d.ts +103 -0
  35. package/scaffold/scripts/parsers/node_modules/acorn-typescript/lib/error.js +78 -0
  36. package/scaffold/scripts/parsers/node_modules/acorn-typescript/lib/error.js.map +1 -0
  37. package/scaffold/scripts/parsers/node_modules/acorn-typescript/lib/extentions/decorators.d.ts +167 -0
  38. package/scaffold/scripts/parsers/node_modules/acorn-typescript/lib/extentions/decorators.js +75 -0
  39. package/scaffold/scripts/parsers/node_modules/acorn-typescript/lib/extentions/decorators.js.map +1 -0
  40. package/scaffold/scripts/parsers/node_modules/acorn-typescript/lib/extentions/import-assertions.d.ts +177 -0
  41. package/scaffold/scripts/parsers/node_modules/acorn-typescript/lib/extentions/import-assertions.js +56 -0
  42. package/scaffold/scripts/parsers/node_modules/acorn-typescript/lib/extentions/import-assertions.js.map +1 -0
  43. package/scaffold/scripts/parsers/node_modules/acorn-typescript/lib/extentions/jsx/index.d.ts +198 -0
  44. package/scaffold/scripts/parsers/node_modules/acorn-typescript/lib/extentions/jsx/index.js +327 -0
  45. package/scaffold/scripts/parsers/node_modules/acorn-typescript/lib/extentions/jsx/index.js.map +1 -0
  46. package/scaffold/scripts/parsers/node_modules/acorn-typescript/lib/extentions/jsx/xhtml.d.ts +256 -0
  47. package/scaffold/scripts/parsers/node_modules/acorn-typescript/lib/extentions/jsx/xhtml.js +256 -0
  48. package/scaffold/scripts/parsers/node_modules/acorn-typescript/lib/extentions/jsx/xhtml.js.map +1 -0
  49. package/scaffold/scripts/parsers/node_modules/acorn-typescript/lib/index.d.ts +472 -0
  50. package/scaffold/scripts/parsers/node_modules/acorn-typescript/lib/index.js +1 -0
  51. package/scaffold/scripts/parsers/node_modules/acorn-typescript/lib/index.js.map +1 -0
  52. package/scaffold/scripts/parsers/node_modules/acorn-typescript/lib/index.mjs +1 -0
  53. package/scaffold/scripts/parsers/node_modules/acorn-typescript/lib/middleware.d.ts +159 -0
  54. package/scaffold/scripts/parsers/node_modules/acorn-typescript/lib/middleware.js +2 -0
  55. package/scaffold/scripts/parsers/node_modules/acorn-typescript/lib/middleware.js.map +1 -0
  56. package/scaffold/scripts/parsers/node_modules/acorn-typescript/lib/parseutil.d.ts +10 -0
  57. package/scaffold/scripts/parsers/node_modules/acorn-typescript/lib/parseutil.js +38 -0
  58. package/scaffold/scripts/parsers/node_modules/acorn-typescript/lib/parseutil.js.map +1 -0
  59. package/scaffold/scripts/parsers/node_modules/acorn-typescript/lib/scopeflags.d.ts +12 -0
  60. package/scaffold/scripts/parsers/node_modules/acorn-typescript/lib/scopeflags.js +29 -0
  61. package/scaffold/scripts/parsers/node_modules/acorn-typescript/lib/scopeflags.js.map +1 -0
  62. package/scaffold/scripts/parsers/node_modules/acorn-typescript/lib/tokenType.d.ts +2 -0
  63. package/scaffold/scripts/parsers/node_modules/acorn-typescript/lib/tokenType.js +118 -0
  64. package/scaffold/scripts/parsers/node_modules/acorn-typescript/lib/tokenType.js.map +1 -0
  65. package/scaffold/scripts/parsers/node_modules/acorn-typescript/lib/types.d.ts +60 -0
  66. package/scaffold/scripts/parsers/node_modules/acorn-typescript/lib/types.js +2 -0
  67. package/scaffold/scripts/parsers/node_modules/acorn-typescript/lib/types.js.map +1 -0
  68. package/scaffold/scripts/parsers/node_modules/acorn-typescript/lib/whitespace.d.ts +2 -0
  69. package/scaffold/scripts/parsers/node_modules/acorn-typescript/lib/whitespace.js +19 -0
  70. package/scaffold/scripts/parsers/node_modules/acorn-typescript/lib/whitespace.js.map +1 -0
  71. package/scaffold/scripts/parsers/node_modules/acorn-typescript/package.json +53 -0
  72. package/scaffold/scripts/parsers/node_modules/acorn-typescript/tsconfig.json +19 -0
  73. package/scaffold/scripts/parsers/node_modules/acorn-walk/CHANGELOG.md +209 -0
  74. package/scaffold/scripts/parsers/node_modules/acorn-walk/LICENSE +21 -0
  75. package/scaffold/scripts/parsers/node_modules/acorn-walk/README.md +124 -0
  76. package/scaffold/scripts/parsers/node_modules/acorn-walk/dist/walk.d.mts +152 -0
  77. package/scaffold/scripts/parsers/node_modules/acorn-walk/dist/walk.d.ts +152 -0
  78. package/scaffold/scripts/parsers/node_modules/acorn-walk/dist/walk.js +485 -0
  79. package/scaffold/scripts/parsers/node_modules/acorn-walk/dist/walk.mjs +467 -0
  80. package/scaffold/scripts/parsers/node_modules/acorn-walk/package.json +50 -0
  81. package/scaffold/scripts/parsers/node_modules/tree-sitter-wasms/LICENSE +24 -0
  82. package/scaffold/scripts/parsers/node_modules/tree-sitter-wasms/README.md +23 -0
  83. package/scaffold/scripts/parsers/node_modules/tree-sitter-wasms/out/tree-sitter-bash.wasm +0 -0
  84. package/scaffold/scripts/parsers/node_modules/tree-sitter-wasms/out/tree-sitter-c.wasm +0 -0
  85. package/scaffold/scripts/parsers/node_modules/tree-sitter-wasms/out/tree-sitter-c_sharp.wasm +0 -0
  86. package/scaffold/scripts/parsers/node_modules/tree-sitter-wasms/out/tree-sitter-cpp.wasm +0 -0
  87. package/scaffold/scripts/parsers/node_modules/tree-sitter-wasms/out/tree-sitter-css.wasm +0 -0
  88. package/scaffold/scripts/parsers/node_modules/tree-sitter-wasms/out/tree-sitter-dart.wasm +0 -0
  89. package/scaffold/scripts/parsers/node_modules/tree-sitter-wasms/out/tree-sitter-elisp.wasm +0 -0
  90. package/scaffold/scripts/parsers/node_modules/tree-sitter-wasms/out/tree-sitter-elixir.wasm +0 -0
  91. package/scaffold/scripts/parsers/node_modules/tree-sitter-wasms/out/tree-sitter-elm.wasm +0 -0
  92. package/scaffold/scripts/parsers/node_modules/tree-sitter-wasms/out/tree-sitter-embedded_template.wasm +0 -0
  93. package/scaffold/scripts/parsers/node_modules/tree-sitter-wasms/out/tree-sitter-go.wasm +0 -0
  94. package/scaffold/scripts/parsers/node_modules/tree-sitter-wasms/out/tree-sitter-html.wasm +0 -0
  95. package/scaffold/scripts/parsers/node_modules/tree-sitter-wasms/out/tree-sitter-java.wasm +0 -0
  96. package/scaffold/scripts/parsers/node_modules/tree-sitter-wasms/out/tree-sitter-javascript.wasm +0 -0
  97. package/scaffold/scripts/parsers/node_modules/tree-sitter-wasms/out/tree-sitter-json.wasm +0 -0
  98. package/scaffold/scripts/parsers/node_modules/tree-sitter-wasms/out/tree-sitter-kotlin.wasm +0 -0
  99. package/scaffold/scripts/parsers/node_modules/tree-sitter-wasms/out/tree-sitter-lua.wasm +0 -0
  100. package/scaffold/scripts/parsers/node_modules/tree-sitter-wasms/out/tree-sitter-objc.wasm +0 -0
  101. package/scaffold/scripts/parsers/node_modules/tree-sitter-wasms/out/tree-sitter-ocaml.wasm +0 -0
  102. package/scaffold/scripts/parsers/node_modules/tree-sitter-wasms/out/tree-sitter-php.wasm +0 -0
  103. package/scaffold/scripts/parsers/node_modules/tree-sitter-wasms/out/tree-sitter-python.wasm +0 -0
  104. package/scaffold/scripts/parsers/node_modules/tree-sitter-wasms/out/tree-sitter-ql.wasm +0 -0
  105. package/scaffold/scripts/parsers/node_modules/tree-sitter-wasms/out/tree-sitter-rescript.wasm +0 -0
  106. package/scaffold/scripts/parsers/node_modules/tree-sitter-wasms/out/tree-sitter-ruby.wasm +0 -0
  107. package/scaffold/scripts/parsers/node_modules/tree-sitter-wasms/out/tree-sitter-rust.wasm +0 -0
  108. package/scaffold/scripts/parsers/node_modules/tree-sitter-wasms/out/tree-sitter-scala.wasm +0 -0
  109. package/scaffold/scripts/parsers/node_modules/tree-sitter-wasms/out/tree-sitter-solidity.wasm +0 -0
  110. package/scaffold/scripts/parsers/node_modules/tree-sitter-wasms/out/tree-sitter-swift.wasm +0 -0
  111. package/scaffold/scripts/parsers/node_modules/tree-sitter-wasms/out/tree-sitter-systemrdl.wasm +0 -0
  112. package/scaffold/scripts/parsers/node_modules/tree-sitter-wasms/out/tree-sitter-tlaplus.wasm +0 -0
  113. package/scaffold/scripts/parsers/node_modules/tree-sitter-wasms/out/tree-sitter-toml.wasm +0 -0
  114. package/scaffold/scripts/parsers/node_modules/tree-sitter-wasms/out/tree-sitter-tsx.wasm +0 -0
  115. package/scaffold/scripts/parsers/node_modules/tree-sitter-wasms/out/tree-sitter-typescript.wasm +0 -0
  116. package/scaffold/scripts/parsers/node_modules/tree-sitter-wasms/out/tree-sitter-vue.wasm +0 -0
  117. package/scaffold/scripts/parsers/node_modules/tree-sitter-wasms/out/tree-sitter-yaml.wasm +0 -0
  118. package/scaffold/scripts/parsers/node_modules/tree-sitter-wasms/out/tree-sitter-zig.wasm +0 -0
  119. package/scaffold/scripts/parsers/node_modules/tree-sitter-wasms/package.json +64 -0
  120. package/scaffold/scripts/parsers/node_modules/web-tree-sitter/LICENSE +21 -0
  121. package/scaffold/scripts/parsers/node_modules/web-tree-sitter/README.md +198 -0
  122. package/scaffold/scripts/parsers/node_modules/web-tree-sitter/package.json +37 -0
  123. package/scaffold/scripts/parsers/node_modules/web-tree-sitter/tree-sitter-web.d.ts +242 -0
  124. package/scaffold/scripts/parsers/node_modules/web-tree-sitter/tree-sitter.js +1 -0
  125. package/scaffold/scripts/parsers/node_modules/web-tree-sitter/tree-sitter.wasm +0 -0
  126. package/scaffold/scripts/parsers/package-lock.json +19 -1
  127. package/scaffold/scripts/parsers/package.json +3 -1
  128. package/scaffold/scripts/parsers/python-treesitter.mjs +271 -0
  129. package/scaffold/scripts/parsers/ruby-treesitter.mjs +271 -0
  130. package/scaffold/scripts/parsers/rust-dispatch.mjs +43 -0
  131. package/scaffold/scripts/parsers/rust-treesitter.mjs +291 -0
  132. package/scaffold/scripts/parsers/tree-sitter/base.mjs +163 -0
  133. package/scaffold/scripts/parsers/tree-sitter/queries/bash.calls.scm +7 -0
  134. package/scaffold/scripts/parsers/tree-sitter/queries/bash.chunks.scm +6 -0
  135. package/scaffold/scripts/parsers/tree-sitter/queries/bash.imports.scm +5 -0
  136. package/scaffold/scripts/parsers/tree-sitter/queries/cpp.calls.scm +17 -0
  137. package/scaffold/scripts/parsers/tree-sitter/queries/cpp.chunks.scm +30 -0
  138. package/scaffold/scripts/parsers/tree-sitter/queries/cpp.imports.scm +6 -0
  139. package/scaffold/scripts/parsers/tree-sitter/queries/go.calls.scm +11 -0
  140. package/scaffold/scripts/parsers/tree-sitter/queries/go.chunks.scm +19 -0
  141. package/scaffold/scripts/parsers/tree-sitter/queries/go.imports.scm +6 -0
  142. package/scaffold/scripts/parsers/tree-sitter/queries/java.calls.scm +6 -0
  143. package/scaffold/scripts/parsers/tree-sitter/queries/java.chunks.scm +23 -0
  144. package/scaffold/scripts/parsers/tree-sitter/queries/java.imports.scm +6 -0
  145. package/scaffold/scripts/parsers/tree-sitter/queries/python.calls.scm +11 -0
  146. package/scaffold/scripts/parsers/tree-sitter/queries/python.chunks.scm +11 -0
  147. package/scaffold/scripts/parsers/tree-sitter/queries/python.imports.scm +13 -0
  148. package/scaffold/scripts/parsers/tree-sitter/queries/ruby.calls.scm +6 -0
  149. package/scaffold/scripts/parsers/tree-sitter/queries/ruby.chunks.scm +16 -0
  150. package/scaffold/scripts/parsers/tree-sitter/queries/ruby.imports.scm +8 -0
  151. package/scaffold/scripts/parsers/tree-sitter/queries/rust.calls.scm +31 -0
  152. package/scaffold/scripts/parsers/tree-sitter/queries/rust.chunks.scm +29 -0
  153. package/scaffold/scripts/parsers/tree-sitter/queries/rust.imports.scm +5 -0
  154. package/scaffold/scripts/parsers/vb6.mjs +395 -0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (C) 2012-2022 by various contributors (see AUTHORS)
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,301 @@
1
+ # Acorn
2
+
3
+ A tiny, fast JavaScript parser written in JavaScript.
4
+
5
+ ## Community
6
+
7
+ Acorn is open source software released under an
8
+ [MIT license](https://github.com/acornjs/acorn/blob/master/acorn/LICENSE).
9
+
10
+ You are welcome to
11
+ [report bugs](https://github.com/acornjs/acorn/issues) or create pull
12
+ requests on [github](https://github.com/acornjs/acorn).
13
+
14
+ ## Installation
15
+
16
+ The easiest way to install acorn is from [`npm`](https://www.npmjs.com/):
17
+
18
+ ```sh
19
+ npm install acorn
20
+ ```
21
+
22
+ Alternately, you can download the source and build acorn yourself:
23
+
24
+ ```sh
25
+ git clone https://github.com/acornjs/acorn.git
26
+ cd acorn
27
+ npm install
28
+ ```
29
+ ## Importing acorn
30
+
31
+ ESM as well as CommonJS is supported for all 3: `acorn`, `acorn-walk` and `acorn-loose`.
32
+
33
+ ESM example for `acorn`:
34
+
35
+ ```js
36
+ import * as acorn from "acorn"
37
+ ```
38
+
39
+ CommonJS example for `acorn`:
40
+
41
+ ```js
42
+ let acorn = require("acorn")
43
+ ```
44
+
45
+ ESM is preferred, as it allows better editor auto-completions by offering TypeScript support.
46
+ For this reason, following examples will use ESM imports.
47
+
48
+ ## Interface
49
+
50
+ **parse**`(input, options)` is the main interface to the library. The
51
+ `input` parameter is a string, `options` must be an object setting
52
+ some of the options listed below. The return value will be an abstract
53
+ syntax tree object as specified by the [ESTree
54
+ spec](https://github.com/estree/estree).
55
+
56
+ ```javascript
57
+ import * as acorn from "acorn"
58
+ console.log(acorn.parse("1 + 1", {ecmaVersion: 2020}))
59
+ ```
60
+
61
+ When encountering a syntax error, the parser will raise a
62
+ `SyntaxError` object with a meaningful message. The error object will
63
+ have a `pos` property that indicates the string offset at which the
64
+ error occurred, and a `loc` object that contains a `{line, column}`
65
+ object referring to that same position.
66
+
67
+ Options are provided by in a second argument, which should be an
68
+ object containing any of these fields (only `ecmaVersion` is
69
+ required):
70
+
71
+ - **ecmaVersion**: Indicates the ECMAScript version to parse. Can be a
72
+ number, either in year (`2022`) or plain version number (`6`) form,
73
+ or `"latest"` (the latest the library supports). This influences
74
+ support for strict mode, the set of reserved words, and support for
75
+ new syntax features.
76
+
77
+ **NOTE**: Only 'stage 4' (finalized) ECMAScript features are being
78
+ implemented by Acorn. Other proposed new features must be
79
+ implemented through plugins.
80
+
81
+ - **sourceType**: Indicate the mode the code should be parsed in. Can be
82
+ either `"script"`, `"module"` or `"commonjs"`. This influences global strict mode
83
+ and parsing of `import` and `export` declarations.
84
+
85
+ **NOTE**: If set to `"module"`, then static `import` / `export` syntax
86
+ will be valid, even if `ecmaVersion` is less than 6. If set to `"commonjs"`,
87
+ it is the same as `"script"` except that the top-level scope behaves like a function.
88
+
89
+ - **onInsertedSemicolon**: If given a callback, that callback will be
90
+ called whenever a missing semicolon is inserted by the parser. The
91
+ callback will be given the character offset of the point where the
92
+ semicolon is inserted as argument, and if `locations` is on, also a
93
+ `{line, column}` object representing this position.
94
+
95
+ - **onTrailingComma**: Like `onInsertedSemicolon`, but for trailing
96
+ commas.
97
+
98
+ - **allowReserved**: If `false`, using a reserved word will generate
99
+ an error. Defaults to `true` for `ecmaVersion` 3, `false` for higher
100
+ versions. When given the value `"never"`, reserved words and
101
+ keywords can also not be used as property names (as in Internet
102
+ Explorer's old parser).
103
+
104
+ - **allowReturnOutsideFunction**: By default, a return statement at
105
+ the top level raises an error. Set this to `true` to accept such
106
+ code.
107
+
108
+ - **allowImportExportEverywhere**: By default, `import` and `export`
109
+ declarations can only appear at a program's top level. Setting this
110
+ option to `true` allows them anywhere where a statement is allowed,
111
+ and also allows `import.meta` expressions to appear in scripts
112
+ (when `sourceType` is not `"module"`).
113
+
114
+ - **allowAwaitOutsideFunction**: If `false`, `await` expressions can
115
+ only appear inside `async` functions. Defaults to `true` in modules
116
+ for `ecmaVersion` 2022 and later, `false` for lower versions.
117
+ Setting this option to `true` allows to have top-level `await`
118
+ expressions. They are still not allowed in non-`async` functions,
119
+ though. Setting this option to `true` is not allowed when `sourceType: "commonjs"`.
120
+
121
+ - **allowSuperOutsideMethod**: By default, `super` outside a method
122
+ raises an error. Set this to `true` to accept such code.
123
+
124
+ - **allowHashBang**: When this is enabled, if the code starts with the
125
+ characters `#!` (as in a shellscript), the first line will be
126
+ treated as a comment. Defaults to true when `ecmaVersion` >= 2023.
127
+
128
+ - **checkPrivateFields**: By default, the parser will verify that
129
+ private properties are only used in places where they are valid and
130
+ have been declared. Set this to false to turn such checks off.
131
+
132
+ - **locations**: When `true`, each node has a `loc` object attached
133
+ with `start` and `end` subobjects, each of which contains the
134
+ one-based line and zero-based column numbers in `{line, column}`
135
+ form. Default is `false`.
136
+
137
+ - **onToken**: If a function is passed for this option, each found
138
+ token will be passed in same format as tokens returned from
139
+ `tokenizer().getToken()`.
140
+
141
+ If array is passed, each found token is pushed to it.
142
+
143
+ Note that you are not allowed to call the parser from the
144
+ callback—that will corrupt its internal state.
145
+
146
+ - **onComment**: If a function is passed for this option, whenever a
147
+ comment is encountered the function will be called with the
148
+ following parameters:
149
+
150
+ - `block`: `true` if the comment is a block comment, false if it
151
+ is a line comment.
152
+ - `text`: The content of the comment.
153
+ - `start`: Character offset of the start of the comment.
154
+ - `end`: Character offset of the end of the comment.
155
+
156
+ When the `locations` options is on, the `{line, column}` locations
157
+ of the comment’s start and end are passed as two additional
158
+ parameters.
159
+
160
+ If array is passed for this option, each found comment is pushed
161
+ to it as object in Esprima format:
162
+
163
+ ```javascript
164
+ {
165
+ "type": "Line" | "Block",
166
+ "value": "comment text",
167
+ "start": Number,
168
+ "end": Number,
169
+ // If `locations` option is on:
170
+ "loc": {
171
+ "start": {line: Number, column: Number}
172
+ "end": {line: Number, column: Number}
173
+ },
174
+ // If `ranges` option is on:
175
+ "range": [Number, Number]
176
+ }
177
+ ```
178
+
179
+ Note that you are not allowed to call the parser from the
180
+ callback—that will corrupt its internal state.
181
+
182
+ - **ranges**: Nodes have their start and end characters offsets
183
+ recorded in `start` and `end` properties (directly on the node,
184
+ rather than the `loc` object, which holds line/column data. To also
185
+ add a
186
+ [semi-standardized](https://bugzilla.mozilla.org/show_bug.cgi?id=745678)
187
+ `range` property holding a `[start, end]` array with the same
188
+ numbers, set the `ranges` option to `true`.
189
+
190
+ - **program**: It is possible to parse multiple files into a single
191
+ AST by passing the tree produced by parsing the first file as the
192
+ `program` option in subsequent parses. This will add the toplevel
193
+ forms of the parsed file to the "Program" (top) node of an existing
194
+ parse tree.
195
+
196
+ - **sourceFile**: When the `locations` option is `true`, you can pass
197
+ this option to add a `source` attribute in every node’s `loc`
198
+ object. Note that the contents of this option are not examined or
199
+ processed in any way; you are free to use whatever format you
200
+ choose.
201
+
202
+ - **directSourceFile**: Like `sourceFile`, but a `sourceFile` property
203
+ will be added (regardless of the `location` option) directly to the
204
+ nodes, rather than the `loc` object.
205
+
206
+ - **preserveParens**: If this option is `true`, parenthesized expressions
207
+ are represented by (non-standard) `ParenthesizedExpression` nodes
208
+ that have a single `expression` property containing the expression
209
+ inside parentheses.
210
+
211
+ **parseExpressionAt**`(input, offset, options)` will parse a single
212
+ expression in a string, and return its AST. It will not complain if
213
+ there is more of the string left after the expression.
214
+
215
+ **tokenizer**`(input, options)` returns an object with a `getToken`
216
+ method that can be called repeatedly to get the next token, a `{start,
217
+ end, type, value}` object (with added `loc` property when the
218
+ `locations` option is enabled and `range` property when the `ranges`
219
+ option is enabled). When the token's type is `tokTypes.eof`, you
220
+ should stop calling the method, since it will keep returning that same
221
+ token forever.
222
+
223
+ Note that tokenizing JavaScript without parsing it is, in modern
224
+ versions of the language, not really possible due to the way syntax is
225
+ overloaded in ways that can only be disambiguated by the parse
226
+ context. This package applies a bunch of heuristics to try and do a
227
+ reasonable job, but you are advised to use `parse` with the `onToken`
228
+ option instead of this.
229
+
230
+ In ES6 environment, returned result can be used as any other
231
+ protocol-compliant iterable:
232
+
233
+ ```javascript
234
+ for (let token of acorn.tokenizer(str)) {
235
+ // iterate over the tokens
236
+ }
237
+
238
+ // transform code to array of tokens:
239
+ var tokens = [...acorn.tokenizer(str)]
240
+ ```
241
+
242
+ **tokTypes** holds an object mapping names to the token type objects
243
+ that end up in the `type` properties of tokens.
244
+
245
+ **getLineInfo**`(input, offset)` can be used to get a `{line,
246
+ column}` object for a given program string and offset.
247
+
248
+ ### The `Parser` class
249
+
250
+ Instances of the **`Parser`** class contain all the state and logic
251
+ that drives a parse. It has static methods `parse`,
252
+ `parseExpressionAt`, and `tokenizer` that match the top-level
253
+ functions by the same name.
254
+
255
+ When extending the parser with plugins, you need to call these methods
256
+ on the extended version of the class. To extend a parser with plugins,
257
+ you can use its static `extend` method.
258
+
259
+ ```javascript
260
+ var acorn = require("acorn")
261
+ var jsx = require("acorn-jsx")
262
+ var JSXParser = acorn.Parser.extend(jsx())
263
+ JSXParser.parse("foo(<bar/>)", {ecmaVersion: 2020})
264
+ ```
265
+
266
+ The `extend` method takes any number of plugin values, and returns a
267
+ new `Parser` class that includes the extra parser logic provided by
268
+ the plugins.
269
+
270
+ ## Command line interface
271
+
272
+ The `bin/acorn` utility can be used to parse a file from the command
273
+ line. It accepts as arguments its input file and the following
274
+ options:
275
+
276
+ - `--ecma3|--ecma5|--ecma6|--ecma7|--ecma8|--ecma9|--ecma10`: Sets the ECMAScript version
277
+ to parse. Default is version 9.
278
+
279
+ - `--module`: Sets the parsing mode to `"module"`. Is set to `"script"` otherwise.
280
+
281
+ - `--locations`: Attaches a "loc" object to each node with "start" and
282
+ "end" subobjects, each of which contains the one-based line and
283
+ zero-based column numbers in `{line, column}` form.
284
+
285
+ - `--allow-hash-bang`: If the code starts with the characters #! (as
286
+ in a shellscript), the first line will be treated as a comment.
287
+
288
+ - `--allow-await-outside-function`: Allows top-level `await` expressions.
289
+ See the `allowAwaitOutsideFunction` option for more information.
290
+
291
+ - `--compact`: No whitespace is used in the AST output.
292
+
293
+ - `--silent`: Do not output the AST, just return the exit status.
294
+
295
+ - `--help`: Print the usage information and quit.
296
+
297
+ The utility spits out the syntax tree as JSON data.
298
+
299
+ ## Existing plugins
300
+
301
+ - [`acorn-jsx`](https://github.com/RReverser/acorn-jsx): Parse [Facebook JSX syntax extensions](https://github.com/facebook/jsx)
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env node
2
+ "use strict"
3
+
4
+ require("../dist/bin.js")