@profile-psl/psl-parser 0.1.0
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/CHANGELOG.md +58 -0
- package/LICENSE +9 -0
- package/README.md +34 -0
- package/config.d.ts +29 -0
- package/config.js +51 -0
- package/index.d.ts +6 -0
- package/index.js +7 -0
- package/package.json +35 -0
- package/parser.d.ts +155 -0
- package/parser.js +707 -0
- package/statementParser.d.ts +93 -0
- package/statementParser.js +739 -0
- package/tokenizer.d.ts +139 -0
- package/tokenizer.js +535 -0
- package/utilities.d.ts +43 -0
- package/utilities.js +427 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## [Unreleased]
|
|
9
|
+
|
|
10
|
+
## [0.1.0]
|
|
11
|
+
|
|
12
|
+
### Changed
|
|
13
|
+
|
|
14
|
+
- Project split from original source [ing-bank/vscode-psl](https://github.com/ing-bank/vscode-psl.git)
|
|
15
|
+
to new dedicated source [ing-bank/psl-parser](https://github.com/ing-bank/psl-parser.git).
|
|
16
|
+
This deprecates all previous released versions. Previous revisions from the
|
|
17
|
+
original CHANGELOG are kept, even though the change log does not contain a
|
|
18
|
+
lot of information.
|
|
19
|
+
- Update this changelog to follow the latest format from *Keep a Changelog*.
|
|
20
|
+
- Let functions return `null` instead of `undefined` for those functions where
|
|
21
|
+
not all paths had a return value.
|
|
22
|
+
- Switched linter from `tslint` to `eslint`.
|
|
23
|
+
- Update all the dependencies to the latest version
|
|
24
|
+
- Change the module type to ES module.
|
|
25
|
+
- Moved from jest to node test framework.
|
|
26
|
+
|
|
27
|
+
## [0.0.3] - 2019-04-19
|
|
28
|
+
|
|
29
|
+
### Changed
|
|
30
|
+
|
|
31
|
+
- Minor changes.
|
|
32
|
+
|
|
33
|
+
## [0.0.2] - 2019-04-19
|
|
34
|
+
|
|
35
|
+
### Changed
|
|
36
|
+
|
|
37
|
+
- Minor changes.
|
|
38
|
+
|
|
39
|
+
## [0.0.1] - 2019-04-19
|
|
40
|
+
|
|
41
|
+
### Added
|
|
42
|
+
|
|
43
|
+
- Initial publication.
|
|
44
|
+
|
|
45
|
+
[Unreleased]: https://github.com/ing-bank/psl-parser/compare/v0.1.0...HEAD
|
|
46
|
+
[0.1.0]: https://github.com/ing-bank/psl-parser/compare/4814107ce1840d92c2ab0de99e31887014453d4c...v0.1.0
|
|
47
|
+
|
|
48
|
+
<!--
|
|
49
|
+
The links to 0.0.3 and earlier go to the commit where the package.json
|
|
50
|
+
for the psl-parser was changed. The diffs are not usable as this project
|
|
51
|
+
contains a lot more than just the psl-parser.
|
|
52
|
+
|
|
53
|
+
The links for 0.0.1 and 0.0.2 point to the same commit, as the first occurrence
|
|
54
|
+
of the package.json already had the version set to 0.0.2
|
|
55
|
+
-->
|
|
56
|
+
[0.0.3]: https://github.com/ing-bank/vscode-psl/commit/4a89048f6c2c45218986284f00e8898d8500d9f3
|
|
57
|
+
[0.0.2]: https://github.com/ing-bank/vscode-psl/commit/4bed075d2087d7fa714370df71acc5d43a0ef9fe
|
|
58
|
+
[0.0.1]: https://github.com/ing-bank/vscode-psl/commit/4bed075d2087d7fa714370df71acc5d43a0ef9fe
|
package/LICENSE
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2018 ING Bank NV
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
6
|
+
|
|
7
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
8
|
+
|
|
9
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# psl-parser
|
|
2
|
+
|
|
3
|
+
Implementation of a Profile Scripting Language Parser in TypeScript.
|
|
4
|
+
|
|
5
|
+
## Usage
|
|
6
|
+
|
|
7
|
+
```javascript
|
|
8
|
+
import { parseText } from 'psl-parser';
|
|
9
|
+
|
|
10
|
+
const parsedPsl = parseText(/* PSL source text */);
|
|
11
|
+
|
|
12
|
+
parsedPsl.methods.forEach(method => {
|
|
13
|
+
console.log(method.id.value);
|
|
14
|
+
})
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Development
|
|
18
|
+
|
|
19
|
+
If you would like to join the development of this project, you will need to
|
|
20
|
+
install [node.js] (with npm) in order to install the dependencies.
|
|
21
|
+
|
|
22
|
+
Once you clone the project, from the command line in the root of this project,
|
|
23
|
+
run `npm install`.
|
|
24
|
+
|
|
25
|
+
## History
|
|
26
|
+
|
|
27
|
+
This project was originally developed under [ing-bank/vscode-psl] repository,
|
|
28
|
+
in order to preserve that history this project was cloned from
|
|
29
|
+
[ing-bank/vscode-psl] and only code relevant to the psl-parser was retained.
|
|
30
|
+
Please refer to the [split commit] for details.
|
|
31
|
+
|
|
32
|
+
[split commit]: https://github.com/ing-bank/psl-parser/commit/4814107ce1840d92c2ab0de99e31887014453d4c
|
|
33
|
+
[ing-bank/vscode-psl]: https://github.com/ing-bank/vscode-psl.git
|
|
34
|
+
[node.js]: https://nodejs.org/en
|
package/config.d.ts
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export declare function setConfig(configPath: string, workspaces: Map<string, string>): void;
|
|
2
|
+
export declare function removeConfig(configPath: string): void;
|
|
3
|
+
/**
|
|
4
|
+
* Absolute paths.
|
|
5
|
+
*/
|
|
6
|
+
export interface FinderPaths {
|
|
7
|
+
/**
|
|
8
|
+
* Absolute path to the active routine, if the active component is a routine.
|
|
9
|
+
*/
|
|
10
|
+
activeRoutine?: string;
|
|
11
|
+
/**
|
|
12
|
+
* Absolute path to the active table, if the active component is a table.
|
|
13
|
+
*/
|
|
14
|
+
activeTable?: string;
|
|
15
|
+
/**
|
|
16
|
+
* Absolute paths to all possible sources for PSL classes, across all projects.
|
|
17
|
+
* Ordered by priority.
|
|
18
|
+
*/
|
|
19
|
+
projectPsl: string[];
|
|
20
|
+
/**
|
|
21
|
+
* Absolute path to the location of PSL core class definitions.
|
|
22
|
+
*/
|
|
23
|
+
corePsl: string;
|
|
24
|
+
/**
|
|
25
|
+
* Absolute path to the directory that contains file definitions.
|
|
26
|
+
*/
|
|
27
|
+
tables: string[];
|
|
28
|
+
}
|
|
29
|
+
export declare function getFinderPaths(currentDir: string, activeRoutine?: string): FinderPaths;
|
package/config.js
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import * as fs from "fs-extra";
|
|
2
|
+
import * as path from "path";
|
|
3
|
+
const activeConfigs = new Map();
|
|
4
|
+
export function setConfig(configPath, workspaces) {
|
|
5
|
+
const configBaseDir = path.dirname(configPath);
|
|
6
|
+
// TODO: (Mischa Reitsma) Loading from a file and not validating that it follows the ProjectConfig interface, worth writing a config parser or use a lib to check against a json schema.
|
|
7
|
+
const config = JSON.parse(fs.readFileSync(configPath).toString());
|
|
8
|
+
config.parentProjects = config.parentProjects.map(p => workspaces.get(p)).filter(x => x);
|
|
9
|
+
activeConfigs.set(configBaseDir, config);
|
|
10
|
+
}
|
|
11
|
+
export function removeConfig(configPath) {
|
|
12
|
+
const configBaseDir = path.dirname(configPath);
|
|
13
|
+
activeConfigs.delete(configBaseDir);
|
|
14
|
+
}
|
|
15
|
+
export function getFinderPaths(currentDir, activeRoutine) {
|
|
16
|
+
const defaultPslSources = ["dataqwik/procedure/", "psl/"];
|
|
17
|
+
const defaultFileDefinitionSources = ["dataqwik/table/"];
|
|
18
|
+
const config = activeConfigs.get(currentDir);
|
|
19
|
+
const projectPsl = [];
|
|
20
|
+
const tables = [];
|
|
21
|
+
const loadPsl = (base, source) => {
|
|
22
|
+
projectPsl.push(path.join(base, source));
|
|
23
|
+
};
|
|
24
|
+
const loadFileDefinition = (base, source) => {
|
|
25
|
+
tables.push(path.join(base, source));
|
|
26
|
+
};
|
|
27
|
+
const relativePslSources = (config && config.pslSources)
|
|
28
|
+
? config.pslSources : defaultPslSources;
|
|
29
|
+
const relativeFileDefinitionSource = config && config.fileDefinitionSources
|
|
30
|
+
? config.fileDefinitionSources : defaultFileDefinitionSources;
|
|
31
|
+
const corePsl = path.join(currentDir, ".vscode/pslcls/");
|
|
32
|
+
// load core first
|
|
33
|
+
projectPsl.push(corePsl);
|
|
34
|
+
// load base sources
|
|
35
|
+
relativePslSources.forEach(source => loadPsl(currentDir, source));
|
|
36
|
+
relativeFileDefinitionSource.forEach(source => loadFileDefinition(currentDir, source));
|
|
37
|
+
// load parent sources
|
|
38
|
+
if (config && config.parentProjects) {
|
|
39
|
+
for (const parent of config.parentProjects) {
|
|
40
|
+
relativePslSources.forEach(source => loadPsl(parent, source));
|
|
41
|
+
relativeFileDefinitionSource.forEach(source => loadFileDefinition(parent, source));
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return {
|
|
45
|
+
activeRoutine,
|
|
46
|
+
corePsl,
|
|
47
|
+
projectPsl,
|
|
48
|
+
t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
1
|
+
export * from "./parser";
|
|
2
|
+
export * from "./statementParser";
|
|
3
|
+
import * as _tokenizer from "./tokenizer";
|
|
4
|
+
export { _tokenizer as tokenizer };
|
|
5
|
+
import * as _utilities from "./utilities";
|
|
6
|
+
export { _utilities as utilities };
|
|
7
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi9zcmMvaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsY0FBYyxVQUFVLENBQUM7QUFFekIsY0FBYyxtQkFBbUIsQ0FBQztBQUVsQyxPQUFPLEtBQUssVUFBVSxNQUFNLGFBQWEsQ0FBQztBQUMxQyxPQUFPLEVBQUUsVUFBVSxJQUFJLFNBQVMsRUFBRSxDQUFDO0FBRW5DLE9BQU8sS0FBSyxVQUFVLE1BQU0sYUFBYSxDQUFDO0FBQzFDLE9BQU8sRUFBRSxVQUFVLElBQUksU0FBUyxFQUFFLENBQUMifQ==
|
package/package.json
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@profile-psl/psl-parser",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Profile Scripting Language Parser",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"keywords": [
|
|
7
|
+
"PSL",
|
|
8
|
+
"parser",
|
|
9
|
+
"Profile"
|
|
10
|
+
],
|
|
11
|
+
"homepage": "https://github.com/ing-bank/psl-parser#readme",
|
|
12
|
+
"bugs": {
|
|
13
|
+
"url": "https://github.com/ing-bank/psl-parser/issues"
|
|
14
|
+
},
|
|
15
|
+
"license": "MIT",
|
|
16
|
+
"author": "atiplea",
|
|
17
|
+
"contributors": [
|
|
18
|
+
"SOliveira",
|
|
19
|
+
{
|
|
20
|
+
"name": "Mischa Reitsma",
|
|
21
|
+
"email": "dev@mreitmsa.com",
|
|
22
|
+
"url": "https://github.com/mischareitsma"
|
|
23
|
+
}
|
|
24
|
+
],
|
|
25
|
+
"main": "index.js",
|
|
26
|
+
"types": "index.d.ts",
|
|
27
|
+
"repository": {
|
|
28
|
+
"type": "git",
|
|
29
|
+
"url": "git+https://git@github.com/ing-bank/psl-parser.git"
|
|
30
|
+
},
|
|
31
|
+
"dependencies": {
|
|
32
|
+
"fs-extra": "^11.2.0",
|
|
33
|
+
"jsonc-parser": "^3.2.0"
|
|
34
|
+
}
|
|
35
|
+
}
|
package/parser.d.ts
ADDED
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
import { Statement } from "./statementParser";
|
|
2
|
+
import { Token } from "./tokenizer";
|
|
3
|
+
/**
|
|
4
|
+
* Used for checking the type of Member at runtime
|
|
5
|
+
*/
|
|
6
|
+
export declare enum MemberClass {
|
|
7
|
+
method = 1,
|
|
8
|
+
parameter = 2,
|
|
9
|
+
property = 3,
|
|
10
|
+
declaration = 4,
|
|
11
|
+
column = 5,
|
|
12
|
+
table = 6,
|
|
13
|
+
proc = 7
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* A generic type that abstracts Method, Parameter, Declaration, etc
|
|
17
|
+
*/
|
|
18
|
+
export interface Member {
|
|
19
|
+
/**
|
|
20
|
+
* The Token representing the name of the member.
|
|
21
|
+
*/
|
|
22
|
+
id: Token;
|
|
23
|
+
/**
|
|
24
|
+
* An array of types. The 0 index represents the 0 node type.
|
|
25
|
+
* For trees the type of the nth node will be found at index n.
|
|
26
|
+
*/
|
|
27
|
+
types: Token[];
|
|
28
|
+
modifiers: Token[];
|
|
29
|
+
/**
|
|
30
|
+
* The member class to determine the type at runtime
|
|
31
|
+
*/
|
|
32
|
+
memberClass: MemberClass;
|
|
33
|
+
documentation?: string;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Contains information about a Method
|
|
37
|
+
*/
|
|
38
|
+
export interface Method extends Member {
|
|
39
|
+
/**
|
|
40
|
+
* The Token of the closing parenthesis after the declaration of all the Method's
|
|
41
|
+
* parameters.
|
|
42
|
+
*/
|
|
43
|
+
closeParen: Token;
|
|
44
|
+
/**
|
|
45
|
+
* Currently unused for Methods.
|
|
46
|
+
*/
|
|
47
|
+
types: Token[];
|
|
48
|
+
/**
|
|
49
|
+
* All the modifiers before the Method id, like "public", "static", "void", "String", etc.
|
|
50
|
+
*/
|
|
51
|
+
modifiers: Token[];
|
|
52
|
+
/**
|
|
53
|
+
* The parameters of the Method, each with their own typing and comment information.
|
|
54
|
+
*/
|
|
55
|
+
parameters: Parameter[];
|
|
56
|
+
/**
|
|
57
|
+
* The "type" declarations found within the body of the method.
|
|
58
|
+
* Only the location where they are declared is referenced.
|
|
59
|
+
*/
|
|
60
|
+
declarations: Declaration[];
|
|
61
|
+
/**
|
|
62
|
+
* The zero-based line where the Method begins
|
|
63
|
+
*/
|
|
64
|
+
line: number;
|
|
65
|
+
/**
|
|
66
|
+
* The last line of the Method, right before the start of a new Method
|
|
67
|
+
*/
|
|
68
|
+
endLine: number;
|
|
69
|
+
/**
|
|
70
|
+
* Whether the Method (label) is a batch label, such as "OPEN" or "EXEC"
|
|
71
|
+
*/
|
|
72
|
+
batch: boolean;
|
|
73
|
+
statements: Statement[];
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* A PROPERTYDEF declaration
|
|
77
|
+
*/
|
|
78
|
+
export interface Property extends Member {
|
|
79
|
+
/**
|
|
80
|
+
* The other Tokens in the declaration, currently unparsed.
|
|
81
|
+
*/
|
|
82
|
+
modifiers: Token[];
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Represents a parameter, always belonging to a Method
|
|
86
|
+
*/
|
|
87
|
+
export interface Parameter extends Member {
|
|
88
|
+
/**
|
|
89
|
+
* If the req keyword is used
|
|
90
|
+
*/
|
|
91
|
+
req: boolean;
|
|
92
|
+
/**
|
|
93
|
+
* If the ret keyword is used
|
|
94
|
+
*/
|
|
95
|
+
ret: boolean;
|
|
96
|
+
/**
|
|
97
|
+
* If the literal keyword is used.
|
|
98
|
+
*/
|
|
99
|
+
literal: boolean;
|
|
100
|
+
/**
|
|
101
|
+
* The contents of the comment for the parameter, i.e.
|
|
102
|
+
* ```
|
|
103
|
+
* public String name(
|
|
104
|
+
* String p1 // a comment
|
|
105
|
+
* )
|
|
106
|
+
* ```
|
|
107
|
+
*/
|
|
108
|
+
comment: Token;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* A type declaration, typically found within a method.
|
|
112
|
+
*/
|
|
113
|
+
export interface Declaration extends Member {
|
|
114
|
+
/**
|
|
115
|
+
* The other Tokens in the declaration, currently unparsed.
|
|
116
|
+
*/
|
|
117
|
+
modifiers: Token[];
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* An abstract syntax tree of a PSL document
|
|
121
|
+
*/
|
|
122
|
+
export interface ParsedDocument {
|
|
123
|
+
/**
|
|
124
|
+
* An array of Declarations that are not contained within a method.
|
|
125
|
+
* This will be empty for valid Profile 7.6 code but is maintained for compatibility.
|
|
126
|
+
*/
|
|
127
|
+
declarations: Declaration[];
|
|
128
|
+
/**
|
|
129
|
+
* An array of PROPERTYDEF
|
|
130
|
+
*/
|
|
131
|
+
properties: Property[];
|
|
132
|
+
/**
|
|
133
|
+
* An array of the methods in the document
|
|
134
|
+
*/
|
|
135
|
+
methods: Method[];
|
|
136
|
+
/**
|
|
137
|
+
* All the tokens in the document, for reference.
|
|
138
|
+
*/
|
|
139
|
+
tokens: Token[];
|
|
140
|
+
/**
|
|
141
|
+
* The Token that represents the parent class.
|
|
142
|
+
*/
|
|
143
|
+
extending: Token;
|
|
144
|
+
/**
|
|
145
|
+
* The Token that represents the PSL package.
|
|
146
|
+
*/
|
|
147
|
+
pslPackage: string;
|
|
148
|
+
/**
|
|
149
|
+
* The tokens corresponding to line and block comments.
|
|
150
|
+
*/
|
|
151
|
+
comments: Token[];
|
|
152
|
+
}
|
|
153
|
+
export declare const NON_TYPE_MODIFIERS: string[];
|
|
154
|
+
export declare function parseText(sourceText: string): ParsedDocument;
|
|
155
|
+
export declare function parseFile(sourcePath: string): Promise<ParsedDocument>;
|