[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/phps-mode bc8306f 71/96: Fix in automation grammar to s
From: |
Christian Johansson |
Subject: |
[elpa] externals/phps-mode bc8306f 71/96: Fix in automation grammar to support exporting |
Date: |
Fri, 29 Oct 2021 11:14:52 -0400 (EDT) |
branch: externals/phps-mode
commit bc8306f47083d56a124e4c5037ec2ac2de8f2722
Author: Christian Johansson <christian@cvj.se>
Commit: Christian Johansson <christian@cvj.se>
Fix in automation grammar to support exporting
---
phps-mode-automation-grammar.el | 330 ++++++++++++++++++++--------------------
1 file changed, 166 insertions(+), 164 deletions(-)
diff --git a/phps-mode-automation-grammar.el b/phps-mode-automation-grammar.el
index e1c02a5..654cc7d 100644
--- a/phps-mode-automation-grammar.el
+++ b/phps-mode-automation-grammar.el
@@ -50,7 +50,7 @@
(defvar
phps-mode-parser-lex-analyzer--move-to-index-flag
nil
- "A dummy flag.")
+ "Non-nil means to move index.")
(defvar
phps-mode-automation-grammar--header
@@ -70,176 +70,178 @@
(defvar
phps-mode-automation-grammar--lex-analyzer-reset-function
(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)
+ (progn
+ ;; 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-lexer--heredoc-label
- nil)
- (setq-local
- phps-mode-lexer--heredoc-label-stack
- nil)
+ phps-mode-parser-tokens
+ (reverse
+ phps-mode-lexer--generated-tokens))
+
+ ;; Reset buffer-index to token-list-index connections
(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)))
-
- )
+ phps-mode-parser-position
+ nil)))
+
+ ))
"The reset function.")
(defvar
phps-mode-automation-grammar--lex-analyzer-function
(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)))))
+ (progn
+
+ ;; 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 custom lex-analyzer.")
(defvar
- [elpa] externals/phps-mode ce5e28e 72/96: Added generated grammar in output of automation, (continued)
- [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
- [elpa] externals/phps-mode 128868c 75/96: Added another parse test, Christian Johansson, 2021/10/29
- [elpa] externals/phps-mode f44577a 79/96: More testing integrating parser and lex-analyzer, Christian Johansson, 2021/10/29
- [elpa] externals/phps-mode 7cfa35c 81/96: Improved error-reporting for parser errors, Christian Johansson, 2021/10/29
- [elpa] externals/phps-mode 91b425f 73/96: Update of parsers lex-analyzer function to not depend on lexer buffer, Christian Johansson, 2021/10/29
- [elpa] externals/phps-mode 0f11914 83/96: Fixed lexer issue with wrong token for expressions inside double quoted strings, Christian Johansson, 2021/10/29
- [elpa] externals/phps-mode 50c9b31 84/96: Added 2 TODO items, Christian Johansson, 2021/10/29
- [elpa] externals/phps-mode c9f6fdb 82/96: Mode-line status now signals parser errors, Christian Johansson, 2021/10/29
- [elpa] externals/phps-mode e007ea7 88/96: Fixed parser-mode issue with parser and lex-analyzer integration, Christian Johansson, 2021/10/29
- [elpa] externals/phps-mode bc8306f 71/96: Fix in automation grammar to support exporting,
Christian Johansson <=
- [elpa] externals/phps-mode 238f967 76/96: Cleaned up lex function, Christian Johansson, 2021/10/29
- [elpa] externals/phps-mode 5e375e3 80/96: Parser is not blocking lexer anymore, Christian Johansson, 2021/10/29
- [elpa] externals/phps-mode 7b62779 86/96: Added another TODO item, Christian Johansson, 2021/10/29
- [elpa] externals/phps-mode c5058c5 87/96: Fixed issue with async.el support for parser, Christian Johansson, 2021/10/29
- [elpa] externals/phps-mode 8e263fe 85/96: Removed T_DIE as token as it's replaced by T_EXIT, Christian Johansson, 2021/10/29
- [elpa] externals/phps-mode 3489f9d 90/96: Parser parse function now ignores creating a SDT, Christian Johansson, 2021/10/29
- [elpa] externals/phps-mode 620ec6e 91/96: Optimization of parser speed, Christian Johansson, 2021/10/29
- [elpa] externals/phps-mode ff25e3d 92/96: Removed obsolete files, Christian Johansson, 2021/10/29
- [elpa] externals/phps-mode aa691a8 89/96: Added parser and lexer integraction-fix to automation, Christian Johansson, 2021/10/29
- [elpa] externals/phps-mode daba241 93/96: Added another TODO item, Christian Johansson, 2021/10/29