@bablr/cli 0.4.6 → 0.5.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.
Files changed (3) hide show
  1. package/README.md +2 -2
  2. package/lib/syntax.js +32 -22
  3. package/package.json +9 -9
package/README.md CHANGED
@@ -24,7 +24,7 @@ Options:
24
24
  ## Example
25
25
 
26
26
  ```bash
27
- bablr -l @bablr/language-json -p Expression -f << 'EOF'
27
+ bablr -l @bablr/language-en-json -p Expression -f << 'EOF'
28
28
  [
29
29
  1,
30
30
  true,
@@ -36,7 +36,7 @@ EOF
36
36
  Running the above command produces the following output. Note that this is a stream parse so lines of output will appear one by one as fast as the input can be read and parsed.
37
37
 
38
38
  ```cstml
39
- <!0:cstml bablr-language='https://github.com/bablr-lang/language-json'>
39
+ <!0:cstml bablr-language='https://github.com/bablr-lang/language-en-json'>
40
40
  <>
41
41
  <Array>
42
42
  openToken:
package/lib/syntax.js CHANGED
@@ -16,6 +16,7 @@ import {
16
16
  buildAnsiPopEffect,
17
17
  } from '@bablr/agast-helpers/builders';
18
18
  import { buildFullyQualifiedSpamMatcher } from '@bablr/agast-vm-helpers';
19
+ import { OpenNodeTag, CloseNodeTag, ReferenceTag, LiteralTag } from '@bablr/agast-helpers/symbols';
19
20
 
20
21
  function* __higlightStrategy(context, tokens) {
21
22
  const co = new Coroutine(getStreamIterator(tokens));
@@ -33,41 +34,50 @@ function* __higlightStrategy(context, tokens) {
33
34
 
34
35
  if (co.done) break;
35
36
 
36
- const token = co.value;
37
+ const tag = co.value;
37
38
 
38
- if (token.type === 'OpenNodeTag') {
39
- const tagType = token.value.type;
39
+ if (tag.type === OpenNodeTag) {
40
+ const tagType = tag.value.type;
40
41
  const currentType = types.value;
41
42
 
42
43
  types = types.push(tagType);
43
44
 
44
- if (tagType === 'Literal' || (tagType === 'String' && currentRef.name === 'intrinsicValue')) {
45
- if (tagType === 'Literal' || currentType === 'OpenNodeTag') {
45
+ if (
46
+ tagType === Symbol.for('LiteralTag') ||
47
+ (tagType === Symbol.for('String') && currentRef.name === 'intrinsicValue')
48
+ ) {
49
+ if (tagType === Symbol.for('LiteralTag') || currentType === Symbol.for('OpenNodeTag')) {
46
50
  yield buildAnsiPushEffect('bold green');
47
- } else if (currentType === 'NodeMatcher') {
51
+ } else if (currentType === Symbol.for('OpenNodeMatcher')) {
48
52
  yield buildAnsiPushEffect('bold orange');
49
53
  } else {
50
54
  yield buildAnsiPushEffect();
51
55
  }
52
- } else if (tagType === 'Pattern') {
56
+ } else if (
57
+ tagType === Symbol.for('Pattern') &&
58
+ tag.value.language !== 'https://bablr.org/languages/core/en/spamex'
59
+ ) {
53
60
  yield buildAnsiPushEffect('bold orange');
54
- } else if (tagType === 'EscapeSequence') {
61
+ } else if (tagType === Symbol.for('EscapeSequence')) {
55
62
  yield buildAnsiPushEffect('bold cyan');
56
- } else if (tagType === 'Identifier') {
57
- if (currentType === 'Reference') {
63
+ } else if (tagType === Symbol.for('Identifier')) {
64
+ if (currentType === Symbol.for('ReferenceTag')) {
58
65
  yield buildAnsiPushEffect('bold gray');
59
- } else if (currentType === 'Call') {
66
+ } else if (currentType === Symbol.for('Call')) {
60
67
  yield buildAnsiPushEffect('magenta bold');
61
68
  } else {
62
69
  yield buildAnsiPushEffect();
63
70
  }
64
- } else if (tagType === 'EnterProductionLine' || tagType === 'LeaveProductionLine') {
71
+ } else if (
72
+ tagType === Symbol.for('EnterProductionLine') ||
73
+ tagType === Symbol.for('LeaveProductionLine')
74
+ ) {
65
75
  yield buildAnsiPushEffect('blue bold');
66
76
  } else if (
67
77
  (currentRef?.name === 'sigilToken' &&
68
- (currentType === 'ExecSpamexInstructionLine' ||
69
- currentType === 'ExecCSTMLInstructionLine')) ||
70
- (currentType === 'Tuple' &&
78
+ (currentType === Symbol.for('ExecSpamexInstructionLine') ||
79
+ currentType === Symbol.for('ExecCSTMLInstructionLine'))) ||
80
+ (currentType === Symbol.for('Tuple') &&
71
81
  (currentRef.name === 'openToken' || currentRef.name === 'closeToken'))
72
82
  ) {
73
83
  yield buildAnsiPushEffect('magenta bold');
@@ -76,19 +86,19 @@ function* __higlightStrategy(context, tokens) {
76
86
  }
77
87
  }
78
88
 
79
- if (token.type === 'Reference') {
80
- currentRef = token.value;
89
+ if (tag.type === ReferenceTag) {
90
+ currentRef = tag.value;
81
91
  }
82
92
 
83
- if (token.type === 'CloseNodeTag') {
93
+ if (tag.type === CloseNodeTag) {
84
94
  types = types.pop();
85
95
  yield buildAnsiPopEffect();
86
96
  }
87
97
 
88
- if (token.type === 'Literal') {
89
- yield buildWriteEffect(token.value);
90
- } else if (token.type === 'OpenNodeTag' && token.value.intrinsicValue) {
91
- yield buildWriteEffect(token.value.intrinsicValue);
98
+ if (tag.type === LiteralTag) {
99
+ yield buildWriteEffect(tag.value);
100
+ } else if (tag.type === OpenNodeTag && tag.value.intrinsicValue) {
101
+ yield buildWriteEffect(tag.value.intrinsicValue);
92
102
  yield buildAnsiPopEffect();
93
103
  }
94
104
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@bablr/cli",
3
3
  "description": "CLI for running BABLR parsers",
4
- "version": "0.4.6",
4
+ "version": "0.5.0",
5
5
  "author": "Conrad Buck<conartist6@gmail.com>",
6
6
  "type": "module",
7
7
  "files": [
@@ -17,16 +17,16 @@
17
17
  },
18
18
  "sideEffects": false,
19
19
  "dependencies": {
20
- "@bablr/agast-helpers": "0.3.2",
21
- "@bablr/agast-vm-helpers": "0.3.2",
22
- "@bablr/io-vm-node": "0.3.0",
23
- "@bablr/boot": "0.4.0",
20
+ "@bablr/agast-helpers": "0.4.0",
21
+ "@bablr/agast-vm-helpers": "0.4.0",
22
+ "@bablr/io-vm-node": "0.4.0",
23
+ "@bablr/boot": "0.5.0",
24
24
  "@bablr/coroutine": "0.1.0",
25
- "@bablr/helpers": "0.18.2",
26
- "@bablr/language-en-cstml": "0.4.3",
27
- "@bablr/language-en-bablr-cli-verbose-output": "0.3.1",
25
+ "@bablr/helpers": "0.19.0",
26
+ "@bablr/language-en-cstml": "0.5.0",
27
+ "@bablr/language-en-bablr-cli-verbose-output": "0.4.0",
28
28
  "@iter-tools/imm-stack": "1.1.0",
29
- "bablr": "0.4.4",
29
+ "bablr": "0.5.0",
30
30
  "color-support": "1.1.3",
31
31
  "commander": "12.0.0"
32
32
  },