@ant-yasa/uast-parser-php 0.2.9 → 0.2.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 (33) hide show
  1. package/dist/package.json +1 -1
  2. package/package.json +1 -1
  3. package/src/index.ts +26 -0
  4. package/src/parser.ts +1234 -0
  5. package/tests/benchmark/base/advanced.php +20 -0
  6. package/tests/benchmark/base/advanced.php.json +1269 -0
  7. package/tests/benchmark/base/basic.php +3 -0
  8. package/tests/benchmark/base/basic.php.json +292 -0
  9. package/tests/benchmark/base/closure-class.php +24 -0
  10. package/tests/benchmark/base/closure-class.php.json +1623 -0
  11. package/tests/benchmark/base/control-flow.php +37 -0
  12. package/tests/benchmark/base/control-flow.php.json +2010 -0
  13. package/tests/benchmark/base/enum-trait-adapt.php +31 -0
  14. package/tests/benchmark/base/enum-trait-adapt.php.json +965 -0
  15. package/tests/benchmark/base/exprs.php +4 -0
  16. package/tests/benchmark/base/exprs.php.json +811 -0
  17. package/tests/benchmark/base/flow-extras.php +12 -0
  18. package/tests/benchmark/base/flow-extras.php.json +897 -0
  19. package/tests/benchmark/base/function.php +7 -0
  20. package/tests/benchmark/base/function.php.json +536 -0
  21. package/tests/benchmark/base/modern-php.php +13 -0
  22. package/tests/benchmark/base/modern-php.php.json +508 -0
  23. package/tests/benchmark/base/namespace.php +5 -0
  24. package/tests/benchmark/base/namespace.php.json +307 -0
  25. package/tests/benchmark/base/new-static.php +3 -0
  26. package/tests/benchmark/base/new-static.php.json +399 -0
  27. package/tests/benchmark/base/runtime.php +13 -0
  28. package/tests/benchmark/base/runtime.php.json +1095 -0
  29. package/tests/benchmark/base/strings-casts.php +17 -0
  30. package/tests/benchmark/base/strings-casts.php.json +1357 -0
  31. package/tests/benchmark/base/structures.php +26 -0
  32. package/tests/benchmark/base/structures.php.json +1582 -0
  33. package/tests/index.ts +87 -0
package/dist/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "version": "0.0.0",
4
4
  "description": "for converting php to UAST",
5
5
  "dependencies": {
6
- "@ant-yasa/uast-spec": "file:../specification",
6
+ "@ant-yasa/uast-spec": "^0.2.0",
7
7
  "php-parser": "^3.4.0",
8
8
  "tree-sitter-php": "^0.24.2",
9
9
  "typescript": "^5.7.2",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ant-yasa/uast-parser-php",
3
- "version": "0.2.9",
3
+ "version": "0.2.10",
4
4
  "description": "for converting php to UAST",
5
5
  "dependencies": {
6
6
  "@ant-yasa/uast-spec": "^0.2.0",
package/src/index.ts ADDED
@@ -0,0 +1,26 @@
1
+ import * as phpParser from './parser';
2
+ import * as UAST from '@ant-yasa/uast-spec';
3
+
4
+ export { version } from '../package.json';
5
+
6
+ export class Parser {
7
+ private opts: Record<string, any>;
8
+ private initialized: boolean = false;
9
+
10
+ constructor(opts: Record<string, any> | null = null) {
11
+ this.opts = opts || {};
12
+ }
13
+
14
+ async init(): Promise<void> {
15
+ if (!this.initialized) {
16
+ await phpParser.init();
17
+ this.initialized = true;
18
+ }
19
+ }
20
+
21
+ parse(content: string, opts: Record<string, any> = {}): UAST.Node {
22
+ return phpParser.parse(content, { ...this.opts, ...opts });
23
+ }
24
+ }
25
+
26
+ export { phpParser };