@traqula/core 0.0.18 → 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.
Files changed (36) hide show
  1. package/lib/AstCoreFactory.js +1 -1
  2. package/lib/AstCoreFactory.js.map +1 -1
  3. package/lib/TransformerObject.d.ts +64 -0
  4. package/lib/TransformerObject.js +204 -0
  5. package/lib/TransformerObject.js.map +1 -0
  6. package/lib/TransformerSubTyped.d.ts +94 -0
  7. package/lib/TransformerSubTyped.js +116 -0
  8. package/lib/TransformerSubTyped.js.map +1 -0
  9. package/lib/TransformerTyped.d.ts +62 -0
  10. package/lib/TransformerTyped.js +95 -0
  11. package/lib/TransformerTyped.js.map +1 -0
  12. package/lib/generator-builder/dynamicGenerator.d.ts +13 -3
  13. package/lib/generator-builder/dynamicGenerator.js +90 -60
  14. package/lib/generator-builder/dynamicGenerator.js.map +1 -1
  15. package/lib/generator-builder/generatorBuilder.d.ts +5 -2
  16. package/lib/generator-builder/generatorBuilder.js +6 -3
  17. package/lib/generator-builder/generatorBuilder.js.map +1 -1
  18. package/lib/generator-builder/generatorTypes.d.ts +35 -21
  19. package/lib/generator-builder/generatorTypes.js.map +1 -1
  20. package/lib/index.cjs +346 -138
  21. package/lib/index.d.ts +3 -1
  22. package/lib/index.js +3 -1
  23. package/lib/index.js.map +1 -1
  24. package/lib/indirection-builder/IndirBuilder.d.ts +4 -1
  25. package/lib/indirection-builder/IndirBuilder.js +6 -3
  26. package/lib/indirection-builder/IndirBuilder.js.map +1 -1
  27. package/lib/parser-builder/parserBuilder.d.ts +12 -8
  28. package/lib/parser-builder/parserBuilder.js +6 -3
  29. package/lib/parser-builder/parserBuilder.js.map +1 -1
  30. package/lib/utils.d.ts +4 -0
  31. package/lib/utils.js +4 -0
  32. package/lib/utils.js.map +1 -1
  33. package/package.json +2 -2
  34. package/lib/Transformers.d.ts +0 -129
  35. package/lib/Transformers.js +0 -226
  36. 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
- * Print the character to the output stream ensuring there is a space to the left oif what you print.
45
- * If a space was printed right before this, it will not print a space.
46
- * @param args
47
- * @constructor
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
- PRINT_WORD: (...args: string[]) => void;
48
+ ENSURE: (...args: string[]) => void;
56
49
  /**
57
- * Prints all arguments as words, ensuring they all have a space before and behind them.
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
- PRINT_WORDS: (...args: string[]) => void;
52
+ ENSURE_EITHER: (...args: string[]) => void;
62
53
  /**
63
- * Ensures that what you print is on a newline with the indentation equal to the indentation currently setup.
64
- * @param args
65
- * @constructor
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
- PRINT_ON_EMPTY: (...args: string[]) => void;
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 * @constructor\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 * @constructor\n */\n PRINT: (...args: string[]) => void;\n /**\n * Print the character to the output stream ensuring there is a space to the left oif what you print.\n * If a space was printed right before this, it will not print a space.\n * @param args\n * @constructor\n */\n PRINT_SPACE_LEFT: (...args: string[]) => void;\n /**\n * Prints all arguments as one word, ensuring it has a space before and behind each word\n * @param args\n * @constructor\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 * @constructor\n */\n PRINT_WORDS: (...args: string[]) => void;\n /**\n * Ensures that what you print is on a newline with the indentation equal to the indentation currently setup.\n * @param args\n * @constructor\n */\n PRINT_ON_EMPTY: (...args: string[]) => 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"]}
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"]}