diff --git a/mozilla/js/semantics/JS20/Lexer.lisp b/mozilla/js/semantics/JS20/Lexer.lisp index cb9cfd24c89..0480af07831 100644 --- a/mozilla/js/semantics/JS20/Lexer.lisp +++ b/mozilla/js/semantics/JS20/Lexer.lisp @@ -616,4 +616,5 @@ fjds*/y//z") (js-pmetaparse "3a+in'a+b\\040\\077\\700\\150\\15A\\69\"de'\"'\"") |# +#+allegro (clean-grammar *lg*) ;Remove this line if you wish to print the grammar's state tables. (length (grammar-states *lg*)) diff --git a/mozilla/js/semantics/JS20/Parser.lisp b/mozilla/js/semantics/JS20/Parser.lisp index cfca8f6ed2e..4745c3d1f90 100644 --- a/mozilla/js/semantics/JS20/Parser.lisp +++ b/mozilla/js/semantics/JS20/Parser.lisp @@ -605,6 +605,9 @@ ; A list of terminals that may precede a / or /= terminal; ; The intersection of the $regular-expression and /|/= lists. ; The intersection of the $regular-expression|$virtual-semicolon and /|/= lists. +; +; USE ONLY ON canonical-lr-1 grammars. +; DON'T RUN THIS AFTER CALLING forward-parser-states. (defun show-regexp-and-division-predecessors (grammar) (let* ((nstates (length (grammar-states grammar))) (state-predecessors (make-array nstates :element-type 'terminalset :initial-element *empty-terminalset*))) @@ -619,12 +622,13 @@ (div-predecessors *empty-terminalset*)) (all-state-transitions #'(lambda (state transitions-hash) - (when (gethash '$regular-expression transitions-hash) - (terminalset-union-f regexp-predecessors (svref state-predecessors (state-number state)))) - (if (or (gethash '/ transitions-hash) (gethash '/= transitions-hash)) - (terminalset-union-f div-predecessors (svref state-predecessors (state-number state))) - (when (gethash '$virtual-semicolon transitions-hash) - (terminalset-union-f virtual-predecessors (svref state-predecessors (state-number state)))))) + (let ((predecessors (svref state-predecessors (state-number state)))) + (when (gethash '$regular-expression transitions-hash) + (terminalset-union-f regexp-predecessors predecessors)) + (if (or (gethash '/ transitions-hash) (gethash '/= transitions-hash)) + (terminalset-union-f div-predecessors predecessors) + (when (gethash '$virtual-semicolon transitions-hash) + (terminalset-union-f virtual-predecessors predecessors))))) grammar) (values (terminalset-list grammar regexp-predecessors) @@ -697,4 +701,6 @@ |# (ensure-lf-subset *jg*) +(forward-parser-states *jg*) +#+allegro (clean-grammar *jg*) ;Remove this line if you wish to print the grammar's state tables. (length (grammar-states *jg*)) diff --git a/mozilla/js/semantics/JS20/RegExp.lisp b/mozilla/js/semantics/JS20/RegExp.lisp index a5e4a642b85..d2ad77f3ce2 100644 --- a/mozilla/js/semantics/JS20/RegExp.lisp +++ b/mozilla/js/semantics/JS20/RegExp.lisp @@ -634,4 +634,5 @@ (run-regexp "(aa|aabaac|ba|b|c)*" "aabaac") |# +#+allegro (clean-grammar *rg*) ;Remove this line if you wish to print the grammar's state tables. (length (grammar-states *rg*)) diff --git a/mozilla/js2/semantics/JS20/Lexer.lisp b/mozilla/js2/semantics/JS20/Lexer.lisp index cb9cfd24c89..0480af07831 100644 --- a/mozilla/js2/semantics/JS20/Lexer.lisp +++ b/mozilla/js2/semantics/JS20/Lexer.lisp @@ -616,4 +616,5 @@ fjds*/y//z") (js-pmetaparse "3a+in'a+b\\040\\077\\700\\150\\15A\\69\"de'\"'\"") |# +#+allegro (clean-grammar *lg*) ;Remove this line if you wish to print the grammar's state tables. (length (grammar-states *lg*)) diff --git a/mozilla/js2/semantics/JS20/Parser.lisp b/mozilla/js2/semantics/JS20/Parser.lisp index cfca8f6ed2e..4745c3d1f90 100644 --- a/mozilla/js2/semantics/JS20/Parser.lisp +++ b/mozilla/js2/semantics/JS20/Parser.lisp @@ -605,6 +605,9 @@ ; A list of terminals that may precede a / or /= terminal; ; The intersection of the $regular-expression and /|/= lists. ; The intersection of the $regular-expression|$virtual-semicolon and /|/= lists. +; +; USE ONLY ON canonical-lr-1 grammars. +; DON'T RUN THIS AFTER CALLING forward-parser-states. (defun show-regexp-and-division-predecessors (grammar) (let* ((nstates (length (grammar-states grammar))) (state-predecessors (make-array nstates :element-type 'terminalset :initial-element *empty-terminalset*))) @@ -619,12 +622,13 @@ (div-predecessors *empty-terminalset*)) (all-state-transitions #'(lambda (state transitions-hash) - (when (gethash '$regular-expression transitions-hash) - (terminalset-union-f regexp-predecessors (svref state-predecessors (state-number state)))) - (if (or (gethash '/ transitions-hash) (gethash '/= transitions-hash)) - (terminalset-union-f div-predecessors (svref state-predecessors (state-number state))) - (when (gethash '$virtual-semicolon transitions-hash) - (terminalset-union-f virtual-predecessors (svref state-predecessors (state-number state)))))) + (let ((predecessors (svref state-predecessors (state-number state)))) + (when (gethash '$regular-expression transitions-hash) + (terminalset-union-f regexp-predecessors predecessors)) + (if (or (gethash '/ transitions-hash) (gethash '/= transitions-hash)) + (terminalset-union-f div-predecessors predecessors) + (when (gethash '$virtual-semicolon transitions-hash) + (terminalset-union-f virtual-predecessors predecessors))))) grammar) (values (terminalset-list grammar regexp-predecessors) @@ -697,4 +701,6 @@ |# (ensure-lf-subset *jg*) +(forward-parser-states *jg*) +#+allegro (clean-grammar *jg*) ;Remove this line if you wish to print the grammar's state tables. (length (grammar-states *jg*)) diff --git a/mozilla/js2/semantics/JS20/RegExp.lisp b/mozilla/js2/semantics/JS20/RegExp.lisp index a5e4a642b85..d2ad77f3ce2 100644 --- a/mozilla/js2/semantics/JS20/RegExp.lisp +++ b/mozilla/js2/semantics/JS20/RegExp.lisp @@ -634,4 +634,5 @@ (run-regexp "(aa|aabaac|ba|b|c)*" "aabaac") |# +#+allegro (clean-grammar *rg*) ;Remove this line if you wish to print the grammar's state tables. (length (grammar-states *rg*))