1- import { TData } from './data' ;
1+ import { TData , TDataName } from './data' ;
22import {
33 IElementData ,
44 IElementExpression ,
@@ -14,54 +14,17 @@ export type TElementKind = 'Argument' | 'Instruction';
1414/** Type (`Data`, `Expression`, `Statement`, `Block`) of the syntax element. */
1515export type TElementType = 'Data' | 'Expression' | 'Statement' | 'Block' ;
1616
17- /** Names of factory list of data elements. */
18- export type TElementNameData =
19- // value elements
20- | 'value-boolean'
21- | 'value-number'
22- | 'value-string'
23- // box identifier elements
24- | 'boxidentifier-generic'
25- | 'boxidentifier-boolean'
26- | 'boxidentifier-number'
27- | 'boxidentifier-string' ;
28-
29- /** Names of factory list of expression elements. */
30- export type TElementNameExpression =
31- // math operator elements
32- | 'operator-math-plus'
33- | 'operator-math-minus'
34- | 'operator-math-times'
35- | 'operator-math-divide'
36- | 'operator-math-modulus' ;
37-
38- /** Names of factory list of statement elements. */
39- export type TElementNameStatement =
40- // box elements
41- | 'box-generic'
42- | 'box-boolean'
43- | 'box-number'
44- | 'box-string'
45- // print element
46- | 'print' ;
47-
48- /** Names of factory list of block elements. */
49- export type TElementNameBlock = 'process' | 'routine' | 'repeat' | 'if' ;
50-
51- /** Names of factory list of syntax elements. */
52- export type TElementName =
53- | 'dummy'
54- | TElementNameData
55- | TElementNameExpression
56- | TElementNameStatement
57- | TElementNameBlock ;
58-
5917/** Type for the specification object for data elements. */
6018export interface IElementSpecificationData {
6119 label : string ;
6220 type : 'Data' ;
6321 category : string ;
64- prototype : ( name : TElementNameData , label : string ) => IElementData < TData > ;
22+ prototype : ( name : string , label : string ) => IElementData < TData > ;
23+ values ?:
24+ | string [ ]
25+ | {
26+ types : TDataName [ ] ;
27+ } ;
6528}
6629
6730/** Type for the specification entry object for data elements. */
@@ -77,7 +40,7 @@ export interface IElementSpecificationExpression {
7740 label : string ;
7841 type : 'Expression' ;
7942 category : string ;
80- prototype : ( name : TElementNameExpression , label : string ) => IElementExpression < TData > ;
43+ prototype : ( name : string , label : string ) => IElementExpression < TData > ;
8144}
8245
8346/** Type for the specification object for expression elements. */
@@ -90,21 +53,21 @@ export interface IElementSpecificationEntryExpression extends IElementSpecificat
9053
9154/** Type for the specification object for instruction elements. */
9255interface IElementSpecificationInstruction {
93- allowAbove ?: TElementName [ ] | boolean ;
94- allowBelow ?: TElementName [ ] | boolean ;
95- forbidAbove ?: TElementName [ ] ;
96- forbidBelow ?: TElementName [ ] ;
56+ allowAbove ?: string [ ] | boolean ;
57+ allowBelow ?: string [ ] | boolean ;
58+ forbidAbove ?: string [ ] ;
59+ forbidBelow ?: string [ ] ;
9760 allowedNestLevel ?: number [ ] | 'any' ;
98- allowedNestInside ?: TElementNameBlock [ ] | boolean ;
99- forbiddenNestInside ?: TElementNameBlock [ ] ;
61+ allowedNestInside ?: string [ ] | boolean ;
62+ forbiddenNestInside ?: string [ ] ;
10063}
10164
10265/** Type for the specification object for statement elements. */
10366export type IElementSpecificationStatement = IElementSpecificationInstruction & {
10467 label : string ;
10568 type : 'Statement' ;
10669 category : string ;
107- prototype : ( name : TElementNameStatement , label : string ) => IElementStatement ;
70+ prototype : ( name : string , label : string ) => IElementStatement ;
10871} ;
10972
11073/** Type for the specification object for statement elements. */
@@ -120,9 +83,9 @@ export type IElementSpecificationBlock = IElementSpecificationInstruction & {
12083 label : string ;
12184 type : 'Block' ;
12285 category : string ;
123- prototype : ( name : TElementNameBlock , label : string ) => IElementBlock ;
124- allowNestInside ?: ( TElementNameStatement | TElementNameBlock ) [ ] | boolean ;
125- forbidNestInside ?: ( TElementNameStatement | TElementNameBlock ) [ ] ;
86+ prototype : ( name : string , label : string ) => IElementBlock ;
87+ allowNestInside ?: string [ ] | boolean ;
88+ forbidNestInside ?: string [ ] ;
12689} ;
12790
12891/** Type for the specification entry object for block elements. */
@@ -131,22 +94,33 @@ export type IElementSpecificationEntryBlock = IElementSpecificationInstruction &
13194 type : 'Block' ;
13295 category : string ;
13396 prototype : typeof IElementBlock ;
134- allowNestInside ?: ( TElementNameStatement | TElementNameBlock ) [ ] | boolean ;
135- forbidNestInside ?: ( TElementNameStatement | TElementNameBlock ) [ ] ;
97+ allowNestInside ?: string [ ] | boolean ;
98+ forbidNestInside ?: string [ ] ;
13699} ;
137100
101+ /** Type for the specification object for an element. */
138102export interface IElementSpecification {
139103 label : string ;
140104 type : TElementType ;
141105 category : string ;
142- prototype : new ( name : TElementName , label : string ) => IElementSyntax ;
143- allowAbove ?: TElementName [ ] | boolean ;
144- allowBelow ?: TElementName [ ] | boolean ;
145- forbidAbove ?: TElementName [ ] ;
146- forbidBelow ?: TElementName [ ] ;
106+ prototype : new ( name : string , label : string ) => IElementSyntax ;
107+ allowAbove ?: string [ ] | boolean ;
108+ allowBelow ?: string [ ] | boolean ;
109+ forbidAbove ?: string [ ] ;
110+ forbidBelow ?: string [ ] ;
147111 allowedNestLevel ?: number [ ] | 'any' ;
148- allowedNestInside ?: TElementNameBlock [ ] | boolean ;
149- forbiddenNestInside ?: TElementNameBlock [ ] ;
150- allowNestInside ?: ( TElementNameStatement | TElementNameBlock ) [ ] | boolean ;
151- forbidNestInside ?: ( TElementNameStatement | TElementNameBlock ) [ ] | boolean ;
112+ allowedNestInside ?: string [ ] | boolean ;
113+ forbiddenNestInside ?: string [ ] ;
114+ allowNestInside ?: string [ ] | boolean ;
115+ forbidNestInside ?: string [ ] | boolean ;
116+ values ?:
117+ | string [ ]
118+ | {
119+ types : TDataName [ ] ;
120+ } ;
121+ }
122+
123+ /** Type for the snapshot of an element's specification. */
124+ export interface IElementSpecificationSnapshot extends Omit < IElementSpecification , 'prototype' > {
125+ prototypeName : string ;
152126}
0 commit comments