Skip to content

Commit ff40e80

Browse files
committed
add the dictionary from vscode-extension
1 parent 07bd60b commit ff40e80

File tree

4 files changed

+106
-0
lines changed

4 files changed

+106
-0
lines changed

src/dictionary/dictionary.ts

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import { Functionary, Rule } from './index';
2+
3+
const rules: Rule[] = [
4+
{
5+
name: 'imports-keyword',
6+
type: 'keyword',
7+
default: 'import'
8+
},
9+
{
10+
name: 'function-value-return-enabled',
11+
type: 'boolean',
12+
default: false
13+
},
14+
{
15+
name: 'function-value-return-keyword',
16+
type: 'keyword',
17+
default: 'return'
18+
}
19+
];
20+
21+
const func: Functionary[] = [
22+
{
23+
name: 'compile',
24+
value: 'regex'
25+
},
26+
{
27+
name: 'imports',
28+
value: 'string'
29+
}
30+
];
31+
32+
export namespace dictionary {
33+
34+
export const Rules: Rule[] = rules;
35+
export const PrimitiveTypes: string[] = ['int', 'decimal', 'boolean', 'string'];
36+
export const Keywords: string[] = ['export', 'rule', 'keyword', 'import', 'operator', 'function', 'global'];
37+
export const Functionaries: Functionary[] = func;
38+
39+
}

src/dictionary/functionaries.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/**
2+
* A functionary that can be used inside other statements as a statement.
3+
* @author efekos
4+
* @version 1.0.0
5+
* @since 0.0.1-alpha
6+
*/
7+
export interface Functionary {
8+
name: string;
9+
value:FunctionaryValueType;
10+
}
11+
12+
/**
13+
* All types of the values you can pass in to a functionary
14+
* @author efekos
15+
* @version 1.0.0
16+
* @since 0.0.1-alpha
17+
*/
18+
export type FunctionaryValueType = 'regex' | 'string' | 'void';

src/dictionary/index.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import { BaseRule, BooleanRule, Rule, RuleType, StringRule } from './rules';
2+
import { Functionary, FunctionaryValueType } from './functionaries';
3+
import { dictionary } from './dictionary';
4+
5+
export { dictionary };
6+
export { BaseRule, RuleType, Functionary, FunctionaryValueType, BooleanRule, Rule, StringRule };

src/dictionary/rules.ts

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/**
2+
* Value type of a rule.
3+
*/
4+
export type RuleType = 'keyword'|'boolean';
5+
6+
/**
7+
* Base interface for rules. Represents a rule that can be modified by any file using `rule` modifier.
8+
* @author efekos
9+
* @version 1.0.0
10+
* @since 0.0.1-alpha
11+
*/
12+
export interface BaseRule {
13+
name: string;
14+
type: RuleType;
15+
}
16+
17+
/**
18+
* A rule that has a boolean type.
19+
* @author efekos
20+
* @version 1.0.0
21+
* @since 0.0.1-alpha
22+
*/
23+
export interface BooleanRule extends BaseRule {
24+
type: 'boolean';
25+
default: boolean;
26+
}
27+
28+
29+
/**
30+
* A rule that has a string type.
31+
* @author efekos
32+
* @version 1.0.0
33+
* @since 0.0.1-alpha
34+
*/
35+
export interface StringRule extends BaseRule {
36+
type: 'keyword';
37+
default: string;
38+
}
39+
40+
/**
41+
* A rule that can be modified using `rule` statements.
42+
*/
43+
export type Rule = BooleanRule | StringRule;

0 commit comments

Comments
 (0)