File tree 2 files changed +230
-43
lines changed
2 files changed +230
-43
lines changed Original file line number Diff line number Diff line change 10
10
(define (prod-link grammar name)
11
11
(elemref (prod-tag grammar name) (prod-ref name)))
12
12
13
+ (define grammar-prod-counts (make-hash))
14
+ (define (get-next-grammar-prod-tag grammar prod-name)
15
+ (define grammar-prod (hash-ref! grammar-prod-counts grammar make-hash))
16
+ (define prod-num (+ 1 (hash-ref grammar-prod prod-name 0 )))
17
+ (hash-set! grammar-prod prod-name prod-num)
18
+ (if (= prod-num 1 )
19
+ (prod-tag grammar prod-name)
20
+ (prod-tag grammar (format "~a@~a " prod-name prod-num))))
21
+
13
22
14
23
(define (render grammar parsed)
15
24
(define-values (constants prods) (partition constant? parsed))
58
67
(define tok (assoc (pattern-token-val p) names))
59
68
(cond
60
69
[tok (lit (second tok))]
70
+ [(string=? (pattern-token-val p) "... " ) (meta "... " )]
61
71
[else (unknown-lit (pattern-token-val p))])]
62
72
[(pattern-lit? p)
63
73
(lit (pattern-lit-val p))]
72
82
(add-between
73
83
(for/list [(p prods)]
74
84
(parameterize ([rule-name (lhs-id-val (rule-lhs p))])
75
- (list (elemtag (prod-tag grammar (rule-name))
85
+ (list (elemtag (get-next-grammar- prod-tag grammar (rule-name))
76
86
(elem (prod-ref (rule-name))
77
87
#:style (make-style #f (list (attributes '((class . "bnf-rule " )))))))
78
88
(meta ": " )
You can’t perform that action at this time.
0 commit comments