[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/parser-generator d397a1d48e 12/82: Improved variable na
From: |
Christian Johansson |
Subject: |
[elpa] externals/parser-generator d397a1d48e 12/82: Improved variable naming |
Date: |
Thu, 12 May 2022 13:28:13 -0400 (EDT) |
branch: externals/parser-generator
commit d397a1d48e1cc21b0b53f40d66adc236123a4f93
Author: Christian Johansson <christian@cvj.se>
Commit: Christian Johansson <christian@cvj.se>
Improved variable naming
---
parser-generator-ll.el | 50 +++++++++++++++++++-------------------------------
1 file changed, 19 insertions(+), 31 deletions(-)
diff --git a/parser-generator-ll.el b/parser-generator-ll.el
index 4cb6f5e268..c0628e31a8 100644
--- a/parser-generator-ll.el
+++ b/parser-generator-ll.el
@@ -58,15 +58,11 @@
(let* ((start (parser-generator--get-grammar-start))
(start-rhss (parser-generator--get-grammar-rhs start)))
(dolist (start-rhs start-rhss)
- (let* ((production (list (list start) start-rhs))
- (production-number
- (parser-generator--get-grammar-production-number
- production)))
+ (let* ((production (list (list start) start-rhs)))
(push
(list
(list start)
start-rhs
- production-number
nil)
stack))))
(setq stack (nreverse stack))
@@ -79,42 +75,40 @@
(nth 0 stack-item))
(production-rhs
(nth 1 stack-item))
- (production-number
+ (parent-follow
(nth 2 stack-item))
- (dot-look-ahead
- (nth 3 stack-item))
(first-rhs
(parser-generator--first production-rhs nil t t))
- (first-dot-look-ahead
- (parser-generator--first dot-look-ahead nil t t))
+ (first-parent-follow
+ (parser-generator--first parent-follow nil t t))
(look-aheads))
(cond
((and first-rhs
- (not first-dot-look-ahead))
+ (not first-parent-follow))
(setq
look-aheads
(parser-generator--merge-max-terminal-sets
first-rhs
nil)))
- ((and first-dot-look-ahead
+ ((and first-parent-follow
(not first-rhs))
(setq
look-aheads
(parser-generator--merge-max-terminal-sets
nil
- first-dot-look-ahead)))
+ first-parent-follow)))
((and first-rhs
- first-dot-look-ahead)
+ first-parent-follow)
(setq
look-aheads
(parser-generator--merge-max-terminal-sets
first-rhs
- first-dot-look-ahead)))
+ first-parent-follow)))
(t (error
- "Unexpected empty FIRST for production: %S and dot-look-ahead: %S"
+ "Unexpected empty FIRST for production: %S and parent-follow: %S"
production
- dot-look-ahead)))
+ parent-follow)))
;; For each non-terminal in the production right-hand side
;; push a new item to stack with a local-follow
@@ -126,7 +120,7 @@
(let* ((follow-set
(nthcdr (1+ sub-symbol-index) production-rhs))
(merged-follow
- (append follow-set dot-look-ahead))
+ (append follow-set parent-follow))
(local-follow-set
(parser-generator--first merged-follow nil t t))
(sub-symbol-rhss
@@ -141,14 +135,10 @@
(dolist (sub-symbol-rhs sub-symbol-rhss)
(let* ((sub-symbol-production
(list (list sub-symbol) sub-symbol-rhs))
- (sub-symbol-production-number
- (parser-generator--get-grammar-production-number
- sub-symbol-production))
(new-stack-item
(list
(list sub-symbol)
sub-symbol-rhs
- sub-symbol-production-number
local-follow)))
(parser-generator--debug
(message "new-stack-item: %S" new-stack-item))
@@ -160,27 +150,26 @@
(1+ sub-symbol-index)))
;; Add all distinct combinations of left-hand-side,
- ;; look-ahead and dot-look-ahead to tables list here
+ ;; look-ahead and parent-follow to tables list here
(when look-aheads
(dolist (look-ahead look-aheads)
(let ((table
(list
production-lhs
- dot-look-ahead
+ parent-follow
look-ahead
- production-rhs
- production-number))
+ production-rhs))
(item-hash-key
(format
"%S-%S-%S"
production-lhs
- dot-look-ahead
+ parent-follow
look-ahead))
(table-hash-key
(format
"%S-%S"
production-lhs
- dot-look-ahead)))
+ parent-follow)))
(unless (gethash item-hash-key distinct-item-p)
(puthash
item-hash-key
@@ -214,10 +203,9 @@
(parser-generator--debug
(message "\nproduction-lhs: %S" production-lhs)
(message "production-rhs: %S" production-rhs)
- (message "production-number: %S" production-number)
- (message "dot-look-ahead: %S" dot-look-ahead)
+ (message "parent-follow: %S" parent-follow)
(message "first-rhs: %S" first-rhs)
- (message "first-dot-look-ahead: %S" first-dot-look-ahead)
+ (message "first-parent-follow: %S" first-parent-follow)
(message "look-aheads: %S" look-aheads))))
(let ((sorted-tables))
- [elpa] externals/parser-generator updated (bf7229332f -> db91a5f203), Christian Johansson, 2022/05/12
- [elpa] externals/parser-generator 8c467b1bb1 07/82: Added another test for merge max terminal sets, Christian Johansson, 2022/05/12
- [elpa] externals/parser-generator 1199586dad 11/82: More work on generating LL item, Christian Johansson, 2022/05/12
- [elpa] externals/parser-generator 89105668e8 01/82: Started on LL(k) implementation, Christian Johansson, 2022/05/12
- [elpa] externals/parser-generator 878b2900f2 05/82: Improved calculation of merged max terminals when one of the set is undefined, Christian Johansson, 2022/05/12
- [elpa] externals/parser-generator d397a1d48e 12/82: Improved variable naming,
Christian Johansson <=
- [elpa] externals/parser-generator b09b22c0be 13/82: Passing test for LL(k) table Example 5.15, Christian Johansson, 2022/05/12
- [elpa] externals/parser-generator 7c10be74b8 06/82: Added TODO items, Christian Johansson, 2022/05/12
- [elpa] externals/parser-generator 1d1e4e4bf8 03/82: More work on LL(k) parser, Christian Johansson, 2022/05/12
- [elpa] externals/parser-generator 4cb0a0b941 08/82: More work on LL table generation, Christian Johansson, 2022/05/12
- [elpa] externals/parser-generator 29bad0440f 09/82: More work on LL table generation, Christian Johansson, 2022/05/12
- [elpa] externals/parser-generator 87435188dd 15/82: Added function to set EOF-identifier, Christian Johansson, 2022/05/12
- [elpa] externals/parser-generator bab123bdda 17/82: Added reference to PHP 8.1, Christian Johansson, 2022/05/12
- [elpa] externals/parser-generator a2a629c16d 18/82: More work on data structure for LL-tables, Christian Johansson, 2022/05/12
- [elpa] externals/parser-generator 542a50d9c1 20/82: Remove usage of a hash-table, Christian Johansson, 2022/05/12
- [elpa] externals/parser-generator 221446d647 24/82: Started implementation of LLk validation, Christian Johansson, 2022/05/12