Skip to content

Commit 1f1ee83

Browse files
simplify left recursion check a little; add a note
1 parent 0a3addf commit 1f1ee83

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

tests/dsls/peg/private/leftrec-check.rkt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,14 @@
4747
(nullable? #'e)]
4848
[_ (raise-syntax-error #f "not a core peg form" this-syntax)]))
4949

50+
;; MB note: I thought it might be a problem to raise an error when reaching a previously
51+
;; entered nt, because we might record it as entered when checking one nonterminal and then
52+
;; enter it again for another. But it's okay because if we check it successfully, then it's in
53+
;; def-nullable? and we get 'nullable or 'not-nullable instead.
5054
(define (nullable-nonterminal? id)
51-
(case (or (symbol-table-ref def-nullable? id (lambda () #f)) (symbol-table-ref entered id (lambda () #f)) 'unvisited)
55+
(case (or (symbol-table-ref def-nullable? id #f)
56+
(symbol-table-ref entered id #f)
57+
'unvisited)
5258
[(nullable) #t]
5359
[(not-nullable) #f]
5460
[(entered) (raise-syntax-error #f "left recursion through nonterminal" id)]

0 commit comments

Comments
 (0)