acspec-parser 0.4.3
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/dist/cjs/main.cjs +175 -0
- package/dist/cjs/main.cjs.map +7 -0
- package/dist/esm/main.mjs +172 -0
- package/dist/esm/main.mjs.map +7 -0
- package/dist/language/acspec-module.d.ts +14 -0
- package/dist/language/acspec-validator.d.ts +23 -0
- package/dist/language/generated/ast.d.ts +168 -0
- package/dist/language/generated/grammar.d.ts +6 -0
- package/dist/language/generated/module.d.ts +13 -0
- package/dist/language/main.d.ts +4 -0
- package/package.json +42 -0
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type Module } from 'langium';
|
|
2
|
+
import { type DefaultSharedModuleContext, type LangiumServices, type LangiumSharedServices, type PartialLangiumServices } from 'langium/lsp';
|
|
3
|
+
import { AcspecValidator } from './acspec-validator.js';
|
|
4
|
+
export type AcspecAddedServices = {
|
|
5
|
+
validation: {
|
|
6
|
+
AcspecValidator: AcspecValidator;
|
|
7
|
+
};
|
|
8
|
+
};
|
|
9
|
+
export type AcspecServices = LangiumServices & AcspecAddedServices;
|
|
10
|
+
export declare const AcspecModule: Module<AcspecServices, PartialLangiumServices & AcspecAddedServices>;
|
|
11
|
+
export declare function createAcspecServices(context: DefaultSharedModuleContext): {
|
|
12
|
+
shared: LangiumSharedServices;
|
|
13
|
+
Acspec: AcspecServices;
|
|
14
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { ValidationAcceptor } from 'langium';
|
|
2
|
+
import type { WriteCommand, CheckCommand, CheckAlarmCommand, CheckActionCommand, WatchCommand, UnwatchCommand, DelayCommand, ScheduleCommand, LoopCommand, CountCommand } from './generated/ast.js';
|
|
3
|
+
import type { AcspecServices } from './acspec-module.js';
|
|
4
|
+
/**
|
|
5
|
+
* Register custom validation checks.
|
|
6
|
+
*/
|
|
7
|
+
export declare function registerValidationChecks(services: AcspecServices): void;
|
|
8
|
+
/**
|
|
9
|
+
* Implementation of custom validations.
|
|
10
|
+
*/
|
|
11
|
+
export declare class AcspecValidator {
|
|
12
|
+
private validateAddress;
|
|
13
|
+
checkWriteCommand(write: WriteCommand, accept: ValidationAcceptor): void;
|
|
14
|
+
checkCheckCommand(check: CheckCommand, accept: ValidationAcceptor): void;
|
|
15
|
+
checkAlarmCommand(check_alarm: CheckAlarmCommand, accept: ValidationAcceptor): void;
|
|
16
|
+
checkActionCommand(check_action: CheckActionCommand, accept: ValidationAcceptor): void;
|
|
17
|
+
checkWatchCommand(watch: WatchCommand, accept: ValidationAcceptor): void;
|
|
18
|
+
checkUnwatchCommand(unwatch: UnwatchCommand, accept: ValidationAcceptor): void;
|
|
19
|
+
checkDelayCommand(delay: DelayCommand, accept: ValidationAcceptor): void;
|
|
20
|
+
checkScheduleCommand(schedule: ScheduleCommand, accept: ValidationAcceptor): void;
|
|
21
|
+
checkLoopCommand(loop: LoopCommand, accept: ValidationAcceptor): void;
|
|
22
|
+
checkCountCommand(count: CountCommand, accept: ValidationAcceptor): void;
|
|
23
|
+
}
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
/******************************************************************************
|
|
2
|
+
* This file was generated by langium-cli 3.5.2.
|
|
3
|
+
* DO NOT EDIT MANUALLY!
|
|
4
|
+
******************************************************************************/
|
|
5
|
+
import * as langium from 'langium';
|
|
6
|
+
export declare const AcspecTerminals: {
|
|
7
|
+
WS: RegExp;
|
|
8
|
+
ID: RegExp;
|
|
9
|
+
NUMBER: RegExp;
|
|
10
|
+
ML_COMMENT: RegExp;
|
|
11
|
+
SL_COMMENT: RegExp;
|
|
12
|
+
};
|
|
13
|
+
export type AcspecTerminalNames = keyof typeof AcspecTerminals;
|
|
14
|
+
export type AcspecKeywordNames = "," | "check" | "check!" | "check_action" | "check_action!" | "check_alarm" | "check_alarm!" | "count" | "delay" | "init" | "loop" | "schedule" | "unit" | "unwatch" | "unwatch!" | "use" | "watch" | "watch!" | "write" | "write!" | "{" | "}";
|
|
15
|
+
export type AcspecTokenNames = AcspecTerminalNames | AcspecKeywordNames;
|
|
16
|
+
export type BlockCommand = CountCommand | LoopCommand | ScheduleCommand;
|
|
17
|
+
export declare const BlockCommand = "BlockCommand";
|
|
18
|
+
export declare function isBlockCommand(item: unknown): item is BlockCommand;
|
|
19
|
+
export type LineCommand = CheckActionCommand | CheckAlarmCommand | CheckCommand | DelayCommand | UnwatchCommand | WatchCommand | WriteCommand;
|
|
20
|
+
export declare const LineCommand = "LineCommand";
|
|
21
|
+
export declare function isLineCommand(item: unknown): item is LineCommand;
|
|
22
|
+
export interface AddressParam extends langium.AstNode {
|
|
23
|
+
readonly $container: CheckCommand | UnwatchCommand | WatchCommand | WriteCommand;
|
|
24
|
+
readonly $type: 'AddressParam';
|
|
25
|
+
value: string;
|
|
26
|
+
}
|
|
27
|
+
export declare const AddressParam = "AddressParam";
|
|
28
|
+
export declare function isAddressParam(item: unknown): item is AddressParam;
|
|
29
|
+
export interface CheckActionCommand extends langium.AstNode {
|
|
30
|
+
readonly $container: CountCommand | LoopCommand | Model | ScheduleCommand;
|
|
31
|
+
readonly $type: 'CheckActionCommand';
|
|
32
|
+
code: CodeParam;
|
|
33
|
+
}
|
|
34
|
+
export declare const CheckActionCommand = "CheckActionCommand";
|
|
35
|
+
export declare function isCheckActionCommand(item: unknown): item is CheckActionCommand;
|
|
36
|
+
export interface CheckAlarmCommand extends langium.AstNode {
|
|
37
|
+
readonly $container: CountCommand | LoopCommand | Model | ScheduleCommand;
|
|
38
|
+
readonly $type: 'CheckAlarmCommand';
|
|
39
|
+
codes: Array<CodeParam>;
|
|
40
|
+
}
|
|
41
|
+
export declare const CheckAlarmCommand = "CheckAlarmCommand";
|
|
42
|
+
export declare function isCheckAlarmCommand(item: unknown): item is CheckAlarmCommand;
|
|
43
|
+
export interface CheckCommand extends langium.AstNode {
|
|
44
|
+
readonly $container: CountCommand | LoopCommand | Model | ScheduleCommand;
|
|
45
|
+
readonly $type: 'CheckCommand';
|
|
46
|
+
address: AddressParam;
|
|
47
|
+
address2?: AddressParam;
|
|
48
|
+
value?: ValueParam;
|
|
49
|
+
value2?: ValueParam;
|
|
50
|
+
}
|
|
51
|
+
export declare const CheckCommand = "CheckCommand";
|
|
52
|
+
export declare function isCheckCommand(item: unknown): item is CheckCommand;
|
|
53
|
+
export interface CodeParam extends langium.AstNode {
|
|
54
|
+
readonly $container: CheckActionCommand | CheckAlarmCommand;
|
|
55
|
+
readonly $type: 'CodeParam';
|
|
56
|
+
value: number;
|
|
57
|
+
}
|
|
58
|
+
export declare const CodeParam = "CodeParam";
|
|
59
|
+
export declare function isCodeParam(item: unknown): item is CodeParam;
|
|
60
|
+
export interface CountCommand extends langium.AstNode {
|
|
61
|
+
readonly $container: Model;
|
|
62
|
+
readonly $type: 'CountCommand';
|
|
63
|
+
commands: Array<LineCommand>;
|
|
64
|
+
times: ValueParam;
|
|
65
|
+
}
|
|
66
|
+
export declare const CountCommand = "CountCommand";
|
|
67
|
+
export declare function isCountCommand(item: unknown): item is CountCommand;
|
|
68
|
+
export interface DelayCommand extends langium.AstNode {
|
|
69
|
+
readonly $container: CountCommand | LoopCommand | Model | ScheduleCommand;
|
|
70
|
+
readonly $type: 'DelayCommand';
|
|
71
|
+
time: TimeParam;
|
|
72
|
+
}
|
|
73
|
+
export declare const DelayCommand = "DelayCommand";
|
|
74
|
+
export declare function isDelayCommand(item: unknown): item is DelayCommand;
|
|
75
|
+
export interface LoopCommand extends langium.AstNode {
|
|
76
|
+
readonly $container: Model;
|
|
77
|
+
readonly $type: 'LoopCommand';
|
|
78
|
+
commands: Array<LineCommand>;
|
|
79
|
+
time: TimeParam;
|
|
80
|
+
}
|
|
81
|
+
export declare const LoopCommand = "LoopCommand";
|
|
82
|
+
export declare function isLoopCommand(item: unknown): item is LoopCommand;
|
|
83
|
+
export interface Model extends langium.AstNode {
|
|
84
|
+
readonly $type: 'Model' | 'TypeDeclare';
|
|
85
|
+
commands: Array<BlockCommand | LineCommand>;
|
|
86
|
+
}
|
|
87
|
+
export declare const Model = "Model";
|
|
88
|
+
export declare function isModel(item: unknown): item is Model;
|
|
89
|
+
export interface ScheduleCommand extends langium.AstNode {
|
|
90
|
+
readonly $container: Model;
|
|
91
|
+
readonly $type: 'ScheduleCommand';
|
|
92
|
+
commands: Array<LineCommand>;
|
|
93
|
+
time: TimeParam;
|
|
94
|
+
}
|
|
95
|
+
export declare const ScheduleCommand = "ScheduleCommand";
|
|
96
|
+
export declare function isScheduleCommand(item: unknown): item is ScheduleCommand;
|
|
97
|
+
export interface TimeParam extends langium.AstNode {
|
|
98
|
+
readonly $container: DelayCommand | LoopCommand | ScheduleCommand;
|
|
99
|
+
readonly $type: 'TimeParam';
|
|
100
|
+
value: number;
|
|
101
|
+
}
|
|
102
|
+
export declare const TimeParam = "TimeParam";
|
|
103
|
+
export declare function isTimeParam(item: unknown): item is TimeParam;
|
|
104
|
+
export interface UnwatchCommand extends langium.AstNode {
|
|
105
|
+
readonly $container: CountCommand | LoopCommand | Model | ScheduleCommand;
|
|
106
|
+
readonly $type: 'UnwatchCommand';
|
|
107
|
+
address: AddressParam;
|
|
108
|
+
}
|
|
109
|
+
export declare const UnwatchCommand = "UnwatchCommand";
|
|
110
|
+
export declare function isUnwatchCommand(item: unknown): item is UnwatchCommand;
|
|
111
|
+
export interface ValueParam extends langium.AstNode {
|
|
112
|
+
readonly $container: CheckCommand | CountCommand | WatchCommand | WriteCommand;
|
|
113
|
+
readonly $type: 'ValueParam';
|
|
114
|
+
value: number;
|
|
115
|
+
}
|
|
116
|
+
export declare const ValueParam = "ValueParam";
|
|
117
|
+
export declare function isValueParam(item: unknown): item is ValueParam;
|
|
118
|
+
export interface WatchCommand extends langium.AstNode {
|
|
119
|
+
readonly $container: CountCommand | LoopCommand | Model | ScheduleCommand;
|
|
120
|
+
readonly $type: 'WatchCommand';
|
|
121
|
+
address: AddressParam;
|
|
122
|
+
value: ValueParam;
|
|
123
|
+
value2?: ValueParam;
|
|
124
|
+
}
|
|
125
|
+
export declare const WatchCommand = "WatchCommand";
|
|
126
|
+
export declare function isWatchCommand(item: unknown): item is WatchCommand;
|
|
127
|
+
export interface WriteCommand extends langium.AstNode {
|
|
128
|
+
readonly $container: CountCommand | LoopCommand | Model | ScheduleCommand;
|
|
129
|
+
readonly $type: 'WriteCommand';
|
|
130
|
+
address: AddressParam;
|
|
131
|
+
address2?: AddressParam;
|
|
132
|
+
value?: ValueParam;
|
|
133
|
+
}
|
|
134
|
+
export declare const WriteCommand = "WriteCommand";
|
|
135
|
+
export declare function isWriteCommand(item: unknown): item is WriteCommand;
|
|
136
|
+
export interface TypeDeclare extends Model {
|
|
137
|
+
readonly $type: 'TypeDeclare';
|
|
138
|
+
value: 'init' | 'unit';
|
|
139
|
+
}
|
|
140
|
+
export declare const TypeDeclare = "TypeDeclare";
|
|
141
|
+
export declare function isTypeDeclare(item: unknown): item is TypeDeclare;
|
|
142
|
+
export type AcspecAstType = {
|
|
143
|
+
AddressParam: AddressParam;
|
|
144
|
+
BlockCommand: BlockCommand;
|
|
145
|
+
CheckActionCommand: CheckActionCommand;
|
|
146
|
+
CheckAlarmCommand: CheckAlarmCommand;
|
|
147
|
+
CheckCommand: CheckCommand;
|
|
148
|
+
CodeParam: CodeParam;
|
|
149
|
+
CountCommand: CountCommand;
|
|
150
|
+
DelayCommand: DelayCommand;
|
|
151
|
+
LineCommand: LineCommand;
|
|
152
|
+
LoopCommand: LoopCommand;
|
|
153
|
+
Model: Model;
|
|
154
|
+
ScheduleCommand: ScheduleCommand;
|
|
155
|
+
TimeParam: TimeParam;
|
|
156
|
+
TypeDeclare: TypeDeclare;
|
|
157
|
+
UnwatchCommand: UnwatchCommand;
|
|
158
|
+
ValueParam: ValueParam;
|
|
159
|
+
WatchCommand: WatchCommand;
|
|
160
|
+
WriteCommand: WriteCommand;
|
|
161
|
+
};
|
|
162
|
+
export declare class AcspecAstReflection extends langium.AbstractAstReflection {
|
|
163
|
+
getAllTypes(): string[];
|
|
164
|
+
protected computeIsSubtype(subtype: string, supertype: string): boolean;
|
|
165
|
+
getReferenceType(refInfo: langium.ReferenceInfo): string;
|
|
166
|
+
getTypeMetaData(type: string): langium.TypeMetaData;
|
|
167
|
+
}
|
|
168
|
+
export declare const reflection: AcspecAstReflection;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/******************************************************************************
|
|
2
|
+
* This file was generated by langium-cli 3.5.2.
|
|
3
|
+
* DO NOT EDIT MANUALLY!
|
|
4
|
+
******************************************************************************/
|
|
5
|
+
import type { Grammar } from 'langium';
|
|
6
|
+
export declare const AcspecGrammar: () => Grammar;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/******************************************************************************
|
|
2
|
+
* This file was generated by langium-cli 3.5.2.
|
|
3
|
+
* DO NOT EDIT MANUALLY!
|
|
4
|
+
******************************************************************************/
|
|
5
|
+
import type { LangiumSharedCoreServices, LangiumCoreServices, LangiumGeneratedCoreServices, LangiumGeneratedSharedCoreServices, Module } from 'langium';
|
|
6
|
+
export declare const AcspecLanguageMetaData: {
|
|
7
|
+
readonly languageId: "acspec";
|
|
8
|
+
readonly fileExtensions: readonly [".tsc"];
|
|
9
|
+
readonly caseInsensitive: false;
|
|
10
|
+
readonly mode: "production";
|
|
11
|
+
};
|
|
12
|
+
export declare const AcspecGeneratedSharedModule: Module<LangiumSharedCoreServices, LangiumGeneratedSharedCoreServices>;
|
|
13
|
+
export declare const AcspecGeneratedModule: Module<LangiumCoreServices, LangiumGeneratedCoreServices>;
|
package/package.json
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "acspec-parser",
|
|
3
|
+
"version": "0.4.3",
|
|
4
|
+
"keywords": [
|
|
5
|
+
"AcSpec",
|
|
6
|
+
"acspec"
|
|
7
|
+
],
|
|
8
|
+
"author": "Arcuchi",
|
|
9
|
+
"description": "AcSpec Parser",
|
|
10
|
+
"type": "module",
|
|
11
|
+
"main": "./dist/cjs/main.cjs",
|
|
12
|
+
"module": "./dist/esm/main.mjs",
|
|
13
|
+
"types": "./dist/language/main.d.ts",
|
|
14
|
+
"exports": {
|
|
15
|
+
".": {
|
|
16
|
+
"types": "./dist/language/main.d.ts",
|
|
17
|
+
"import": "./dist/esm/main.mjs",
|
|
18
|
+
"require": "./dist/cjs/main.cjs"
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
"files": [
|
|
22
|
+
"dist"
|
|
23
|
+
],
|
|
24
|
+
"dependencies": {
|
|
25
|
+
"langium": "^3.5.0"
|
|
26
|
+
},
|
|
27
|
+
"devDependencies": {
|
|
28
|
+
"@types/node": "^24.1.0",
|
|
29
|
+
"cross-env": "^10.0.0",
|
|
30
|
+
"esbuild": "^0.25.8",
|
|
31
|
+
"langium-cli": "^3.5.2",
|
|
32
|
+
"typescript": "^5.8.3"
|
|
33
|
+
},
|
|
34
|
+
"scripts": {
|
|
35
|
+
"build": "tsc && cross-env NODE_ENV=development node esbuild.js",
|
|
36
|
+
"build:prod": "tsc && cross-env NODE_ENV=production node esbuild.js",
|
|
37
|
+
"langium:generate": "langium generate",
|
|
38
|
+
"langium:generate:production": "langium generate --mode=production",
|
|
39
|
+
"type-check": "tsc --noEmit --skipLibCheck"
|
|
40
|
+
},
|
|
41
|
+
"license": "ISC"
|
|
42
|
+
}
|