|
|
@ -59,6 +59,8 @@
|
|
|
|
(define hide-char #\/)
|
|
|
|
(define hide-char #\/)
|
|
|
|
(define splice-char #\@)
|
|
|
|
(define splice-char #\@)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(define id-separators-pattern "((:)|(::=))")
|
|
|
|
|
|
|
|
|
|
|
|
;; grammar-parser: (-> token) -> (listof rule)
|
|
|
|
;; grammar-parser: (-> token) -> (listof rule)
|
|
|
|
(define grammar-parser
|
|
|
|
(define grammar-parser
|
|
|
|
(parser
|
|
|
|
(parser
|
|
|
@ -84,7 +86,7 @@
|
|
|
|
[rule
|
|
|
|
[rule
|
|
|
|
[(RULE_HEAD pattern)
|
|
|
|
[(RULE_HEAD pattern)
|
|
|
|
(begin
|
|
|
|
(begin
|
|
|
|
(define trimmed (regexp-replace #px"\\s*:$" $1 ""))
|
|
|
|
(define trimmed (regexp-replace (pregexp (format "\\s*~a$" id-separators-pattern)) $1 ""))
|
|
|
|
(rule (position->pos $1-start-pos)
|
|
|
|
(rule (position->pos $1-start-pos)
|
|
|
|
(position->pos $2-end-pos)
|
|
|
|
(position->pos $2-end-pos)
|
|
|
|
(lhs-id (position->pos $1-start-pos)
|
|
|
|
(lhs-id (position->pos $1-start-pos)
|
|
|
@ -98,7 +100,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
[(RULE_HEAD_HIDDEN pattern) ; slash indicates hiding
|
|
|
|
[(RULE_HEAD_HIDDEN pattern) ; slash indicates hiding
|
|
|
|
(begin
|
|
|
|
(begin
|
|
|
|
(define trimmed (cadr (regexp-match (pregexp (format "~a(\\S+)\\s*:$" hide-char)) $1)))
|
|
|
|
(define trimmed (cadr (regexp-match (pregexp (format "~a(\\S+)\\s*~a$" hide-char id-separators-pattern)) $1)))
|
|
|
|
(rule (position->pos $1-start-pos)
|
|
|
|
(rule (position->pos $1-start-pos)
|
|
|
|
(position->pos $2-end-pos)
|
|
|
|
(position->pos $2-end-pos)
|
|
|
|
(lhs-id (position->pos $1-start-pos)
|
|
|
|
(lhs-id (position->pos $1-start-pos)
|
|
|
@ -113,7 +115,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
[(RULE_HEAD_SPLICED pattern) ; atsign indicates splicing
|
|
|
|
[(RULE_HEAD_SPLICED pattern) ; atsign indicates splicing
|
|
|
|
(begin
|
|
|
|
(begin
|
|
|
|
(define trimmed (cadr (regexp-match (pregexp (format "~a(\\S+)\\s*:$" splice-char)) $1)))
|
|
|
|
(define trimmed (cadr (regexp-match (pregexp (format "~a(\\S+)\\s*~a$" splice-char id-separators-pattern)) $1)))
|
|
|
|
(rule (position->pos $1-start-pos)
|
|
|
|
(rule (position->pos $1-start-pos)
|
|
|
|
(position->pos $2-end-pos)
|
|
|
|
(position->pos $2-end-pos)
|
|
|
|
(lhs-id (position->pos $1-start-pos)
|
|
|
|
(lhs-id (position->pos $1-start-pos)
|
|
|
|