@traqula/core 0.0.19 → 0.0.20
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/lib/AstCoreFactory.js +1 -1
- package/lib/AstCoreFactory.js.map +1 -1
- package/lib/TransformerObject.d.ts +64 -0
- package/lib/TransformerObject.js +204 -0
- package/lib/TransformerObject.js.map +1 -0
- package/lib/TransformerSubTyped.d.ts +94 -0
- package/lib/TransformerSubTyped.js +116 -0
- package/lib/TransformerSubTyped.js.map +1 -0
- package/lib/TransformerTyped.d.ts +62 -0
- package/lib/TransformerTyped.js +95 -0
- package/lib/TransformerTyped.js.map +1 -0
- package/lib/generator-builder/dynamicGenerator.d.ts +13 -3
- package/lib/generator-builder/dynamicGenerator.js +90 -60
- package/lib/generator-builder/dynamicGenerator.js.map +1 -1
- package/lib/generator-builder/generatorBuilder.d.ts +5 -2
- package/lib/generator-builder/generatorBuilder.js +3 -0
- package/lib/generator-builder/generatorBuilder.js.map +1 -1
- package/lib/generator-builder/generatorTypes.d.ts +35 -21
- package/lib/generator-builder/generatorTypes.js.map +1 -1
- package/lib/index.cjs +337 -129
- package/lib/index.d.ts +3 -1
- package/lib/index.js +3 -1
- package/lib/index.js.map +1 -1
- package/lib/indirection-builder/IndirBuilder.d.ts +4 -1
- package/lib/indirection-builder/IndirBuilder.js +3 -0
- package/lib/indirection-builder/IndirBuilder.js.map +1 -1
- package/lib/parser-builder/parserBuilder.d.ts +12 -8
- package/lib/parser-builder/parserBuilder.js +3 -0
- package/lib/parser-builder/parserBuilder.js.map +1 -1
- package/lib/utils.d.ts +4 -0
- package/lib/utils.js +4 -0
- package/lib/utils.js.map +1 -1
- package/package.json +2 -2
- package/lib/Transformers.d.ts +0 -129
- package/lib/Transformers.js +0 -226
- package/lib/Transformers.js.map +0 -1
|
@@ -31,40 +31,36 @@ export interface RuleDefArg {
|
|
|
31
31
|
* @param rule the rule to be called
|
|
32
32
|
* @param input the ast input to work on
|
|
33
33
|
* @param arg the remaining parameters required by this rule.
|
|
34
|
-
* @constructor
|
|
35
34
|
*/
|
|
36
35
|
SUBRULE: <T, U extends any[]>(rule: GeneratorRule<any, any, T, U>, input: T, ...arg: U) => void;
|
|
37
36
|
/**
|
|
38
37
|
* Print the characters to the output string
|
|
39
38
|
* @param args arguments to be printed
|
|
40
|
-
* @constructor
|
|
41
39
|
*/
|
|
42
40
|
PRINT: (...args: string[]) => void;
|
|
43
41
|
/**
|
|
44
|
-
*
|
|
45
|
-
*
|
|
46
|
-
*
|
|
47
|
-
*
|
|
48
|
-
|
|
49
|
-
PRINT_SPACE_LEFT: (...args: string[]) => void;
|
|
50
|
-
/**
|
|
51
|
-
* Prints all arguments as one word, ensuring it has a space before and behind each word
|
|
52
|
-
* @param args
|
|
53
|
-
* @constructor
|
|
42
|
+
* Ensures the requested characters are printed at the current location.
|
|
43
|
+
* Will not change the constructed string in case either:
|
|
44
|
+
* 1. The string builder ends in the to ensure string.
|
|
45
|
+
* 2: The next printed string starts with the ensure string.
|
|
46
|
+
* Otherwise, prints the sting.
|
|
54
47
|
*/
|
|
55
|
-
|
|
48
|
+
ENSURE: (...args: string[]) => void;
|
|
56
49
|
/**
|
|
57
|
-
*
|
|
58
|
-
* @param args
|
|
59
|
-
* @constructor
|
|
50
|
+
* Ensures either one of the provided strings. If no string can be ensured, it will print the first argument.
|
|
60
51
|
*/
|
|
61
|
-
|
|
52
|
+
ENSURE_EITHER: (...args: string[]) => void;
|
|
62
53
|
/**
|
|
63
|
-
*
|
|
64
|
-
*
|
|
65
|
-
*
|
|
54
|
+
* Create a new line, will ensure the previous line does not end in blank characters.
|
|
55
|
+
* Will only print a newline if the pointer is not currently on a new line.
|
|
56
|
+
* When the traqulaIndentation is changed in the meanwhile, this will ensure the indentation of teh pointer updated.
|
|
66
57
|
*/
|
|
67
|
-
|
|
58
|
+
NEW_LINE: (arg?: {
|
|
59
|
+
/**
|
|
60
|
+
* Whether the newline should be printed regardless of the pointer is already on an empty newline.
|
|
61
|
+
*/
|
|
62
|
+
force?: boolean;
|
|
63
|
+
}) => void;
|
|
68
64
|
/**
|
|
69
65
|
* Handles the location of a node as if it was generated using a SUBRULE.
|
|
70
66
|
* Can be used to generate many nodes within a single subrule call while still having correct localization handling.
|
|
@@ -80,4 +76,22 @@ export interface RuleDefArg {
|
|
|
80
76
|
* @constructor
|
|
81
77
|
*/
|
|
82
78
|
CATCHUP: (until: number) => void;
|
|
79
|
+
/**
|
|
80
|
+
* Prints all arguments as one word, ensuring it has a space before and behind each word
|
|
81
|
+
* @param args
|
|
82
|
+
*/
|
|
83
|
+
PRINT_WORD: (...args: string[]) => void;
|
|
84
|
+
/**
|
|
85
|
+
* Prints all arguments as words, ensuring they all have a space before and behind them.
|
|
86
|
+
* @param args
|
|
87
|
+
*/
|
|
88
|
+
PRINT_WORDS: (...args: string[]) => void;
|
|
89
|
+
/**
|
|
90
|
+
* Start a newline to print arguments on
|
|
91
|
+
*/
|
|
92
|
+
PRINT_ON_EMPTY: (...args: string[]) => void;
|
|
93
|
+
/**
|
|
94
|
+
* Prints arguments on its own (shared) line
|
|
95
|
+
*/
|
|
96
|
+
PRINT_ON_OWN_LINE: (...args: string[]) => void;
|
|
83
97
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generatorTypes.js","sourceRoot":"","sources":["generatorTypes.ts"],"names":[],"mappings":"","sourcesContent":["import type { Localized } from '../nodeTypings.js';\n\n/**\n * Type used to declare generator rules.\n */\nexport type GeneratorRule<\n /**\n * Context object available in rule implementation.\n */\n Context = any,\n /**\n * Name of grammar rule, should be a strict subtype of string like 'myGrammarRule'.\n */\n NameType extends string = string,\n /**\n * Type that of the AST that we will generate the string for.\n * This type will be the provided when calling SUBRULE with this generator rule.\n * Generation happens on a per AST node basis.\n * The core will implement the generation as such. If this ever changes, we will cross that bridge when we get there.\n */\n AstType = any,\n /**\n * Function arguments that can be given to convey the state of the current parse operation.\n */\n ParamType extends any[] = any[],\n> = {\n name: NameType;\n gImpl: (def: RuleDefArg) =>\n (ast: AstType, context: Context, ...params: ParamType) => void;\n};\n\nexport interface RuleDefArg {\n /**\n * Call another generator rule so it can generate its string representation.\n * @param rule the rule to be called\n * @param input the ast input to work on\n * @param arg the remaining parameters required by this rule.\n
|
|
1
|
+
{"version":3,"file":"generatorTypes.js","sourceRoot":"","sources":["generatorTypes.ts"],"names":[],"mappings":"","sourcesContent":["import type { Localized } from '../nodeTypings.js';\n\n/**\n * Type used to declare generator rules.\n */\nexport type GeneratorRule<\n /**\n * Context object available in rule implementation.\n */\n Context = any,\n /**\n * Name of grammar rule, should be a strict subtype of string like 'myGrammarRule'.\n */\n NameType extends string = string,\n /**\n * Type that of the AST that we will generate the string for.\n * This type will be the provided when calling SUBRULE with this generator rule.\n * Generation happens on a per AST node basis.\n * The core will implement the generation as such. If this ever changes, we will cross that bridge when we get there.\n */\n AstType = any,\n /**\n * Function arguments that can be given to convey the state of the current parse operation.\n */\n ParamType extends any[] = any[],\n> = {\n name: NameType;\n gImpl: (def: RuleDefArg) =>\n (ast: AstType, context: Context, ...params: ParamType) => void;\n};\n\nexport interface RuleDefArg {\n /**\n * Call another generator rule so it can generate its string representation.\n * @param rule the rule to be called\n * @param input the ast input to work on\n * @param arg the remaining parameters required by this rule.\n */\n SUBRULE: <T, U extends any[]>(rule: GeneratorRule<any, any, T, U>, input: T, ...arg: U) => void;\n /**\n * Print the characters to the output string\n * @param args arguments to be printed\n */\n PRINT: (...args: string[]) => void;\n /**\n * Ensures the requested characters are printed at the current location.\n * Will not change the constructed string in case either:\n * 1. The string builder ends in the to ensure string.\n * 2: The next printed string starts with the ensure string.\n * Otherwise, prints the sting.\n */\n ENSURE: (...args: string[]) => void;\n /**\n * Ensures either one of the provided strings. If no string can be ensured, it will print the first argument.\n */\n ENSURE_EITHER: (...args: string[]) => void;\n /**\n * Create a new line, will ensure the previous line does not end in blank characters.\n * Will only print a newline if the pointer is not currently on a new line.\n * When the traqulaIndentation is changed in the meanwhile, this will ensure the indentation of teh pointer updated.\n */\n NEW_LINE: (arg?: {\n /**\n * Whether the newline should be printed regardless of the pointer is already on an empty newline.\n */\n force?: boolean;\n }) => void;\n /**\n * Handles the location of a node as if it was generated using a SUBRULE.\n * Can be used to generate many nodes within a single subrule call while still having correct localization handling.\n * @param loc\n * @param nodeHandle\n * @constructor\n */\n HANDLE_LOC: <T>(loc: Localized, nodeHandle: () => T) => T | undefined;\n /**\n * Catchup the string until a given length,\n * printing everything from the current catchup location until the index you provide.\n * @param until\n * @constructor\n */\n CATCHUP: (until: number) => void;\n\n // Derivations from the above fundamental functions\n /**\n * Prints all arguments as one word, ensuring it has a space before and behind each word\n * @param args\n */\n PRINT_WORD: (...args: string[]) => void;\n /**\n * Prints all arguments as words, ensuring they all have a space before and behind them.\n * @param args\n */\n PRINT_WORDS: (...args: string[]) => void;\n /**\n * Start a newline to print arguments on\n */\n PRINT_ON_EMPTY: (...args: string[]) => void;\n /**\n * Prints arguments on its own (shared) line\n */\n PRINT_ON_OWN_LINE: (...args: string[]) => void;\n}\n"]}
|