[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/phps-mode 945571c 65/96: Fixed byte-compilation issues
From: |
Christian Johansson |
Subject: |
[elpa] externals/phps-mode 945571c 65/96: Fixed byte-compilation issues with parser |
Date: |
Fri, 29 Oct 2021 11:14:50 -0400 (EDT) |
branch: externals/phps-mode
commit 945571cfe892351ad9044a0ecbfe5bc8e36f7150
Author: Christian Johansson <christian@cvj.se>
Commit: Christian Johansson <christian@cvj.se>
Fixed byte-compilation issues with parser
---
phps-mode-parser.el | 169 +++++++++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 167 insertions(+), 2 deletions(-)
diff --git a/phps-mode-parser.el b/phps-mode-parser.el
index 8881fcf..bbf3ca4 100644
--- a/phps-mode-parser.el
+++ b/phps-mode-parser.el
@@ -102,12 +102,177 @@
(defvar
phps-mode-parser-lex-analyzer--function
- (lambda (buffer-index) (if (get-buffer "*PHPs Lexer*") nil
(generate-new-buffer "*PHPs Lexer*") (let ((old-buffer
(buffer-substring-no-properties (point-min) (point-max)))) (save-current-buffer
(set-buffer "*PHPs Lexer*") (insert old-buffer)))))
+ (lambda (buffer-index)
+
+ ;; Create lexer buffer if none exists
+ (unless (get-buffer "*PHPs Lexer*")
+ (generate-new-buffer "*PHPs Lexer*")
+ (let ((old-buffer
+ (buffer-substring-no-properties
+ (point-min)
+ (point-max))))
+ (with-current-buffer "*PHPs Lexer*"
+ (insert old-buffer))))
+
+ (with-current-buffer "*PHPs Lexer*"
+ (let ((token-list-index))
+ (if (and
+ phps-mode-parser-position
+ (= (car (car phps-mode-parser-position)) buffer-index))
+ (progn
+ (setq
+ token-list-index
+ (car (cdr (car phps-mode-parser-position)))))
+
+ ;; Search from last requested index and forward until
+ ;; we find a token starting at or after buffer-index and
+ ;; use this as buffer-index, save buffer-index to
+ ;; token-list-index connection
+ (let ((previous-token-list-index 0))
+ (when (and
+ phps-mode-parser-position
+ (< (car (car phps-mode-parser-position)) buffer-index))
+ (setq
+ previous-token-list-index
+ (car (cdr (car phps-mode-parser-position)))))
+
+ (let ((temp-token-list-index
+ previous-token-list-index)
+ (token-list-size
+ (length
+ phps-mode-parser-tokens))
+ (continue t))
+ (while (and
+ continue
+ (<
+ temp-token-list-index
+ token-list-size))
+ (let ((token
+ (nth
+ temp-token-list-index
+ phps-mode-parser-tokens)))
+
+ ;; When token starts at cursor we found correct index
+ ;; Save it
+ (when (= (car (cdr token)) buffer-index)
+ (let ((token-type (car token)))
+ (push
+ (list
+ buffer-index
+ temp-token-list-index)
+ phps-mode-parser-position)
+ (unless (or
+ (equal token-type 'T_OPEN_TAG)
+ (equal token-type 'T_CLOSE_TAG)
+ (equal token-type 'T_DOC_COMMENT)
+ (equal token-type 'T_COMMENT))
+ (setq
+ token-list-index
+ temp-token-list-index)
+ (setq
+ continue
+ nil))))
+
+ ;; When token starts after cursor, flag move of cursor
+ ;; Save it
+ (when (> (car (cdr token)) buffer-index)
+ (let ((token-type (car token)))
+ (push
+ (list
+ (car (cdr token))
+ temp-token-list-index)
+ phps-mode-parser-position)
+ (unless (or
+ (equal token-type 'T_OPEN_TAG)
+ (equal token-type 'T_CLOSE_TAG)
+ (equal token-type 'T_DOC_COMMENT)
+ (equal token-type 'T_COMMENT))
+ (setq-local
+ phps-mode-parser-lex-analyzer--move-to-index-flag
+ (car (cdr token)))
+ (setq
+ continue
+ nil))))
+
+ (setq
+ temp-token-list-index
+ (1+ temp-token-list-index))
+ )))))
+
+ (when
+ token-list-index
+ (let ((token
+ (nth
+ token-list-index
+ phps-mode-parser-tokens)))
+ (when (equal (car token) 'T_OPEN_TAG_WITH_ECHO)
+ (setf
+ (car token)
+ 'T_ECHO))
+ token)))))
"The lex-analyzer function.")
(defvar
phps-mode-parser-lex-analyzer--reset-function
- (lambda nil (if (get-buffer "*PHPs Lexer*") nil (generate-new-buffer "*PHPs
Lexer*") (let ((old-buffer (buffer-substring-no-properties (point-min)
(point-max)))) (save-current-buffer (set-buffer "*PHPs Lexer*") (insert
old-buffer)))))
+ (lambda()
+ ;; Create lexer buffer if none exists
+ (unless (get-buffer "*PHPs Lexer*")
+ (generate-new-buffer "*PHPs Lexer*")
+ (let ((old-buffer
+ (buffer-substring-no-properties
+ (point-min)
+ (point-max))))
+ (with-current-buffer "*PHPs Lexer*"
+ (insert old-buffer))))
+
+ (with-current-buffer "*PHPs Lexer*"
+ ;; Unless we have lexed the buffer
+ (unless phps-mode-parser-tokens
+ (unless phps-mode-lexer--generated-tokens
+ ;; Reset lexer
+ (setq-local
+ phps-mode-lexer--generated-tokens
+ nil)
+ (setq-local
+ phps-mode-lexer--state
+ 'ST_INITIAL)
+ (setq-local
+ phps-mode-lexer--states
+ nil)
+ (setq-local
+ phps-mode-lexer--state-stack
+ nil)
+ (setq-local
+ phps-mode-lexer--heredoc-label
+ nil)
+ (setq-local
+ phps-mode-lexer--heredoc-label-stack
+ nil)
+ (setq-local
+ phps-mode-lexer--nest-location-stack
+ nil)
+ (goto-char (point-min))
+
+ ;; Run lexer on entire buffer here
+ (let ((index (point))
+ (max-index (point-max)))
+ (while (< index max-index)
+ (phps-mode-lexer--re2c)
+ (setq
+ index
+ semantic-lex-end-point)
+ (goto-char index))))
+ (setq-local
+ phps-mode-parser-tokens
+ (reverse
+ phps-mode-lexer--generated-tokens))
+
+ ;; Reset buffer-index to token-list-index connections
+ (setq-local
+ phps-mode-parser-position
+ nil)))
+
+ )
"The lex-analyzer reset function.")
- [elpa] externals/phps-mode 024e8d4 55/96: Setting up context-sensitive attributes automatically, (continued)
- [elpa] externals/phps-mode 024e8d4 55/96: Setting up context-sensitive attributes automatically, Christian Johansson, 2021/10/29
- [elpa] externals/phps-mode 605b76c 57/96: Removed note, Christian Johansson, 2021/10/29
- [elpa] externals/phps-mode 20ad000 68/96: Added another TODO item, Christian Johansson, 2021/10/29
- [elpa] externals/phps-mode a6c5db1 45/96: Updated grammar productions based on automatically parsed grammar from YACC, Christian Johansson, 2021/10/29
- [elpa] externals/phps-mode 2ac480a 47/96: Started on automatic generation of terminals, non-terminals and start as well, Christian Johansson, 2021/10/29
- [elpa] externals/phps-mode eb17d8c 51/96: Improved resuming of parser-generation, Christian Johansson, 2021/10/29
- [elpa] externals/phps-mode 6af98c4 56/96: Productions are now read automatically again, Christian Johansson, 2021/10/29
- [elpa] externals/phps-mode 212fd7f 63/96: Fixed warning in byte-compilation, Christian Johansson, 2021/10/29
- [elpa] externals/phps-mode fb57c3b 53/96: Started on parser for global declaration, Christian Johansson, 2021/10/29
- [elpa] externals/phps-mode e418621 59/96: Projects passes tests and byte-compilation again, Christian Johansson, 2021/10/29
- [elpa] externals/phps-mode 945571c 65/96: Fixed byte-compilation issues with parser,
Christian Johansson <=
- [elpa] externals/phps-mode 07a983d 66/96: Passing parser tests, Christian Johansson, 2021/10/29
- [elpa] externals/phps-mode b551e69 67/96: Added TODO items, Christian Johansson, 2021/10/29
- [elpa] externals/phps-mode 37fdd2e 78/96: Passing all tests with parser integrated somewhat, Christian Johansson, 2021/10/29
- [elpa] externals/phps-mode e3b9403 69/96: Removed garbage collection modification, Christian Johansson, 2021/10/29
- [elpa] externals/phps-mode 1789d15 60/96: Fixed bug in gramamr automation, Christian Johansson, 2021/10/29
- [elpa] externals/phps-mode 08e1325 74/96: Test of parser not dependent on buffer name, Christian Johansson, 2021/10/29
- [elpa] externals/phps-mode eced7be 77/96: Parser now not dependent on lex-analyzer variables, Christian Johansson, 2021/10/29
- [elpa] externals/phps-mode 4f7126b 70/96: Fixed automation grammar setting of lex-analyzer functions, Christian Johansson, 2021/10/29
- [elpa] externals/phps-mode ce5e28e 72/96: Added generated grammar in output of automation, Christian Johansson, 2021/10/29
- [elpa] externals/phps-mode e698a2e 64/96: Re-generated parser with automated grammar, Christian Johansson, 2021/10/29