[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/phps-mode 3734d56 7/7: More testing with generating AST
From: |
Christian Johansson |
Subject: |
[elpa] externals/phps-mode 3734d56 7/7: More testing with generating AST |
Date: |
Sun, 7 Nov 2021 14:21:38 -0500 (EST) |
branch: externals/phps-mode
commit 3734d56372531db3e01500f74d4f437c5c192515
Author: Christian Johansson <christian@cvj.se>
Commit: Christian Johansson <christian@cvj.se>
More testing with generating AST
---
README.md | 2 +-
phps-mode-parser.el | 2 +-
phps-mode.el | 4 ++--
test/phps-mode-test-parser.el | 55 ++++++++++++++++++++++++++-----------------
4 files changed, 38 insertions(+), 25 deletions(-)
diff --git a/README.md b/README.md
index 62198fa..48fbf1e 100644
--- a/README.md
+++ b/README.md
@@ -29,7 +29,7 @@ This mode does not require PHP installed on your computer
because it has a built
* Support for asynchronous lexer via processes (`async.el`) or threads
* Mode-line asynchronous status
* Bookkeeping in lexical-analysis, showing defined and undefined variables via
syntax coloring (requires a theme that has distinct colors for
'font-lock-warning-face and 'font-lock-variable-name-face)
-* Canonical LR(1) Parser automatically generated from official PHP 8.0 LALR
YACC grammar
+* Canonical LR(1) Parser automatically generated from official PHP 8.0 LALR(1)
YACC grammar
## Roadmap
diff --git a/phps-mode-parser.el b/phps-mode-parser.el
index 76cfe98..12d4353 100644
--- a/phps-mode-parser.el
+++ b/phps-mode-parser.el
@@ -661,7 +661,7 @@
(push
(list
partial-translation
- (if (= (length
popped-items-terminals) 1) popped-items-terminals nil))
+ popped-items-terminals)
symbol-translations)
(puthash
temp-hash-key
diff --git a/phps-mode.el b/phps-mode.el
index ca9597d..9d42dd6 100644
--- a/phps-mode.el
+++ b/phps-mode.el
@@ -5,8 +5,8 @@
;; Author: Christian Johansson <christian@cvj.se>
;; Maintainer: Christian Johansson <christian@cvj.se>
;; Created: 3 Mar 2018
-;; Modified: 2 Nov 2021
-;; Version: 0.4.12
+;; Modified: 7 Nov 2021
+;; Version: 0.4.13
;; Keywords: tools, convenience
;; URL: https://github.com/cjohansson/emacs-phps-mode
diff --git a/test/phps-mode-test-parser.el b/test/phps-mode-test-parser.el
index 607682a..cdd99e7 100644
--- a/test/phps-mode-test-parser.el
+++ b/test/phps-mode-test-parser.el
@@ -347,9 +347,9 @@
'(("myFunctionA" . 16) ("myFunctionB" . 42))))
;; TODO Test bookkeeping here
)))
+ (message "Passed functional oriented imenu-index")
- (let ((imenu-index)
- (imenu-functions)
+ (let ((imenu-functions)
(imenu-namespaces)
(imenu-classes)
(imenu-methods))
@@ -360,15 +360,18 @@
(lambda(args terminals)
(let ((ast-object
(list
+ 'function
(nth 2 args)
(car (cdr (nth 2 terminals)))
(car (cdr (nth 9 terminals)))
(car (cdr (nth 11 terminals))))))
(message "Function: %S" ast-object)
- ;; (message "terminals: %S" terminals)
+ (message "args: %S" args)
+ (message "terminals: %S" terminals)
(push
ast-object
- imenu-functions)))
+ imenu-functions)
+ ast-object))
phps-mode-parser--table-translations)
;; attributed_class_statement -> (method_modifiers function returns_ref
identifier backup_doc_comment "(" parameter_list ")" return_type
backup_fn_flags method_body backup_fn_flags)
@@ -377,15 +380,18 @@
(lambda(args terminals)
(let ((ast-object
(list
+ 'method
(nth 3 args)
(car (cdr (nth 3 terminals)))
(car (cdr (car (nth 10 terminals))))
(cdr (cdr (car (cdr (cdr (nth 10 terminals)))))))))
(message "Method: %S" ast-object)
- ;; (message "terminals: %S" terminals)
+ (message "args: %S" args)
+ (message "terminals: %S" terminals)
(push
ast-object
- imenu-methods)))
+ imenu-methods)
+ ast-object))
phps-mode-parser--table-translations)
;; top_statement -> (T_NAMESPACE namespace_declaration_name ";")
@@ -394,15 +400,18 @@
(lambda(args terminals)
(let ((ast-object
(list
+ 'namespace
(nth 1 args)
(car (cdr (nth 1 terminals)))
(car (cdr (nth 2 terminals)))
'max)))
(message "Namespace %S" ast-object)
- ;; (message "terminals: %S" terminals)
+ (message "args: %S" args)
+ (message "terminals: %S" terminals)
(push
ast-object
- imenu-namespaces)))
+ imenu-namespaces)
+ ast-object))
phps-mode-parser--table-translations)
;; class_declaration_statement -> (T_CLASS T_STRING extends_from
implements_list backup_doc_comment "{" class_statement_list "}")
@@ -411,15 +420,18 @@
(lambda(args terminals)
(let ((ast-object
(list
+ 'class
(nth 1 args)
(car (cdr (nth 1 terminals)))
(car (cdr (nth 5 terminals)))
(car (cdr (nth 7 terminals))))))
(message "Class %S" ast-object)
- ;; (message "terminals: %S" terminals)
+ (message "args: %S" args)
+ (message "terminals: %S" terminals)
(push
ast-object
- imenu-classes)))
+ imenu-classes)
+ ast-object))
phps-mode-parser--table-translations)
(phps-mode-test-parser--buffer-contents
@@ -437,16 +449,17 @@
production-number
(car (car production))
(car (cdr production))))))
- (phps-mode-parser-translate)
- (setq
- imenu-index
- (nreverse imenu-index))
- (should
- (equal
- imenu-index
- '(("MyNamespace" ("MyClass" ("__construct" . 92) ("myFunction1" .
193) ("myFunction2" . 365) ("myFunction3" . 445) ("myFunction4" . 515))))))
- ;; TODO Test bookkeeping here
- )))
+ (let ((translation (phps-mode-parser-translate))
+ (imenu-index))
+ (message "translation: %S" translation)
+
+ ;; TODO Build imenu-index here
+ (should
+ (equal
+ imenu-index
+ '(("MyNamespace" ("MyClass" ("__construct" . 92) ("myFunction1" .
193) ("myFunction2" . 365) ("myFunction3" . 445) ("myFunction4" . 515))))))
+ ;; TODO Test bookkeeping here
+ ))))
(message "\n-- Ran tests for parser translation. --"))
@@ -455,7 +468,7 @@
(message "-- Running all tests for parser... --\n")
(phps-mode-test-parser-parse)
- (phps-mode-test-parser-translate)
+ ;; (phps-mode-test-parser-translate)
(message "\n-- Ran all tests for parser. --"))
- [elpa] externals/phps-mode updated (38e99b2 -> 3734d56), Christian Johansson, 2021/11/07
- [elpa] externals/phps-mode 19dd2c7 2/7: Improved incremental test and fixed bug with inconsistent parse variable after incremental parse, Christian Johansson, 2021/11/07
- [elpa] externals/phps-mode 1c75371 1/7: Added FSF header to generated parser script, Christian Johansson, 2021/11/07
- [elpa] externals/phps-mode 004f60d 3/7: Started on test for SDT, Christian Johansson, 2021/11/07
- [elpa] externals/phps-mode 8ec76e8 5/7: Improved parser to pass more meta-data about tokens for SDT, Christian Johansson, 2021/11/07
- [elpa] externals/phps-mode 3734d56 7/7: More testing with generating AST,
Christian Johansson <=
- [elpa] externals/phps-mode 5994746 4/7: Started on generating imenu-index via parser translation, Christian Johansson, 2021/11/07
- [elpa] externals/phps-mode e82483e 6/7: More testing of generating imenu-index via parser SDT, Christian Johansson, 2021/11/07