emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/phps-mode 3489f9d 90/96: Parser parse function now igno


From: Christian Johansson
Subject: [elpa] externals/phps-mode 3489f9d 90/96: Parser parse function now ignores creating a SDT
Date: Fri, 29 Oct 2021 11:15:05 -0400 (EDT)

branch: externals/phps-mode
commit 3489f9d5aea39a05c69e23665e80a8592cc1b85a
Author: Christian Johansson <christian@cvj.se>
Commit: Christian Johansson <christian@cvj.se>

    Parser parse function now ignores creating a SDT
---
 phps-mode-parser.el | 158 +++++++++++++++++++++++++++-------------------------
 1 file changed, 81 insertions(+), 77 deletions(-)

diff --git a/phps-mode-parser.el b/phps-mode-parser.el
index 63fe9b9..09b976e 100644
--- a/phps-mode-parser.el
+++ b/phps-mode-parser.el
@@ -415,13 +415,14 @@
 (defun
   phps-mode-parser--parse
   (&optional
+    perform-sdt
     input-tape-index
     pushdown-list
     output
     translation
     translation-symbol-table-list
     history)
-  "Perform a LR-parse via lex-analyzer, optionally at INPUT-TAPE-INDEX with 
PUSHDOWN-LIST, OUTPUT, TRANSLATION, TRANSLATION-SYMBOL-TABLE-LIST and HISTORY."
+  "Perform a LR-parse via lex-analyzer, optionally PERFORM-SDT means to 
perform syntax-directed translation and optioanlly start at INPUT-TAPE-INDEX 
with PUSHDOWN-LIST, OUTPUT, TRANSLATION, TRANSLATION-SYMBOL-TABLE-LIST and 
HISTORY."
   (unless input-tape-index
     (setq input-tape-index 1))
   (unless pushdown-list
@@ -655,64 +656,87 @@
                               (setq popped-items (1+ popped-items)))))
                         (push production-number output)
 
-                        (let ((popped-items-meta-contents))
-                          (setq
-                           popped-items-contents
-                           (reverse popped-items-contents))
-                          ;; Collect arguments for translation
-                          (dolist (popped-item popped-items-contents)
-                            (if (and
-                                 (listp popped-item)
-                                 (cdr popped-item))
-                                ;; If item is a terminal, use it's literal 
value
-                                (push
-                                 (phps-mode-parser-lex-analyzer--get-function
-                                  popped-item)
-                                 popped-items-meta-contents)
-
-                              ;; If item is a non-terminal
-                              (let ((temp-hash-key
-                                     (format
-                                      "%S"
-                                       popped-item)))
-
-                              ;; If we have a translation for symbol, pop one
-                              ;; otherwise push nil on translation argument 
stack
-                              (if (gethash
-                                       temp-hash-key
-                                       translation-symbol-table)
+                        (when perform-sdt
+                          (let ((popped-items-meta-contents))
+                            (setq
+                             popped-items-contents
+                             (reverse popped-items-contents))
+                            ;; Collect arguments for translation
+                            (dolist (popped-item popped-items-contents)
+                              (if (and
+                                   (listp popped-item)
+                                   (cdr popped-item))
+                                  ;; If item is a terminal, use it's literal 
value
+                                  (push
+                                   (phps-mode-parser-lex-analyzer--get-function
+                                    popped-item)
+                                   popped-items-meta-contents)
+
+                                ;; If item is a non-terminal
+                                (let ((temp-hash-key
+                                       (format
+                                        "%S"
+                                         popped-item)))
+
+                                ;; If we have a translation for symbol, pop one
+                                ;; otherwise push nil on translation argument 
stack
+                                (if (gethash
+                                         temp-hash-key
+                                         translation-symbol-table)
+                                        (let ((symbol-translations
+                                               (gethash
+                                                temp-hash-key
+                                                translation-symbol-table)))
+                                          (let ((symbol-translation
+                                                 (pop symbol-translations)))
+                                            (push
+                                             symbol-translation
+                                             popped-items-meta-contents)
+                                            (puthash
+                                             temp-hash-key
+                                             symbol-translations
+                                             translation-symbol-table)))
+                                      (push
+                                       nil
+                                       popped-items-meta-contents)))))
+
+                              ;; If we just have one argument, pass it as a 
instead of a list
+                              (when (= (length popped-items-meta-contents) 1)
+                                (setq
+                                 popped-items-meta-contents
+                                 (car popped-items-meta-contents)))
+
+                              ;; Perform translation at reduction if specified
+                              (if
+                                  
(phps-mode-parser--get-grammar-translation-by-number
+                                   production-number)
+                                  (let ((partial-translation
+                                         (funcall
+                                          
(phps-mode-parser--get-grammar-translation-by-number
+                                           production-number)
+                                          popped-items-meta-contents)))
+                                    (let ((temp-hash-key
+                                           (format
+                                            "%S"
+                                            production-lhs)))
                                       (let ((symbol-translations
                                              (gethash
                                               temp-hash-key
                                               translation-symbol-table)))
-                                        (let ((symbol-translation
-                                               (pop symbol-translations)))
-                                          (push
-                                           symbol-translation
-                                           popped-items-meta-contents)
-                                          (puthash
-                                           temp-hash-key
-                                           symbol-translations
-                                           translation-symbol-table)))
-                                    (push
-                                     nil
-                                     popped-items-meta-contents)))))
-
-                            ;; If we just have one argument, pass it as a 
instead of a list
-                            (when (= (length popped-items-meta-contents) 1)
-                              (setq
-                               popped-items-meta-contents
-                               (car popped-items-meta-contents)))
-
-                            ;; Perform translation at reduction if specified
-                            (if
-                                
(phps-mode-parser--get-grammar-translation-by-number
-                                 production-number)
+                                        (push
+                                         partial-translation
+                                         symbol-translations)
+                                        (puthash
+                                         temp-hash-key
+                                         symbol-translations
+                                         translation-symbol-table)
+                                        (setq
+                                         translation
+                                         partial-translation))))
+
+                                ;; When no translation is specified just use 
popped contents as translation
                                 (let ((partial-translation
-                                       (funcall
-                                        
(phps-mode-parser--get-grammar-translation-by-number
-                                         production-number)
-                                        popped-items-meta-contents)))
+                                       popped-items-meta-contents))
                                   (let ((temp-hash-key
                                          (format
                                           "%S"
@@ -730,29 +754,7 @@
                                        translation-symbol-table)
                                       (setq
                                        translation
-                                       partial-translation))))
-
-                              ;; When no translation is specified just use 
popped contents as translation
-                              (let ((partial-translation
-                                     popped-items-meta-contents))
-                                (let ((temp-hash-key
-                                       (format
-                                        "%S"
-                                        production-lhs)))
-                                  (let ((symbol-translations
-                                         (gethash
-                                          temp-hash-key
-                                          translation-symbol-table)))
-                                    (push
-                                     partial-translation
-                                     symbol-translations)
-                                    (puthash
-                                     temp-hash-key
-                                     symbol-translations
-                                     translation-symbol-table)
-                                    (setq
-                                     translation
-                                     partial-translation))))))
+                                       partial-translation)))))))
 
                           (let ((new-table-index (car pushdown-list)))
                             (let ((goto-table-distinct-index
@@ -829,6 +831,7 @@
   "Perform a LR-parse via lex-analyzer, optionally at INPUT-TAPE-INDEX with 
PUSHDOWN-LIST, OUTPUT, TRANSLATION and HISTORY."
   (let ((result
          (phps-mode-parser--parse
+          nil
           input-tape-index
           pushdown-list
           output
@@ -846,6 +849,7 @@
   "Perform a LR-parse via lex-analyzer, optionally at INPUT-TAPE-INDEX with 
PUSHDOWN-LIST, OUTPUT, TRANSLATION and HISTORY."
   (let ((result
          (phps-mode-parser--parse
+          t
           input-tape-index
           pushdown-list
           output



reply via email to

[Prev in Thread] Current Thread [Next in Thread]