funcity 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/LICENSE +21 -0
- package/README.md +109 -0
- package/dist/index.cjs +2005 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.mjs +2005 -0
- package/dist/index.mjs.map +1 -0
- package/dist/parser.d.ts +220 -0
- package/dist/parser.d.ts.map +1 -0
- package/dist/reducer.d.ts +125 -0
- package/dist/reducer.d.ts.map +1 -0
- package/dist/scripting.d.ts +36 -0
- package/dist/scripting.d.ts.map +1 -0
- package/dist/standards.d.ts +53 -0
- package/dist/standards.d.ts.map +1 -0
- package/dist/tokenizer.d.ts +96 -0
- package/dist/tokenizer.d.ts.map +1 -0
- package/package.json +64 -0
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* name: funcity
|
|
3
|
+
* version: 0.1.0
|
|
4
|
+
* description: A functional language interpreter with text processing
|
|
5
|
+
* author: Kouji Matsui (@kekyo@mi.kekyo.net)
|
|
6
|
+
* license: MIT
|
|
7
|
+
* repository.url: https://github.com/kekyo/funcity.git
|
|
8
|
+
* git.commit.hash: 5652ca56084e46cd208085f10c65ec7ad06b848a
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import { MtrScriptErrorInfo, MtrScriptVariables } from './scripting';
|
|
12
|
+
import { MtrScriptExpressionNode, MtrScriptBlockNode } from './parser';
|
|
13
|
+
/**
|
|
14
|
+
* Variable value result.
|
|
15
|
+
*/
|
|
16
|
+
export interface ValueResult {
|
|
17
|
+
/**
|
|
18
|
+
* Variable value.
|
|
19
|
+
*/
|
|
20
|
+
readonly value: unknown;
|
|
21
|
+
/**
|
|
22
|
+
* Is this found?
|
|
23
|
+
*/
|
|
24
|
+
readonly isFound: boolean;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Native function context.
|
|
28
|
+
*/
|
|
29
|
+
export interface MtrScriptFunctionContext {
|
|
30
|
+
/**
|
|
31
|
+
* Current scope variables.
|
|
32
|
+
*/
|
|
33
|
+
readonly variables: any;
|
|
34
|
+
/**
|
|
35
|
+
* Current function application node.
|
|
36
|
+
*/
|
|
37
|
+
readonly thisNode: MtrScriptExpressionNode;
|
|
38
|
+
/**
|
|
39
|
+
* Reduce expression node with this context.
|
|
40
|
+
* @param node - Target node
|
|
41
|
+
* @returns Reduced value.
|
|
42
|
+
*/
|
|
43
|
+
readonly reduce: (node: MtrScriptExpressionNode) => Promise<unknown>;
|
|
44
|
+
/**
|
|
45
|
+
* Append directly error information.
|
|
46
|
+
* @param error - Error or warning information.
|
|
47
|
+
*/
|
|
48
|
+
readonly appendError: (error: MtrScriptErrorInfo) => void;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* The reducer context.
|
|
52
|
+
*/
|
|
53
|
+
export interface MtrScriptReducerContext {
|
|
54
|
+
/**
|
|
55
|
+
* Get current context (scope) variable value.
|
|
56
|
+
* @param name - Variable name
|
|
57
|
+
* @returns Variable value information
|
|
58
|
+
*/
|
|
59
|
+
readonly getValue: (name: string) => ValueResult;
|
|
60
|
+
/**
|
|
61
|
+
* Set current context (scope) variable value.
|
|
62
|
+
* @param name - Variable name
|
|
63
|
+
* @param value - New value
|
|
64
|
+
*/
|
|
65
|
+
readonly setValue: (name: string, value: unknown) => void;
|
|
66
|
+
/**
|
|
67
|
+
* Append context error.
|
|
68
|
+
* @param error - Error or warning information.
|
|
69
|
+
*/
|
|
70
|
+
readonly appendError: (error: MtrScriptErrorInfo) => void;
|
|
71
|
+
/**
|
|
72
|
+
* Indicate error received.
|
|
73
|
+
* @returns The context is received any errors.
|
|
74
|
+
*/
|
|
75
|
+
readonly isFailed: () => boolean;
|
|
76
|
+
/**
|
|
77
|
+
* Create new scoped context.
|
|
78
|
+
* @returns New reducer context.
|
|
79
|
+
*/
|
|
80
|
+
readonly newScope: () => MtrScriptReducerContext;
|
|
81
|
+
/**
|
|
82
|
+
* Create native function context proxy.
|
|
83
|
+
* @param thisNode Current node (Indicating the current application is expected)
|
|
84
|
+
* @returns Native function context proxy instance.
|
|
85
|
+
*/
|
|
86
|
+
readonly createFunctionContext: (thisNode: MtrScriptExpressionNode) => MtrScriptFunctionContext;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Reduce expression node.
|
|
90
|
+
* @param context - Reducer context
|
|
91
|
+
* @param node - Target expression node
|
|
92
|
+
* @returns Reduced native value
|
|
93
|
+
*/
|
|
94
|
+
export declare const reduceExpressionNode: (context: MtrScriptReducerContext, node: MtrScriptExpressionNode) => Promise<unknown>;
|
|
95
|
+
/**
|
|
96
|
+
* Reduce a node.
|
|
97
|
+
* @param context - Reducer context
|
|
98
|
+
* @param node - Target node
|
|
99
|
+
* @returns Reduced native value list
|
|
100
|
+
*/
|
|
101
|
+
export declare const reduceNode: (context: MtrScriptReducerContext, node: MtrScriptBlockNode) => Promise<unknown[]>;
|
|
102
|
+
/**
|
|
103
|
+
* Create reducer context.
|
|
104
|
+
* @param variables - Predefined variables
|
|
105
|
+
* @param errors - Will be stored detected warnings/errors into it
|
|
106
|
+
* @returns Reducer context
|
|
107
|
+
*/
|
|
108
|
+
export declare const createReducerContext: (variables: MtrScriptVariables, errors: MtrScriptErrorInfo[]) => MtrScriptReducerContext;
|
|
109
|
+
/**
|
|
110
|
+
* Run the reducer.
|
|
111
|
+
* @param node - Target node
|
|
112
|
+
* @param variables - Predefined variables
|
|
113
|
+
* @param errors - Will be stored detected warnings/errors into it
|
|
114
|
+
* @returns Reduced native value list
|
|
115
|
+
*/
|
|
116
|
+
export declare function runReducer(node: MtrScriptBlockNode, variables: MtrScriptVariables, errors: MtrScriptErrorInfo[]): Promise<unknown[]>;
|
|
117
|
+
/**
|
|
118
|
+
* Run the reducer.
|
|
119
|
+
* @param node - Target node list
|
|
120
|
+
* @param variables - Predefined variables
|
|
121
|
+
* @param errors - Will be stored detected warnings/errors into it
|
|
122
|
+
* @returns Reduced native value list
|
|
123
|
+
*/
|
|
124
|
+
export declare function runReducer(nodes: readonly MtrScriptBlockNode[], variables: MtrScriptVariables, errors: MtrScriptErrorInfo[]): Promise<unknown[]>;
|
|
125
|
+
//# sourceMappingURL=reducer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reducer.d.ts","sourceRoot":"","sources":["../src/reducer.ts"],"names":[],"mappings":";;;;;;;;;AAKA,OAAO,EAGL,KAAK,kBAAkB,EACvB,KAAK,kBAAkB,EAGxB,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EACV,uBAAuB,EAEvB,kBAAkB,EAEnB,MAAM,UAAU,CAAC;AAIlB;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B;;OAEG;IACH,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;IACxB;;OAEG;IACH,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;CAC3B;AAED;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACvC;;OAEG;IACH,QAAQ,CAAC,SAAS,EAAE,GAAG,CAAC;IACxB;;OAEG;IACH,QAAQ,CAAC,QAAQ,EAAE,uBAAuB,CAAC;IAC3C;;;;OAIG;IACH,QAAQ,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,uBAAuB,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;IACrE;;;OAGG;IACH,QAAQ,CAAC,WAAW,EAAE,CAAC,KAAK,EAAE,kBAAkB,KAAK,IAAI,CAAC;CAC3D;AAED;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACtC;;;;OAIG;IACH,QAAQ,CAAC,QAAQ,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,WAAW,CAAC;IACjD;;;;OAIG;IACH,QAAQ,CAAC,QAAQ,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;IAC1D;;;OAGG;IACH,QAAQ,CAAC,WAAW,EAAE,CAAC,KAAK,EAAE,kBAAkB,KAAK,IAAI,CAAC;IAC1D;;;OAGG;IACH,QAAQ,CAAC,QAAQ,EAAE,MAAM,OAAO,CAAC;IACjC;;;OAGG;IACH,QAAQ,CAAC,QAAQ,EAAE,MAAM,uBAAuB,CAAC;IACjD;;;;OAIG;IACH,QAAQ,CAAC,qBAAqB,EAAE,CAC9B,QAAQ,EAAE,uBAAuB,KAC9B,wBAAwB,CAAC;CAC/B;AAyGD;;;;;GAKG;AACH,eAAO,MAAM,oBAAoB,GAC/B,SAAS,uBAAuB,EAChC,MAAM,uBAAuB,KAC5B,OAAO,CAAC,OAAO,CAwEjB,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,UAAU,GACrB,SAAS,uBAAuB,EAChC,MAAM,kBAAkB,KACvB,OAAO,CAAC,OAAO,EAAE,CAgEnB,CAAC;AAIF;;;;;GAKG;AACH,eAAO,MAAM,oBAAoB,GAC/B,WAAW,kBAAkB,EAC7B,QAAQ,kBAAkB,EAAE,KAC3B,uBAsFF,CAAC;AAaF;;;;;;GAMG;AACH,wBAAgB,UAAU,CACxB,IAAI,EAAE,kBAAkB,EACxB,SAAS,EAAE,kBAAkB,EAC7B,MAAM,EAAE,kBAAkB,EAAE,GAC3B,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC;AAEtB;;;;;;GAMG;AACH,wBAAgB,UAAU,CACxB,KAAK,EAAE,SAAS,kBAAkB,EAAE,EACpC,SAAS,EAAE,kBAAkB,EAC7B,MAAM,EAAE,kBAAkB,EAAE,GAC3B,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* name: funcity
|
|
3
|
+
* version: 0.1.0
|
|
4
|
+
* description: A functional language interpreter with text processing
|
|
5
|
+
* author: Kouji Matsui (@kekyo@mi.kekyo.net)
|
|
6
|
+
* license: MIT
|
|
7
|
+
* repository.url: https://github.com/kekyo/funcity.git
|
|
8
|
+
* git.commit.hash: 5652ca56084e46cd208085f10c65ec7ad06b848a
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
export interface MtrScriptLocation {
|
|
12
|
+
readonly line: number;
|
|
13
|
+
readonly column: number;
|
|
14
|
+
}
|
|
15
|
+
export interface MtrScriptRange {
|
|
16
|
+
readonly start: MtrScriptLocation;
|
|
17
|
+
readonly end: MtrScriptLocation;
|
|
18
|
+
}
|
|
19
|
+
export declare const emptyLocation: MtrScriptLocation;
|
|
20
|
+
export declare const emptyRange: MtrScriptRange;
|
|
21
|
+
export type MtrScriptErrorType = 'warning' | 'error';
|
|
22
|
+
export interface MtrScriptErrorInfo {
|
|
23
|
+
readonly type: MtrScriptErrorType;
|
|
24
|
+
readonly description: string;
|
|
25
|
+
readonly range: MtrScriptRange;
|
|
26
|
+
}
|
|
27
|
+
export type MtrScriptVariables = ReadonlyMap<string, unknown>;
|
|
28
|
+
export declare const makeSpecialFunction: (f: Function) => Function;
|
|
29
|
+
export declare const isSpecialFunction: (f: Function) => boolean;
|
|
30
|
+
export declare const isConditionalTrue: (v: unknown) => boolean;
|
|
31
|
+
export declare const asIterable: (v: unknown) => Iterable<unknown> | undefined;
|
|
32
|
+
export declare const combineVariables: (...variablesList: readonly (MtrScriptVariables | Record<string, unknown>)[]) => MtrScriptVariables;
|
|
33
|
+
export declare const fromError: (error: any) => string;
|
|
34
|
+
export declare const widerRange: (...ranges: MtrScriptRange[]) => MtrScriptRange;
|
|
35
|
+
export declare const outputErrors: (path: string, errors: readonly MtrScriptErrorInfo[]) => boolean;
|
|
36
|
+
//# sourceMappingURL=scripting.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scripting.d.ts","sourceRoot":"","sources":["../src/scripting.ts"],"names":[],"mappings":";;;;;;;;;AAOA,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,MAAM,EAAE,MAAM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3
|
+
* version: 0.1.0
|
|
4
|
+
* description: A functional language interpreter with text processing
|
|
5
|
+
* author: Kouji Matsui (@kekyo@mi.kekyo.net)
|
|
6
|
+
* license: MIT
|
|
7
|
+
* repository.url: https://github.com/kekyo/funcity.git
|
|
8
|
+
* git.commit.hash: 5652ca56084e46cd208085f10c65ec7ad06b848a
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import { MtrScriptVariables } from './scripting';
|
|
12
|
+
export declare const standardVariables: {
|
|
13
|
+
readonly undefined: undefined;
|
|
14
|
+
readonly null: null;
|
|
15
|
+
readonly true: true;
|
|
16
|
+
readonly false: false;
|
|
17
|
+
readonly cond: Function;
|
|
18
|
+
readonly toString: (...args: unknown[]) => Promise<string>;
|
|
19
|
+
readonly typeof: (arg0: unknown) => Promise<"string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function" | "null" | "array" | "iterable">;
|
|
20
|
+
readonly add: (arg0: unknown, ...args: unknown[]) => Promise<number>;
|
|
21
|
+
readonly sub: (arg0: unknown, ...args: unknown[]) => Promise<number>;
|
|
22
|
+
readonly mul: (arg0: unknown, ...args: unknown[]) => Promise<number>;
|
|
23
|
+
readonly div: (arg0: unknown, ...args: unknown[]) => Promise<number>;
|
|
24
|
+
readonly mod: (arg0: unknown, ...args: unknown[]) => Promise<number>;
|
|
25
|
+
readonly equal: (arg0: unknown, arg1: unknown) => Promise<boolean>;
|
|
26
|
+
readonly now: () => Promise<number>;
|
|
27
|
+
readonly concat: (...args: unknown[]) => Promise<string>;
|
|
28
|
+
readonly join: (arg0: unknown, ...args: unknown[]) => Promise<string>;
|
|
29
|
+
readonly trim: (arg0: unknown) => Promise<any>;
|
|
30
|
+
readonly toUpper: (arg0: unknown) => Promise<any>;
|
|
31
|
+
readonly toLower: (arg0: unknown) => Promise<any>;
|
|
32
|
+
readonly length: (arg0: unknown) => Promise<number>;
|
|
33
|
+
readonly and: (...args: unknown[]) => Promise<boolean>;
|
|
34
|
+
readonly or: (...args: unknown[]) => Promise<boolean>;
|
|
35
|
+
readonly not: (arg0: unknown) => Promise<boolean>;
|
|
36
|
+
readonly at: (arg0: unknown, arg1: unknown) => Promise<any>;
|
|
37
|
+
readonly first: (arg0: unknown) => Promise<any>;
|
|
38
|
+
readonly last: (arg0: unknown) => Promise<any>;
|
|
39
|
+
readonly range: (arg0: unknown, arg1: unknown) => Promise<unknown[]>;
|
|
40
|
+
readonly sort: (arg0: unknown) => Promise<unknown[]>;
|
|
41
|
+
readonly reverse: (arg0: unknown) => Promise<unknown[]>;
|
|
42
|
+
readonly map: (arg0: unknown, arg1: unknown) => Promise<unknown[]>;
|
|
43
|
+
readonly flatMap: (arg0: unknown, arg1: unknown) => Promise<unknown[]>;
|
|
44
|
+
readonly filter: (arg0: unknown, arg1: unknown) => Promise<unknown[]>;
|
|
45
|
+
readonly collect: (arg0: unknown) => Promise<unknown[]>;
|
|
46
|
+
readonly reduce: (arg0: unknown, arg1: unknown, arg2: unknown) => Promise<unknown>;
|
|
47
|
+
readonly match: (arg0: unknown, arg1: unknown) => Promise<RegExpMatchArray | null>;
|
|
48
|
+
readonly replace: (arg0: unknown, arg1: unknown, arg2: unknown) => Promise<string>;
|
|
49
|
+
readonly regex: (arg0: unknown, arg1: unknown) => Promise<RegExp>;
|
|
50
|
+
readonly bind: (arg0: unknown, ...args: unknown[]) => Promise<any>;
|
|
51
|
+
};
|
|
52
|
+
export declare const buildCandidateVariables: (...variablesList: readonly (MtrScriptVariables | Record<string, unknown>)[]) => MtrScriptVariables;
|
|
53
|
+
//# sourceMappingURL=standards.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"standards.d.ts","sourceRoot":"","sources":["../src/standards.ts"],"names":[],"mappings":";;;;;;;;;AAKA,OAAO,EAKL,KAAK,kBAAkB,EACxB,MAAM,aAAa,CAAC;AAsYrB,eAAO,MAAM,iBAAiB;;;;;;iCAxVI,OAAO,EAAE;4BAzBd,OAAO;yBAiEV,OAAO,WAAW,OAAO,EAAE;yBAK3B,OAAO,WAAW,OAAO,EAAE;yBAK3B,OAAO,WAAW,OAAO,EAAE;yBAK3B,OAAO,WAAW,OAAO,EAAE;yBAK3B,OAAO,WAAW,OAAO,EAAE;2BAKzB,OAAO,QAAQ,OAAO;;+BA0BlB,OAAO,EAAE;0BAKd,OAAO,WAAW,OAAO,EAAE;0BAM3B,OAAO;6BAUJ,OAAO;6BAQP,OAAO;4BAQR,OAAO;4BAoBP,OAAO,EAAE;2BAQV,OAAO,EAAE;yBAQX,OAAO;wBAIR,OAAO,QAAQ,OAAO;2BAuBnB,OAAO;0BAkBR,OAAO;2BAoBN,OAAO,QAAQ,OAAO;0BAmBvB,OAAO;6BATJ,OAAO;yBAkBX,OAAO,QAAQ,OAAO;6BAWlB,OAAO,QAAQ,OAAO;4BAWvB,OAAO,QAAQ,OAAO;6BAarB,OAAO;4BAWR,OAAO,QAAQ,OAAO,QAAQ,OAAO;2BAUtC,OAAO,QAAQ,OAAO;6BAMpB,OAAO,QAAQ,OAAO,QAAQ,OAAO;2BAOvC,OAAO,QAAQ,OAAO;0BAUvB,OAAO,WAAW,OAAO,EAAE;CA+C5C,CAAC;AAEX,eAAO,MAAM,uBAAuB,GAClC,GAAG,eAAe,SAAS,CAAC,kBAAkB,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,EAAE,KAC1E,kBAEF,CAAC"}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* name: funcity
|
|
3
|
+
* version: 0.1.0
|
|
4
|
+
* description: A functional language interpreter with text processing
|
|
5
|
+
* author: Kouji Matsui (@kekyo@mi.kekyo.net)
|
|
6
|
+
* license: MIT
|
|
7
|
+
* repository.url: https://github.com/kekyo/funcity.git
|
|
8
|
+
* git.commit.hash: 5652ca56084e46cd208085f10c65ec7ad06b848a
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import { MtrScriptErrorInfo, MtrScriptRange } from './scripting';
|
|
12
|
+
/**
|
|
13
|
+
* The string token.
|
|
14
|
+
*/
|
|
15
|
+
export interface MtrScriptStringToken {
|
|
16
|
+
readonly kind: 'string';
|
|
17
|
+
/**
|
|
18
|
+
* String value.
|
|
19
|
+
*/
|
|
20
|
+
readonly value: string;
|
|
21
|
+
readonly range: MtrScriptRange;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* The number (numeric) token.
|
|
25
|
+
*/
|
|
26
|
+
export interface MtrScriptNumberToken {
|
|
27
|
+
readonly kind: 'number';
|
|
28
|
+
/**
|
|
29
|
+
* Numeric value.
|
|
30
|
+
*/
|
|
31
|
+
readonly value: number;
|
|
32
|
+
readonly range: MtrScriptRange;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* The identity (variable name) token.
|
|
36
|
+
*/
|
|
37
|
+
export interface MtrScriptIdentityToken {
|
|
38
|
+
readonly kind: 'identity';
|
|
39
|
+
/**
|
|
40
|
+
* Identity.
|
|
41
|
+
*/
|
|
42
|
+
readonly name: string;
|
|
43
|
+
readonly range: MtrScriptRange;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Open parenthesis or bracket node.
|
|
47
|
+
*/
|
|
48
|
+
export interface MtrScriptOpenToken {
|
|
49
|
+
readonly kind: 'open';
|
|
50
|
+
/**
|
|
51
|
+
* Open symbol.
|
|
52
|
+
*/
|
|
53
|
+
readonly symbol: string;
|
|
54
|
+
readonly range: MtrScriptRange;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Close parenthesis or bracket token.
|
|
58
|
+
*/
|
|
59
|
+
export interface MtrScriptCloseToken {
|
|
60
|
+
readonly kind: 'close';
|
|
61
|
+
/**
|
|
62
|
+
* Close symbol.
|
|
63
|
+
*/
|
|
64
|
+
readonly symbol: string;
|
|
65
|
+
readonly range: MtrScriptRange;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* End of line token.
|
|
69
|
+
*/
|
|
70
|
+
export interface MtrScriptEndOfLineToken {
|
|
71
|
+
readonly kind: 'eol';
|
|
72
|
+
readonly range: MtrScriptRange;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Free form text token.
|
|
76
|
+
*/
|
|
77
|
+
export interface MtrScriptTextToken {
|
|
78
|
+
readonly kind: 'text';
|
|
79
|
+
/**
|
|
80
|
+
* Text value.
|
|
81
|
+
*/
|
|
82
|
+
readonly text: string;
|
|
83
|
+
readonly range: MtrScriptRange;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* The token.
|
|
87
|
+
*/
|
|
88
|
+
export type MtrScriptToken = MtrScriptStringToken | MtrScriptNumberToken | MtrScriptIdentityToken | MtrScriptOpenToken | MtrScriptCloseToken | MtrScriptEndOfLineToken | MtrScriptTextToken;
|
|
89
|
+
/**
|
|
90
|
+
* Run tokenizer.
|
|
91
|
+
* @param script - Input script text
|
|
92
|
+
* @errors - Will be stored detected warnings/errors into it
|
|
93
|
+
* @returns The token list
|
|
94
|
+
*/
|
|
95
|
+
export declare const runTokenizer: (script: string, errors: MtrScriptErrorInfo[]) => MtrScriptToken[];
|
|
96
|
+
//# sourceMappingURL=tokenizer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tokenizer.d.ts","sourceRoot":"","sources":["../src/tokenizer.ts"],"names":[],"mappings":";;;;;;;;;AAKA,OAAO,KAAK,EACV,kBAAkB,EAElB,cAAc,EACf,MAAM,aAAa,CAAC;AAIrB;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;IACxB;;OAEG;IACH,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,KAAK,EAAE,cAAc,CAAC;CAChC;AAED;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;IACxB;;OAEG;IACH,QAAQ,CAAC,KAAK,EA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@
|
|
|
1
|
+
{
|
|
2
|
+
"git": {
|
|
3
|
+
"tags": [
|
|
4
|
+
"0.1.0"
|
|
5
|
+
],
|
|
6
|
+
"branches": [
|
|
7
|
+
"main"
|
|
8
|
+
],
|
|
9
|
+
"version": "0.1.0",
|
|
10
|
+
"commit": {
|
|
11
|
+
"hash": "5652ca56084e46cd208085f10c65ec7ad06b848a",
|
|
12
|
+
"shortHash": "5652ca5",
|
|
13
|
+
"date": "2025-07-15T12:22:43+09:00",
|
|
14
|
+
"message": "Initial commit"
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
"version": "0.1.0",
|
|
18
|
+
"author": "Kouji Matsui (@kekyo@mi.kekyo.net)",
|
|
19
|
+
"license": "MIT",
|
|
20
|
+
"repository": {
|
|
21
|
+
"type": "git",
|
|
22
|
+
"url": "https://github.com/kekyo/funcity.git"
|
|
23
|
+
},
|
|
24
|
+
"homepage": "https://github.com/kekyo/funcity#readme",
|
|
25
|
+
"name": "funcity",
|
|
26
|
+
"description": "A functional language interpreter with text processing",
|
|
27
|
+
"keywords": [
|
|
28
|
+
"functional",
|
|
29
|
+
"language",
|
|
30
|
+
"interpreter",
|
|
31
|
+
"text-processing"
|
|
32
|
+
],
|
|
33
|
+
"type": "module",
|
|
34
|
+
"main": "./dist/index.cjs",
|
|
35
|
+
"module": "./dist/index.mjs",
|
|
36
|
+
"types": "./dist/index.d.ts",
|
|
37
|
+
"exports": {
|
|
38
|
+
".": {
|
|
39
|
+
"types": "./dist/index.d.ts",
|
|
40
|
+
"import": "./dist/index.mjs",
|
|
41
|
+
"require": "./dist/index.cjs"
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
"files": [
|
|
45
|
+
"dist",
|
|
46
|
+
"LICENSE"
|
|
47
|
+
],
|
|
48
|
+
"scripts": {
|
|
49
|
+
"build": "vite build",
|
|
50
|
+
"test": "npm run build && vitest run",
|
|
51
|
+
"pack": "npm run build && screw-up pack --pack-destination ../artifacts/"
|
|
52
|
+
},
|
|
53
|
+
"dependencies": {},
|
|
54
|
+
"devDependencies": {
|
|
55
|
+
"@types/node": ">=20.0.0",
|
|
56
|
+
"prettier-max": ">=1.13.0",
|
|
57
|
+
"screw-up": ">=1.18.0",
|
|
58
|
+
"typescript": ">=5.0.0",
|
|
59
|
+
"vite": ">=5.0.0",
|
|
60
|
+
"vite-plugin-dts": ">=3.0.0",
|
|
61
|
+
"vitest": ">=1.0.0"
|
|
62
|
+
},
|
|
63
|
+
"buildDate": "2026-01-09T23:58:36+09:00"
|
|
64
|
+
}
|