-
Notifications
You must be signed in to change notification settings - Fork 24
Expand file tree
/
Copy pathgrammar.go
More file actions
615 lines (563 loc) · 17.3 KB
/
grammar.go
File metadata and controls
615 lines (563 loc) · 17.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
package jsonic
// buildGrammar populates the default jsonic grammar rules using declarative GrammarAltSpec.
// This is a faithful port of grammar.ts, matching the exact alternate orderings
// produced by the JSON phase followed by the Jsonic extension phase.
func buildGrammar(rsm map[string]*RuleSpec, cfg *LexConfig) {
// Named function references for the grammar.
// These closures capture cfg for runtime configuration access.
ref := map[FuncRef]any{
"@finish": AltError(func(r *Rule, ctx *Context) *Token {
if !cfg.FinishRule {
return ctx.T0
}
return nil
}),
"@pairkey": AltAction(func(r *Rule, ctx *Context) {
_ = ctx
keyToken := r.O0
var key string
if keyToken.Tin == TinST || keyToken.Tin == TinTX {
key, _ = keyToken.Val.(string)
} else {
key = keyToken.Src
}
r.U["key"] = key
}),
"@pairval": AltAction(func(r *Rule, ctx *Context) {
key, _ := r.U["key"].(string)
val := r.Child.Node
if IsUndefined(val) {
val = nil
}
if cfg.SafeKey && r.U["list"] == true {
if key == "__proto__" || key == "constructor" {
return
}
}
// Drop keys that match the info marker to preserve metadata.
if cfg.InfoMarker != "" && key == cfg.InfoMarker {
return
}
prev := r.U["prev"]
if prev == nil {
nodeMapSet(r.Node, key, val)
} else if cfg.MapMerge != nil {
nodeMapSet(r.Node, key, cfg.MapMerge(prev, val, r, ctx))
} else if cfg.MapExtend {
nodeMapSet(r.Node, key, Deep(prev, val))
} else {
nodeMapSet(r.Node, key, val)
}
}),
// val rule state actions
"@val-bo": StateAction(func(r *Rule, ctx *Context) {
_ = ctx
r.Node = Undefined
}),
"@val-bc": StateAction(func(r *Rule, ctx *Context) {
_ = ctx
if IsUndefined(r.Node) {
if IsUndefined(r.Child.Node) {
if r.OS == 0 {
r.Node = Undefined
} else {
val := r.O0.ResolveVal()
// A nil value from a non-value token (e.g. #CS, #CB)
// means "no value", not "null". Keep Undefined to match
// TS where resolveVal returns undefined for such tokens.
if val == nil && r.O0.Tin != TinVL {
r.Node = Undefined
} else {
if cfg.TextInfo && (r.O0.Tin == TinST || r.O0.Tin == TinTX) {
quote := ""
if r.O0.Tin == TinST && len(r.O0.Src) > 0 {
quote = string(r.O0.Src[0])
}
str, _ := val.(string)
val = Text{Quote: quote, Str: str}
}
r.Node = val
}
}
} else {
r.Node = r.Child.Node
}
}
}),
// map rule state actions
"@map-bo": StateAction(func(r *Rule, ctx *Context) {
_ = ctx
if cfg.MapRef {
r.Node = MapRef{
Val: make(map[string]any),
Meta: make(map[string]any),
}
} else {
r.Node = make(map[string]any)
}
}),
"@map-bo-jsonic": StateAction(func(r *Rule, ctx *Context) {
_ = ctx
if v, ok := r.N["dmap"]; ok {
r.N["dmap"] = v + 1
} else {
r.N["dmap"] = 1
}
}),
"@map-bc": StateAction(func(r *Rule, ctx *Context) {
_ = ctx
if cfg.MapRef {
implicit := !(r.O0 != NoToken && r.O0.Tin == TinOB)
if mr, ok := r.Node.(MapRef); ok {
mr.Implicit = implicit
r.Node = mr
}
}
}),
// list rule state actions
"@list-bo": StateAction(func(r *Rule, ctx *Context) {
_ = ctx
if cfg.ListRef {
r.Node = ListRef{
Val: make([]any, 0),
Meta: make(map[string]any),
}
} else {
r.Node = make([]any, 0)
}
}),
"@list-bo-jsonic": StateAction(func(r *Rule, ctx *Context) {
_ = ctx
if v, ok := r.N["dlist"]; ok {
r.N["dlist"] = v + 1
} else {
r.N["dlist"] = 1
}
if r.Prev != NoRule && r.Prev != nil {
if implist, ok := r.Prev.U["implist"]; ok && implist == true {
prevNode := r.Prev.Node
if IsUndefined(prevNode) {
prevNode = nil
}
r.Node = nodeListAppend(r.Node, prevNode)
r.Prev.Node = r.Node
}
}
}),
"@list-bc": StateAction(func(r *Rule, ctx *Context) {
_ = ctx
if cfg.ListRef {
implicit := !(r.O0 != NoToken && r.O0.Tin == TinOS)
if lr, ok := r.Node.(ListRef); ok {
lr.Implicit = implicit
if c, ok := r.U["child$"]; ok {
lr.Child = c
}
r.Node = lr
}
}
}),
// pair rule state actions
"@pair-bc-json": StateAction(func(r *Rule, ctx *Context) {
if _, ok := r.U["pair"]; ok {
key, _ := r.U["key"].(string)
if cfg.SafeKey && r.U["list"] == true && (key == "__proto__" || key == "constructor") {
return
}
// Drop keys that match the info marker to preserve metadata.
if cfg.InfoMarker != "" && key == cfg.InfoMarker {
return
}
r.U["prev"] = nodeMapGetVal(r.Node, r.U["key"])
nodeMapSet(r.Node, key, r.Child.Node)
}
}),
"@pair-bc-jsonic": StateAction(func(r *Rule, ctx *Context) {
if _, ok := r.U["pair"]; ok {
key, _ := r.U["key"].(string)
val := r.Child.Node
if IsUndefined(val) {
val = nil
}
if cfg.SafeKey && r.U["list"] == true {
if key == "__proto__" || key == "constructor" {
return
}
}
// Drop keys that match the info marker to preserve metadata.
if cfg.InfoMarker != "" && key == cfg.InfoMarker {
return
}
prev := r.U["prev"]
if prev == nil {
nodeMapSet(r.Node, key, val)
} else if cfg.MapMerge != nil {
nodeMapSet(r.Node, key, cfg.MapMerge(prev, val, r, ctx))
} else if cfg.MapExtend {
nodeMapSet(r.Node, key, Deep(prev, val))
} else {
nodeMapSet(r.Node, key, val)
}
}
}),
"@pair-bc-child": StateAction(func(r *Rule, ctx *Context) {
if childFlag, ok := r.U["child"]; !ok || childFlag != true {
return
}
val := r.Child.Node
if IsUndefined(val) {
val = nil
}
prev, hasPrev := nodeMapGet(r.Node, "child$")
if !hasPrev {
nodeMapSet(r.Node, "child$", val)
} else if cfg.MapMerge != nil {
nodeMapSet(r.Node, "child$", cfg.MapMerge(prev, val, r, ctx))
} else if cfg.MapExtend {
nodeMapSet(r.Node, "child$", Deep(prev, val))
} else {
nodeMapSet(r.Node, "child$", val)
}
}),
// elem rule state actions
"@elem-bc-json": StateAction(func(r *Rule, ctx *Context) {
_ = ctx
done, _ := r.U["done"].(bool)
if !done && !IsUndefined(r.Child.Node) {
if _, ok := nodeListVal(r.Node); ok {
r.Node = nodeListAppend(r.Node, r.Child.Node)
if r.Parent != NoRule && r.Parent != nil {
r.Parent.Node = r.Node
}
}
}
}),
"@elem-bc-pair": StateAction(func(r *Rule, ctx *Context) {
if pair, ok := r.U["pair"]; !ok || pair != true {
return
}
if cfg.ListPair {
key := r.U["key"].(string)
val := r.Child.Node
if IsUndefined(val) {
val = nil
}
pairObj := map[string]any{key: val}
if _, ok := nodeListVal(r.Node); ok {
r.Node = nodeListAppend(r.Node, pairObj)
if r.Parent != NoRule && r.Parent != nil {
r.Parent.Node = r.Node
}
}
} else {
r.U["prev"] = nodeMapGetVal(r.Node, r.U["key"])
key, _ := r.U["key"].(string)
val := r.Child.Node
if IsUndefined(val) {
val = nil
}
if cfg.SafeKey && r.U["list"] == true {
if key == "__proto__" || key == "constructor" {
return
}
}
// Drop keys that match the info marker to preserve metadata.
if cfg.InfoMarker != "" && key == cfg.InfoMarker {
return
}
prev := r.U["prev"]
if prev == nil {
nodeMapSet(r.Node, key, val)
} else if cfg.MapMerge != nil {
nodeMapSet(r.Node, key, cfg.MapMerge(prev, val, r, ctx))
} else if cfg.MapExtend {
nodeMapSet(r.Node, key, Deep(prev, val))
} else {
nodeMapSet(r.Node, key, val)
}
}
}),
"@elem-bc-child": StateAction(func(r *Rule, ctx *Context) {
_ = ctx
if childFlag, ok := r.U["child"]; !ok || childFlag != true {
return
}
val := r.Child.Node
if IsUndefined(val) {
val = nil
}
if r.Parent != NoRule && r.Parent != nil {
prev, hasPrev := r.Parent.U["child$"]
if !hasPrev {
r.Parent.U["child$"] = val
} else if cfg.MapExtend {
r.Parent.U["child$"] = Deep(prev, val)
} else {
r.Parent.U["child$"] = val
}
}
}),
// Inline actions used in alts
"@val-close-err": AltError(func(r *Rule, ctx *Context) *Token {
if r.D == 0 {
return ctx.T0
}
return nil
}),
"@implist-cond": AltCond(func(r *Rule, ctx *Context) bool {
return r.Prev != NoRule && r.Prev != nil && r.Prev.U["implist"] == true
}),
"@elem-double-comma": AltAction(func(r *Rule, ctx *Context) {
_ = ctx
if _, ok := nodeListVal(r.Node); ok {
r.Node = nodeListAppend(r.Node, nil)
if r.Parent != NoRule && r.Parent != nil {
r.Parent.Node = r.Node
}
}
}),
"@elem-single-comma": AltAction(func(r *Rule, ctx *Context) {
_ = ctx
if _, ok := nodeListVal(r.Node); ok {
r.Node = nodeListAppend(r.Node, nil)
if r.Parent != NoRule && r.Parent != nil {
r.Parent.Node = r.Node
}
}
}),
"@elem-pair-err": AltError(func(r *Rule, ctx *Context) *Token {
if cfg.ListProperty || cfg.ListPair {
return nil
}
return ctx.T0
}),
"@elem-close-err": AltError(func(r *Rule, ctx *Context) *Token {
return r.C0
}),
}
// Helper to resolve a GrammarAltSpec slice to []*AltSpec.
resolve := func(gas []*GrammarAltSpec) []*AltSpec {
alts := make([]*AltSpec, len(gas))
for i, ga := range gas {
alts[i] = resolveGrammarAltStatic(ga, ref)
}
return alts
}
// ====== VAL rule ======
valSpec := &RuleSpec{Name: "val"}
valSpec.BO = []StateAction{ref["@val-bo"].(StateAction)}
valSpec.BC = []StateAction{ref["@val-bc"].(StateAction)}
valOpen := resolve([]*GrammarAltSpec{
{S: "#OB", P: "map", B: 1, G: "map,json"},
{S: "#OS", P: "list", B: 1, G: "list,json"},
{S: "#KEY #CL", C: map[string]any{"d": 0}, P: "map", B: 2, G: "pair,jsonic,top"},
{S: "#KEY #CL", P: "map", B: 2, N: map[string]int{"pk": 1}, G: "pair,jsonic"},
{S: "#VAL", G: "val,json"},
})
// CB|CS in single slot:
valOpen = append(valOpen, resolveGrammarAltStatic(
&GrammarAltSpec{S: []string{"#CB #CS"}, C: map[string]any{"d": CGt(0)}, B: 1, G: "val,imp,null,jsonic"}, ref))
valOpen = append(valOpen, resolve([]*GrammarAltSpec{
{S: "#CA", C: map[string]any{"d": 0}, P: "list", B: 1, G: "list,imp,jsonic"},
{S: "#CA", B: 1, G: "list,val,imp,null,jsonic"},
{S: "#ZZ", G: "jsonic"},
})...)
valSpec.Open = valOpen
valClose := resolve([]*GrammarAltSpec{
{S: "#ZZ", G: "end,json"},
})
// CB|CS in single slot:
valClose = append(valClose, resolveGrammarAltStatic(
&GrammarAltSpec{S: []string{"#CB #CS"}, B: 1, E: "@val-close-err", G: "val,json,close"}, ref))
valClose = append(valClose, resolve([]*GrammarAltSpec{
{S: "#CA", C: map[string]any{"n.dlist": CLte(0), "n.dmap": CLte(0)},
R: "list", U: map[string]any{"implist": true}, G: "list,val,imp,comma,jsonic"},
{C: map[string]any{"n.dlist": CLte(0), "n.dmap": CLte(0)},
R: "list", U: map[string]any{"implist": true}, B: 1, G: "list,val,imp,space,jsonic"},
{S: "#ZZ", G: "jsonic"},
{B: 1, G: "more,json"},
})...)
valSpec.Close = valClose
// ====== MAP rule ======
mapSpec := &RuleSpec{Name: "map"}
mapSpec.BO = []StateAction{
ref["@map-bo"].(StateAction),
ref["@map-bo-jsonic"].(StateAction),
}
mapSpec.BC = []StateAction{ref["@map-bc"].(StateAction)}
mapSpec.Open = resolve([]*GrammarAltSpec{
{S: "#OB #ZZ", B: 1, E: "@finish", G: "end,jsonic"},
{S: "#OB #CB", B: 1, N: map[string]int{"pk": 0}, G: "map,json"},
{S: "#OB", P: "pair", N: map[string]int{"pk": 0}, G: "map,json,pair"},
{S: "#KEY #CL", P: "pair", B: 2, G: "pair,list,val,imp,jsonic"},
})
// For map.Close, we need to merge token sets for the third alt.
// "#CA #CS" + VAL tokens in a single slot → need raw AltSpec for that one.
mapClose := resolve([]*GrammarAltSpec{
{S: "#CB", C: map[string]any{"n.pk": CLte(0)}, G: "end,json"},
{S: "#CB", B: 1, G: "path,jsonic"},
// slot 0 = merge(CA, CS, VAL) — handled below
})
// Third alt: CA|CS|VAL tokens in single slot
mapClose = append(mapClose, resolveGrammarAltStatic(
&GrammarAltSpec{S: []string{"#CA #CS #VAL"}, B: 1, G: "end,path,jsonic"}, ref))
mapClose = append(mapClose, resolveGrammarAltStatic(
&GrammarAltSpec{S: "#ZZ", E: "@finish", G: "end,jsonic"}, ref))
mapSpec.Close = mapClose
// ====== LIST rule ======
listSpec := &RuleSpec{Name: "list"}
listSpec.BO = []StateAction{
ref["@list-bo"].(StateAction),
ref["@list-bo-jsonic"].(StateAction),
}
listSpec.BC = []StateAction{ref["@list-bc"].(StateAction)}
// First alt uses a condition function directly (not declarative).
listOpen := []*AltSpec{
resolveGrammarAltStatic(&GrammarAltSpec{C: "@implist-cond", P: "elem"}, ref),
}
listOpen = append(listOpen, resolve([]*GrammarAltSpec{
{S: "#OS #CS", B: 1, G: "list,json"},
{S: "#OS", P: "elem", G: "list,elem,json"},
{S: "#CA", P: "elem", B: 1, G: "list,elem,val,imp,jsonic"},
{P: "elem", G: "list,elem,jsonic"},
})...)
listSpec.Open = listOpen
listSpec.Close = resolve([]*GrammarAltSpec{
{S: "#CS", G: "end,json"},
{S: "#ZZ", E: "@finish", G: "end,jsonic"},
})
// ====== PAIR rule ======
pairSpec := &RuleSpec{Name: "pair"}
pairSpec.BC = []StateAction{
ref["@pair-bc-json"].(StateAction),
ref["@pair-bc-jsonic"].(StateAction),
ref["@pair-bc-child"].(StateAction),
}
pairOpen := resolve([]*GrammarAltSpec{
{S: "#KEY #CL", P: "val", U: map[string]any{"pair": true}, A: "@pairkey", G: "map,pair,key,json"},
{S: "#CA", G: "map,pair,comma,jsonic"},
})
if cfg.MapChild {
pairOpen = append(pairOpen, resolveGrammarAltStatic(
&GrammarAltSpec{S: "#CL", P: "val",
U: map[string]any{"done": true, "child": true}}, ref))
}
pairSpec.Open = pairOpen
pairSpec.Close = resolve([]*GrammarAltSpec{
{S: "#CB", C: map[string]any{"n.pk": CLte(0)}, B: 1, G: "map,pair,json"},
{S: "#CA #CB", C: map[string]any{"n.pk": CLte(0)}, B: 1, G: "map,pair,comma,jsonic"},
{S: "#CA #ZZ", G: "end,jsonic"},
{S: "#CA", C: map[string]any{"n.pk": CLte(0)}, R: "pair", G: "map,pair,json"},
{S: "#CA", C: map[string]any{"n.dmap": CLte(1)}, R: "pair", G: "map,pair,jsonic"},
{S: "#KEY", C: map[string]any{"n.dmap": CLte(1)}, R: "pair", B: 1, G: "map,pair,imp,jsonic"},
})
// CB|CA|CS|KEY in single slot
pairSpec.Close = append(pairSpec.Close, resolveGrammarAltStatic(
&GrammarAltSpec{S: []string{"#CB #CA #CS #KEY"}, C: map[string]any{"n.pk": CGt(0)},
B: 1, G: "map,pair,imp,path,jsonic"}, ref))
// Remaining pair close alts.
pairSpec.Close = append(pairSpec.Close, resolve([]*GrammarAltSpec{
{S: "#CS", E: "@elem-close-err", G: "end,jsonic"},
{S: "#ZZ", E: "@finish", G: "map,pair,json"},
{R: "pair", B: 1, G: "map,pair,imp,jsonic"},
})...)
// ====== ELEM rule ======
elemSpec := &RuleSpec{Name: "elem"}
elemSpec.BC = []StateAction{
ref["@elem-bc-json"].(StateAction),
ref["@elem-bc-pair"].(StateAction),
ref["@elem-bc-child"].(StateAction),
}
elemOpen := resolve([]*GrammarAltSpec{
{S: "#CA #CA", B: 2, U: map[string]any{"done": true}, A: "@elem-double-comma",
G: "list,elem,imp,null,jsonic"},
{S: "#CA", U: map[string]any{"done": true}, A: "@elem-single-comma",
G: "list,elem,imp,null,jsonic"},
{S: "#KEY #CL", P: "val",
N: map[string]int{"pk": 1, "dmap": 1},
U: map[string]any{"done": true, "pair": true, "list": true},
A: "@pairkey", E: "@elem-pair-err", G: "elem,pair,jsonic"},
})
if cfg.ListChild {
elemOpen = append(elemOpen, resolveGrammarAltStatic(
&GrammarAltSpec{S: "#CL", P: "val",
U: map[string]any{"done": true, "child": true, "list": true},
G: "elem,child,jsonic"}, ref))
}
elemOpen = append(elemOpen, resolveGrammarAltStatic(
&GrammarAltSpec{P: "val", G: "list,elem,val,json"}, ref))
elemSpec.Open = elemOpen
elemClose := []*AltSpec{
// CA in slot 0, CS|ZZ in slot 1:
resolveGrammarAltStatic(&GrammarAltSpec{S: []string{"#CA", "#CS #ZZ"}, B: 1, G: "list,elem,comma,jsonic"}, ref),
}
elemClose = append(elemClose, resolve([]*GrammarAltSpec{
{S: "#CA", R: "elem", G: "list,elem,json"},
{S: "#CS", B: 1, G: "list,elem,json"},
{S: "#ZZ", E: "@finish", G: "list,elem,json"},
{S: "#CB", E: "@elem-close-err", G: "end,jsonic"},
{R: "elem", B: 1, G: "list,elem,imp,jsonic"},
})...)
elemSpec.Close = elemClose
rsm["val"] = valSpec
rsm["map"] = mapSpec
rsm["list"] = listSpec
rsm["pair"] = pairSpec
rsm["elem"] = elemSpec
}
// nodeListAppend appends a value to a list node (plain []any or ListRef).
func nodeListAppend(node any, val any) any {
if lr, ok := node.(ListRef); ok {
lr.Val = append(lr.Val, val)
return lr
}
if arr, ok := node.([]any); ok {
return append(arr, val)
}
return node
}
// nodeListVal extracts the []any from a list node.
func nodeListVal(node any) ([]any, bool) {
if lr, ok := node.(ListRef); ok {
return lr.Val, true
}
if arr, ok := node.([]any); ok {
return arr, true
}
return nil, false
}
// nodeListSetVal updates the []any inside a list node.
func nodeListSetVal(node any, arr []any) any {
if lr, ok := node.(ListRef); ok {
lr.Val = arr
return lr
}
return arr
}
// nodeMapSet sets a key on a map node.
func nodeMapSet(node any, key any, val any) {
k, _ := key.(string)
if m, ok := node.(map[string]any); ok {
m[k] = val
} else if mr, ok := node.(MapRef); ok {
mr.Val[k] = val
}
}
// nodeMapGet gets a value from a map node.
func nodeMapGet(node any, key any) (any, bool) {
k, _ := key.(string)
if m, ok := node.(map[string]any); ok {
v, exists := m[k]
return v, exists
}
if mr, ok := node.(MapRef); ok {
v, exists := mr.Val[k]
return v, exists
}
return nil, false
}
// nodeMapGetVal returns the value or nil.
func nodeMapGetVal(node any, key any) any {
v, _ := nodeMapGet(node, key)
return v
}