@bablr/language-en-spamex 0.4.3 → 0.6.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.
@@ -1,9 +1,10 @@
1
1
  import { i } from '@bablr/boot/shorthand.macro';
2
- import { Node, CoveredBy, InjectFrom } from '@bablr/helpers/decorators';
2
+ import { Node, CoveredBy, InjectFrom, UnboundAttributes } from '@bablr/helpers/decorators';
3
3
  import * as productions from '@bablr/helpers/productions';
4
4
  import * as Regex from '@bablr/language-en-regex-vm-pattern';
5
5
  import * as CSTML from '@bablr/language-en-cstml';
6
6
  import * as Space from '@bablr/language-en-blank-space';
7
+ import { notNull } from '@bablr/agast-helpers/tree';
7
8
 
8
9
  export const canonicalURL = 'https://bablr.org/languages/core/en/spamex';
9
10
 
@@ -14,77 +15,111 @@ const { eatMatchTrivia } = CSTML;
14
15
  export const grammar = class SpamexGrammar {
15
16
  @CoveredBy('Expression')
16
17
  *Matcher() {
17
- yield i`eat(<Any> null [
18
- <NodeMatcher '<'>
19
- <CSTML:String /['"]/>
20
- <Regex:Pattern '/'>
18
+ yield i`eat(<Any /> null [
19
+ <NodeMatcher '<' />
20
+ <CSTML:String /['"]/ />
21
+ <Regex:Pattern '/' />
21
22
  ])`;
22
23
  }
23
24
 
24
- @CoveredBy('Matcher')
25
- @CoveredBy('Expression')
26
25
  @Node
26
+ @CoveredBy('Matcher')
27
27
  *NodeMatcher() {
28
- yield i`eat(<~*Punctuator '<' balancedSpan='Tag' balanced='>'> 'open')`;
29
- yield i`eat(<CSTML:Flags>)`;
30
- if (yield i`match(/[a-zA-Z]+:/)`) {
31
- yield i`eat(<*CSTML:Identifier> 'language')`;
32
- yield i`eat(<~*Punctuator ':'> 'namespaceOperator')`;
33
- yield i`eat(<*CSTML:Identifier> 'type')`;
28
+ let open = yield i`eat(<OpenNodeMatcher /> 'open')`;
29
+
30
+ const selfClosing = notNull(open.get('selfClosingTagToken'));
31
+
32
+ if (selfClosing) {
33
+ yield i`eat([] 'children[]$')`;
34
+ yield i`eat(null 'close')`;
34
35
  } else {
35
- yield i`eat(null 'language')`;
36
- yield i`eat(null 'namespaceOperator')`;
37
- yield i`eatMatch(<*CSTML:Identifier> 'type')`;
36
+ // TODO
37
+ yield* eatMatchTrivia();
38
+
39
+ yield i`eat(<CloseNodeMatcher /> 'close')`;
40
+ }
41
+ }
42
+
43
+ @Node
44
+ *OpenNodeMatcher() {
45
+ yield i`eat(<*Punctuator '<' balancedSpan='Tag' balanced='>' /> 'open')`;
46
+ yield i`eat(<CSTML:Flags /> 'flags')`;
47
+
48
+ if (yield i`eatMatch(<CSTML:TagType /[a-zA-Z'"\g]/ />)`) {
49
+ // continue
50
+ } else if (yield i`eatMatch(<*Punctuator /[ \t]+|?/ /> 'type$')`) {
51
+ // continue
38
52
  }
53
+
39
54
  let sp = yield* eatMatchTrivia();
40
55
 
41
- if (sp && (yield i`eatMatch(<StringMatcher> 'intrinsicValue')`)) {
56
+ if (
57
+ sp &&
58
+ !(yield i`match(/\/$/)`) &&
59
+ (yield i`eatMatch(<StringMatcher /> 'intrinsicValue$')`)
60
+ ) {
42
61
  sp = yield* eatMatchTrivia();
43
62
  }
44
63
 
45
64
  while (sp && (yield i`match(/!?[a-zA-Z]/)`)) {
46
- yield i`eat(<Attribute> 'attributes[]')`;
65
+ yield i`eat(<Attribute /> 'attributes[]')`;
47
66
  sp = yield* eatMatchTrivia();
48
67
  }
49
- yield i`eat(<~*Punctuator '>' balancer> 'close')`;
68
+
69
+ yield i`eatMatch(<*Punctuator '/' /> 'selfClosingTagToken')`;
70
+ yield i`eat(<*Punctuator '>' balancer /> 'close')`;
71
+ }
72
+
73
+ @Node
74
+ @CoveredBy('Matcher')
75
+ *CloseNodeMatcher() {
76
+ yield i`eat(<*Punctuator '</' balanced='>' /> 'openToken')`;
77
+ yield i`eatMatch(<TagType />)`;
78
+ yield i`eat(<*Punctuator '>' balancer /> 'closeToken')`;
50
79
  }
51
80
 
52
81
  *Attributes() {
53
- yield i`eatMatch(<List> null {
54
- element: <Attribute>
82
+ yield i`eatMatch(<List /> null {
83
+ element: <Attribute />
55
84
  allowTrailingSeparator: false
56
85
  })`;
57
86
  }
58
87
 
59
88
  *Attribute() {
60
89
  if (yield i`match(/[a-zA-Z]+\s*=/)`) {
61
- yield i`eat(<MappingAttribute>)`;
90
+ yield i`eat(<MappingAttribute />)`;
62
91
  } else {
63
- yield i`eat(<BooleanAttribute>)`;
92
+ yield i`eat(<BooleanAttribute />)`;
64
93
  }
65
94
  }
66
95
 
67
- @CoveredBy('Attribute')
96
+ @UnboundAttributes(['true'])
68
97
  @Node
98
+ @CoveredBy('Attribute')
69
99
  *BooleanAttribute() {
70
- yield i`eat(<*CSTML:Identifier> 'key')`;
100
+ if (yield i`eatMatch(<*Punctuator '!' /> 'negateToken')`) {
101
+ yield i`bindAttribute('true' false)`;
102
+ } else {
103
+ yield i`bindAttribute('true' true)`;
104
+ }
105
+ yield i`eat(<*CSTML:Identifier /> 'key$')`;
71
106
  }
72
107
 
73
108
  @CoveredBy('Attribute')
74
109
  @Node
75
110
  *MappingAttribute() {
76
- yield i`eat(<*CSTML:Identifier> 'key')`;
77
- yield i`eat(<~*Punctuator '='> 'mapOperator')`;
78
- yield i`eat(<CSTML:AttributeValue> 'value')`;
111
+ yield i`eat(<*CSTML:Identifier /> 'key$')`;
112
+ yield i`eat(<*Punctuator '=' /> 'mapOperator')`;
113
+ yield i`eat(<CSTML:AttributeValue /> 'value$')`;
79
114
  }
80
115
 
81
116
  @CoveredBy('Matcher')
82
117
  @CoveredBy('Expression')
83
118
  *StringMatcher() {
84
119
  if (yield i`match(/['"]/)`) {
85
- yield i`eat(<CSTML:String>)`;
120
+ yield i`eat(<CSTML:String />)`;
86
121
  } else {
87
- yield i`eat(<Regex:Pattern>)`;
122
+ yield i`eat(<Regex:Pattern />)`;
88
123
  }
89
124
  }
90
125
 
@@ -93,7 +128,7 @@ export const grammar = class SpamexGrammar {
93
128
  @CoveredBy('Expression')
94
129
  @Node
95
130
  *String() {
96
- yield i`eat(<CSTML:String>)`;
131
+ yield i`eat(<CSTML:String />)`;
97
132
  }
98
133
 
99
134
  @CoveredBy('StringMatcher')
@@ -101,10 +136,10 @@ export const grammar = class SpamexGrammar {
101
136
  @CoveredBy('Expression')
102
137
  @Node
103
138
  *Regex() {
104
- yield i`eat(<~*Punctuator '/' balanced='/'> 'open')`;
105
- yield i`eat(<Regex:Alternatives> 'alternatives[]')`;
106
- yield i`eat(<~*Punctuator '/' balancer> 'close')`;
107
- yield i`eat(<Regex:Flags> 'flags')`;
139
+ yield i`eat(<*Punctuator '/' balanced='/' /> 'open')`;
140
+ yield i`eat(<Regex:Alternatives /> 'alternatives[]$')`;
141
+ yield i`eat(<*Punctuator '/' balancer /> 'close')`;
142
+ yield i`eat(<Regex:Flags /> 'flags$')`;
108
143
  }
109
144
 
110
145
  @InjectFrom(productions)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bablr/language-en-spamex",
3
- "version": "0.4.3",
3
+ "version": "0.6.0",
4
4
  "description": "A BABLR language for SPAM Expressions",
5
5
  "engines": {
6
6
  "node": ">=12.0.0"
@@ -22,18 +22,18 @@
22
22
  },
23
23
  "dependencies": {
24
24
  "@babel/runtime": "^7.23.2",
25
- "@bablr/agast-helpers": "0.3.2",
26
- "@bablr/agast-vm-helpers": "0.3.2",
27
- "@bablr/helpers": "0.18.1",
28
- "@bablr/language-en-blank-space": "0.3.1",
29
- "@bablr/language-en-cstml": "0.4.3",
30
- "@bablr/language-en-regex-vm-pattern": "0.5.1"
25
+ "@bablr/agast-helpers": "^0.5.0",
26
+ "@bablr/agast-vm-helpers": "^0.5.0",
27
+ "@bablr/helpers": "^0.20.0",
28
+ "@bablr/language-en-blank-space": "^0.5.0",
29
+ "@bablr/language-en-cstml": "^0.6.0",
30
+ "@bablr/language-en-regex-vm-pattern": "^0.7.0"
31
31
  },
32
32
  "devDependencies": {
33
- "@bablr/boot": "0.4.0",
33
+ "@bablr/boot": "^0.6.0",
34
34
  "@bablr/eslint-config-base": "github:bablr-lang/eslint-config-base#49f5952efed27f94ee9b94340eb1563c440bf64e",
35
- "@bablr/macrome": "0.1.3",
36
- "@bablr/macrome-generator-bablr": "0.3.1",
35
+ "@bablr/macrome": "^0.1.3",
36
+ "@bablr/macrome-generator-bablr": "^0.3.2",
37
37
  "enhanced-resolve": "^5.12.0",
38
38
  "eslint": "^7.32.0",
39
39
  "eslint-import-resolver-enhanced-resolve": "^1.0.5",