@ant-yasa/uast-parser-php 0.2.9

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.
package/README.md ADDED
@@ -0,0 +1,21 @@
1
+ # @ant-yasa/uast-parser-php
2
+
3
+ PHP parser for YASA-UAST.
4
+
5
+ ## Install
6
+
7
+ ```sh
8
+ npm install
9
+ ```
10
+
11
+ ## Test
12
+
13
+ ```sh
14
+ npm test
15
+ ```
16
+
17
+ ## Build
18
+
19
+ ```sh
20
+ npm run build
21
+ ```
@@ -0,0 +1,30 @@
1
+ {
2
+ "name": "@ant-yasa/uast-parser-php",
3
+ "version": "0.0.0",
4
+ "description": "for converting php to UAST",
5
+ "dependencies": {
6
+ "@ant-yasa/uast-spec": "file:../specification",
7
+ "php-parser": "^3.4.0",
8
+ "tree-sitter-php": "^0.24.2",
9
+ "typescript": "^5.7.2",
10
+ "web-tree-sitter": "^0.26.8"
11
+ },
12
+ "scripts": {
13
+ "test": "mocha --require tsx tests/index.ts",
14
+ "build": "tsc"
15
+ },
16
+ "devDependencies": {
17
+ "@types/mocha": "^10.0.10",
18
+ "@types/node": "^22.13.4",
19
+ "fast-glob": "^3.3.3",
20
+ "mocha": "^11.1.0",
21
+ "ts-node": "^10.9.2",
22
+ "tsx": "^4.21.0"
23
+ },
24
+ "publishConfig": {
25
+ "registry": "https://registry.npmjs.org/"
26
+ },
27
+ "main": "dist/src/index.js",
28
+ "types": "dist/src/index.d.ts",
29
+ "repository": "git@github.com:antgroup/YASA-UAST.git"
30
+ }
@@ -0,0 +1,11 @@
1
+ import * as phpParser from './parser';
2
+ import * as UAST from '@ant-yasa/uast-spec';
3
+ export { version } from '../package.json';
4
+ export declare class Parser {
5
+ private opts;
6
+ private initialized;
7
+ constructor(opts?: Record<string, any> | null);
8
+ init(): Promise<void>;
9
+ parse(content: string, opts?: Record<string, any>): UAST.Node;
10
+ }
11
+ export { phpParser };
@@ -0,0 +1,58 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.phpParser = exports.Parser = exports.version = void 0;
37
+ const phpParser = __importStar(require("./parser"));
38
+ exports.phpParser = phpParser;
39
+ var package_json_1 = require("../package.json");
40
+ Object.defineProperty(exports, "version", { enumerable: true, get: function () { return package_json_1.version; } });
41
+ class Parser {
42
+ opts;
43
+ initialized = false;
44
+ constructor(opts = null) {
45
+ this.opts = opts || {};
46
+ }
47
+ async init() {
48
+ if (!this.initialized) {
49
+ await phpParser.init();
50
+ this.initialized = true;
51
+ }
52
+ }
53
+ parse(content, opts = {}) {
54
+ return phpParser.parse(content, { ...this.opts, ...opts });
55
+ }
56
+ }
57
+ exports.Parser = Parser;
58
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,oDAAsC;AAyB7B,8BAAS;AAtBlB,gDAA0C;AAAjC,uGAAA,OAAO,OAAA;AAEhB,MAAa,MAAM;IACP,IAAI,CAAsB;IAC1B,WAAW,GAAY,KAAK,CAAC;IAErC,YAAY,OAAmC,IAAI;QAC/C,IAAI,CAAC,IAAI,GAAG,IAAI,IAAI,EAAE,CAAC;IAC3B,CAAC;IAED,KAAK,CAAC,IAAI;QACN,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC;YACpB,MAAM,SAAS,CAAC,IAAI,EAAE,CAAC;YACvB,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;QAC5B,CAAC;IACL,CAAC;IAED,KAAK,CAAC,OAAe,EAAE,OAA4B,EAAE;QACjD,OAAO,SAAS,CAAC,KAAK,CAAC,OAAO,EAAE,EAAE,GAAG,IAAI,CAAC,IAAI,EAAE,GAAG,IAAI,EAAE,CAAC,CAAC;IAC/D,CAAC;CACJ;AAlBD,wBAkBC"}
@@ -0,0 +1,5 @@
1
+ import * as UAST from '@ant-yasa/uast-spec';
2
+ export type ParseResult<Result> = Result;
3
+ /** 初始化 tree-sitter parser,加载 PHP WASM */
4
+ export declare function init(): Promise<void>;
5
+ export declare function parse(content: string, opts?: Record<string, any>): ParseResult<UAST.Node>;