Reorganize imports and exports of `grammar.rkt`

remotes/jackfirth/master
Jack Firth 3 years ago
parent b5d3b102f8
commit 39505951ea

@ -6,31 +6,6 @@
yaragg/parser-tools/private-yacc/yacc-helper
racket/contract)
;; Each production has a unique index 0 <= index <= number of productions
(struct prod (lhs rhs index prec action) #:mutable)
;; The dot-pos field is the index of the element in the rhs
;; of prod that the dot immediately precedes.
;; Thus 0 <= dot-pos <= (vector-length rhs).
(struct item (prod dot-pos) #:transparent)
;; gram-sym = (union term? non-term?)
;; Each term has a unique index 0 <= index < number of terms
;; Each non-term has a unique index 0 <= index < number of non-terms
(struct term (sym index prec) #:mutable)
(struct non-term (sym index) #:mutable)
;; a precedence declaration.
(struct prec (num assoc) #:transparent)
(provide/contract
[item (prod? (or/c #f natural-number/c) . -> . item?)]
[term (symbol? (or/c #f natural-number/c) (or/c prec? #f) . -> . term?)]
[non-term (symbol? (or/c #f natural-number/c) . -> . non-term?)]
[prec (natural-number/c (or/c 'left 'right 'nonassoc) . -> . prec?)]
[prod (non-term? (vectorof (or/c non-term? term?))
(or/c #f natural-number/c) (or/c #f prec?) syntax? . -> . prod?)])
(provide
;; Things that work on items
start-item? item-prod item->string
@ -47,8 +22,32 @@
grammar%
;; Things that work on productions
prod-index prod-prec prod-rhs prod-lhs prod-action)
prod-index prod-prec prod-rhs prod-lhs prod-action
(contract-out
[item (prod? (or/c #f natural-number/c) . -> . item?)]
[term (symbol? (or/c #f natural-number/c) (or/c prec? #f) . -> . term?)]
[non-term (symbol? (or/c #f natural-number/c) . -> . non-term?)]
[prec (natural-number/c (or/c 'left 'right 'nonassoc) . -> . prec?)]
[prod (non-term? (vectorof (or/c non-term? term?))
(or/c #f natural-number/c) (or/c #f prec?) syntax? . -> . prod?)]))
;; Each production has a unique index 0 <= index <= number of productions
(struct prod (lhs rhs index prec action) #:mutable)
;; The dot-pos field is the index of the element in the rhs
;; of prod that the dot immediately precedes.
;; Thus 0 <= dot-pos <= (vector-length rhs).
(struct item (prod dot-pos) #:transparent)
;; gram-sym = (union term? non-term?)
;; Each term has a unique index 0 <= index < number of terms
;; Each non-term has a unique index 0 <= index < number of non-terms
(struct term (sym index prec) #:mutable)
(struct non-term (sym index) #:mutable)
;; a precedence declaration.
(struct prec (num assoc) #:transparent)
;;---------------------- LR items --------------------------

Loading…
Cancel
Save