@malloydata/malloy-tag 0.0.335 → 0.0.337

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 (59) hide show
  1. package/CONTEXT.md +83 -9
  2. package/dist/index.d.ts +3 -0
  3. package/dist/index.js +5 -1
  4. package/dist/index.js.map +1 -1
  5. package/dist/peggy/dist/peg-tag-parser.d.ts +11 -0
  6. package/dist/peggy/dist/peg-tag-parser.js +3130 -0
  7. package/dist/peggy/dist/peg-tag-parser.js.map +1 -0
  8. package/dist/peggy/index.d.ts +13 -0
  9. package/dist/peggy/index.js +117 -0
  10. package/dist/peggy/index.js.map +1 -0
  11. package/dist/peggy/interpreter.d.ts +32 -0
  12. package/dist/peggy/interpreter.js +208 -0
  13. package/dist/peggy/interpreter.js.map +1 -0
  14. package/dist/peggy/statements.d.ts +51 -0
  15. package/dist/peggy/statements.js +7 -0
  16. package/dist/peggy/statements.js.map +1 -0
  17. package/dist/schema.d.ts +41 -0
  18. package/dist/schema.js +573 -0
  19. package/dist/schema.js.map +1 -0
  20. package/dist/schema.spec.d.ts +1 -0
  21. package/dist/schema.spec.js +980 -0
  22. package/dist/schema.spec.js.map +1 -0
  23. package/dist/tags.d.ts +144 -37
  24. package/dist/tags.js +535 -344
  25. package/dist/tags.js.map +1 -1
  26. package/dist/tags.spec.js +524 -45
  27. package/dist/tags.spec.js.map +1 -1
  28. package/package.json +6 -8
  29. package/src/index.ts +3 -0
  30. package/src/motly-schema.motly +52 -0
  31. package/src/peggy/dist/peg-tag-parser.js +2790 -0
  32. package/src/peggy/index.ts +89 -0
  33. package/src/peggy/interpreter.ts +265 -0
  34. package/src/peggy/malloy-tag.peggy +224 -0
  35. package/src/peggy/statements.ts +49 -0
  36. package/src/schema.spec.ts +1280 -0
  37. package/src/schema.ts +852 -0
  38. package/src/tags.spec.ts +591 -46
  39. package/src/tags.ts +597 -398
  40. package/tsconfig.json +3 -2
  41. package/dist/lib/Malloy/MalloyTagLexer.d.ts +0 -42
  42. package/dist/lib/Malloy/MalloyTagLexer.js +0 -395
  43. package/dist/lib/Malloy/MalloyTagLexer.js.map +0 -1
  44. package/dist/lib/Malloy/MalloyTagParser.d.ts +0 -180
  45. package/dist/lib/Malloy/MalloyTagParser.js +0 -1077
  46. package/dist/lib/Malloy/MalloyTagParser.js.map +0 -1
  47. package/dist/lib/Malloy/MalloyTagVisitor.d.ts +0 -120
  48. package/dist/lib/Malloy/MalloyTagVisitor.js +0 -4
  49. package/dist/lib/Malloy/MalloyTagVisitor.js.map +0 -1
  50. package/scripts/build_parser.js +0 -98
  51. package/src/MalloyTag.g4 +0 -104
  52. package/src/lib/Malloy/MalloyTag.interp +0 -61
  53. package/src/lib/Malloy/MalloyTag.tokens +0 -32
  54. package/src/lib/Malloy/MalloyTagLexer.interp +0 -85
  55. package/src/lib/Malloy/MalloyTagLexer.tokens +0 -32
  56. package/src/lib/Malloy/MalloyTagLexer.ts +0 -386
  57. package/src/lib/Malloy/MalloyTagParser.ts +0 -1065
  58. package/src/lib/Malloy/MalloyTagVisitor.ts +0 -141
  59. package/src/lib/Malloy/_BUILD_DIGEST_ +0 -1
package/CONTEXT.md CHANGED
@@ -1,6 +1,6 @@
1
- # Malloy Tag Language
1
+ # Malloy Tag Language (MOTLY)
2
2
 
3
- The Malloy Tag Language is a concise, readable syntax for adding structured metadata to Malloy objects through annotations. It's designed to work seamlessly with Malloy's annotation system.
3
+ The Malloy Tag Language (also called MOTLY - Malloy Object Tagging Language) is a concise, readable syntax for adding structured metadata to Malloy objects through annotations. It's designed to work seamlessly with Malloy's annotation system and can also be used as a standalone configuration language.
4
4
 
5
5
  ## Purpose
6
6
 
@@ -20,29 +20,78 @@ The Tag Language supports several data types:
20
20
  ```
21
21
  A tag name without a value is a boolean (implicitly `true`).
22
22
 
23
+ ### Typed Values
24
+ Values prefixed with `@` are typed:
25
+ ```malloy
26
+ # enabled=@true
27
+ # debug=@false
28
+ # created=@2024-01-15
29
+ # updated=@2024-01-15T10:30:00Z
30
+ ```
31
+
23
32
  ### String Values
24
33
  ```malloy
25
34
  # color=blue
26
35
  # name="User Name"
36
+ # description="""
37
+ Multi-line string
38
+ with preserved newlines.
39
+ """
27
40
  ```
28
- Unquoted strings for simple values, quoted strings for values with spaces or special characters.
41
+ Unquoted strings for simple values (alphanumeric and underscore), quoted strings for values with spaces or special characters, triple-quoted for multi-line.
29
42
 
30
43
  ### Numeric Values
31
44
  ```malloy
32
45
  # size=10
33
46
  # width=100.5
47
+ # rate=-0.05
34
48
  ```
35
49
  Numbers are automatically parsed as numeric types.
36
50
 
51
+ ### Arrays
52
+ ```malloy
53
+ # colors=[red, green, blue]
54
+ # ports=[80, 443, 8080]
55
+ # users=[{ name=alice role=admin }, { name=bob role=user }]
56
+ ```
57
+
37
58
  ### Nested Properties
38
59
  ```malloy
39
- # box { width=100 height=200 }
60
+ # box: { width=100 height=200 }
61
+ ```
62
+ Colon and curly braces create nested property groups.
63
+
64
+ ### Deep Path Notation
65
+ ```malloy
66
+ # database.connection.pool.max=100
40
67
  ```
41
- Curly braces create nested property groups.
68
+ Dot notation for setting nested values directly.
69
+
70
+ ### Delete Property
71
+ ```malloy
72
+ # -deprecated_field
73
+ ```
74
+ Minus prefix removes a property.
42
75
 
43
76
  ### Combined Example
44
77
  ```malloy
45
- #(myApp) hidden color=blue size=10 box { width=100 height=200 } name="Blue Thing"
78
+ #(myApp) hidden color=blue size=10 box: { width=100 height=200 } name="Blue Thing"
79
+ ```
80
+
81
+ ## Colon vs Space Syntax
82
+
83
+ Two ways to add properties to objects with different semantics:
84
+
85
+ **Colon syntax (`: { }`) replaces all properties:**
86
+ ```malloy
87
+ # server: { host=localhost port=8080 }
88
+ # server: { url="http://example.com" } # Replaces - only url remains
89
+ ```
90
+
91
+ **Space syntax (`{ }`) merges with existing properties:**
92
+ ```malloy
93
+ # server: { host=localhost }
94
+ # server { port=8080 } # Merges - both host and port exist
46
95
  ```
47
96
 
48
97
  ## Annotation Prefixes
@@ -82,14 +131,39 @@ The expected workflow for using tag annotations:
82
131
  ## Implementation
83
132
 
84
133
  The `malloy-tag` package provides:
85
- - **Parser** for tag language syntax
134
+ - **Peggy-based parser** for tag language syntax
135
+ - **Tag class** with methods for type-safe value access
86
136
  - **Type definitions** for parsed tag structures
87
- - **Utilities** for working with tags in JavaScript/TypeScript
137
+
138
+ ### Key API Methods
139
+
140
+ ```typescript
141
+ import {Tag} from '@malloydata/malloy-tag';
142
+
143
+ const {tag, log} = Tag.parse('enabled=@true port=8080 name="My App"');
144
+
145
+ // Convert to plain JavaScript object
146
+ const obj = tag.toObject(); // { enabled: true, port: 8080, name: "My App" }
147
+
148
+ // Type-safe accessors
149
+ tag.text('name'); // "My App"
150
+ tag.numeric('port'); // 8080
151
+ tag.boolean('enabled'); // true
152
+ tag.isTrue('enabled'); // true
153
+ tag.date('created'); // Date object
154
+ tag.textArray('features'); // string[]
155
+ tag.has('name'); // true
156
+
157
+ // Nested access
158
+ tag.text('server', 'host');
159
+ tag.tag('server'); // Get nested Tag object
160
+ ```
88
161
 
89
162
  ## Documentation
90
163
 
91
164
  For complete tag language syntax and examples, see:
92
- https://docs.malloydata.dev/documentation/language/tags
165
+ - `docs/motly.md` in this package (comprehensive reference)
166
+ - https://docs.malloydata.dev/documentation/language/tags
93
167
 
94
168
  ## Important Notes
95
169
 
package/dist/index.d.ts CHANGED
@@ -1,2 +1,5 @@
1
1
  export * from './tags';
2
+ export { parseTag } from './peggy';
2
3
  export * as ParseUtil from './util';
4
+ export { validateTag } from './schema';
5
+ export type { SchemaError } from './schema';
package/dist/index.js CHANGED
@@ -36,7 +36,7 @@ var __importStar = (this && this.__importStar) || (function () {
36
36
  };
37
37
  })();
38
38
  Object.defineProperty(exports, "__esModule", { value: true });
39
- exports.ParseUtil = void 0;
39
+ exports.validateTag = exports.ParseUtil = exports.parseTag = void 0;
40
40
  /*
41
41
  * Copyright (c) Meta Platforms, Inc. and affiliates.
42
42
  *
@@ -44,5 +44,9 @@ exports.ParseUtil = void 0;
44
44
  * LICENSE file in the root directory of this source tree.
45
45
  */
46
46
  __exportStar(require("./tags"), exports);
47
+ var peggy_1 = require("./peggy");
48
+ Object.defineProperty(exports, "parseTag", { enumerable: true, get: function () { return peggy_1.parseTag; } });
47
49
  exports.ParseUtil = __importStar(require("./util"));
50
+ var schema_1 = require("./schema");
51
+ Object.defineProperty(exports, "validateTag", { enumerable: true, get: function () { return schema_1.validateTag; } });
48
52
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;GAKG;AACH,yCAAuB;AACvB,oDAAoC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;GAKG;AACH,yCAAuB;AACvB,iCAAiC;AAAzB,iGAAA,QAAQ,OAAA;AAChB,oDAAoC;AACpC,mCAAqC;AAA7B,qGAAA,WAAW,OAAA"}
@@ -0,0 +1,11 @@
1
+ declare function peg$SyntaxError(message: any, expected: any, found: any, location: any): Error;
2
+ declare class peg$SyntaxError {
3
+ constructor(message: any, expected: any, found: any, location: any);
4
+ format(sources: any): string;
5
+ }
6
+ declare namespace peg$SyntaxError {
7
+ function buildMessage(expected: any, found: any): string;
8
+ }
9
+ declare function peg$parse(input: any, options: any): any;
10
+ export declare let StartRules: string[];
11
+ export { peg$SyntaxError as SyntaxError, peg$parse as parse };