@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.
- package/CONTEXT.md +83 -9
- package/dist/index.d.ts +3 -0
- package/dist/index.js +5 -1
- package/dist/index.js.map +1 -1
- package/dist/peggy/dist/peg-tag-parser.d.ts +11 -0
- package/dist/peggy/dist/peg-tag-parser.js +3130 -0
- package/dist/peggy/dist/peg-tag-parser.js.map +1 -0
- package/dist/peggy/index.d.ts +13 -0
- package/dist/peggy/index.js +117 -0
- package/dist/peggy/index.js.map +1 -0
- package/dist/peggy/interpreter.d.ts +32 -0
- package/dist/peggy/interpreter.js +208 -0
- package/dist/peggy/interpreter.js.map +1 -0
- package/dist/peggy/statements.d.ts +51 -0
- package/dist/peggy/statements.js +7 -0
- package/dist/peggy/statements.js.map +1 -0
- package/dist/schema.d.ts +41 -0
- package/dist/schema.js +573 -0
- package/dist/schema.js.map +1 -0
- package/dist/schema.spec.d.ts +1 -0
- package/dist/schema.spec.js +980 -0
- package/dist/schema.spec.js.map +1 -0
- package/dist/tags.d.ts +144 -37
- package/dist/tags.js +535 -344
- package/dist/tags.js.map +1 -1
- package/dist/tags.spec.js +524 -45
- package/dist/tags.spec.js.map +1 -1
- package/package.json +6 -8
- package/src/index.ts +3 -0
- package/src/motly-schema.motly +52 -0
- package/src/peggy/dist/peg-tag-parser.js +2790 -0
- package/src/peggy/index.ts +89 -0
- package/src/peggy/interpreter.ts +265 -0
- package/src/peggy/malloy-tag.peggy +224 -0
- package/src/peggy/statements.ts +49 -0
- package/src/schema.spec.ts +1280 -0
- package/src/schema.ts +852 -0
- package/src/tags.spec.ts +591 -46
- package/src/tags.ts +597 -398
- package/tsconfig.json +3 -2
- package/dist/lib/Malloy/MalloyTagLexer.d.ts +0 -42
- package/dist/lib/Malloy/MalloyTagLexer.js +0 -395
- package/dist/lib/Malloy/MalloyTagLexer.js.map +0 -1
- package/dist/lib/Malloy/MalloyTagParser.d.ts +0 -180
- package/dist/lib/Malloy/MalloyTagParser.js +0 -1077
- package/dist/lib/Malloy/MalloyTagParser.js.map +0 -1
- package/dist/lib/Malloy/MalloyTagVisitor.d.ts +0 -120
- package/dist/lib/Malloy/MalloyTagVisitor.js +0 -4
- package/dist/lib/Malloy/MalloyTagVisitor.js.map +0 -1
- package/scripts/build_parser.js +0 -98
- package/src/MalloyTag.g4 +0 -104
- package/src/lib/Malloy/MalloyTag.interp +0 -61
- package/src/lib/Malloy/MalloyTag.tokens +0 -32
- package/src/lib/Malloy/MalloyTagLexer.interp +0 -85
- package/src/lib/Malloy/MalloyTagLexer.tokens +0 -32
- package/src/lib/Malloy/MalloyTagLexer.ts +0 -386
- package/src/lib/Malloy/MalloyTagParser.ts +0 -1065
- package/src/lib/Malloy/MalloyTagVisitor.ts +0 -141
- 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
|
-
|
|
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
|
-
- **
|
|
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
|
-
|
|
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
|
-
|
|
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
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 };
|