[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/phps-mode 5c7c6f4 14/96: Parser passes basic lexing tes
From: |
Christian Johansson |
Subject: |
[elpa] externals/phps-mode 5c7c6f4 14/96: Parser passes basic lexing test |
Date: |
Fri, 29 Oct 2021 11:14:32 -0400 (EDT) |
branch: externals/phps-mode
commit 5c7c6f44a00e96710b212434428b8d47f83c340b
Author: Christian Johansson <christian@cvj.se>
Commit: Christian Johansson <christian@cvj.se>
Parser passes basic lexing test
---
phps-mode-automation-grammar.el | 92 +++++++++++++++++------------------------
phps-mode-parser.el | 4 +-
test/phps-mode-test-parser.el | 2 +-
3 files changed, 41 insertions(+), 57 deletions(-)
diff --git a/phps-mode-automation-grammar.el b/phps-mode-automation-grammar.el
index 070d2e1..5f515ac 100644
--- a/phps-mode-automation-grammar.el
+++ b/phps-mode-automation-grammar.el
@@ -1453,61 +1453,45 @@
(lambda (index)
(save-current-buffer
(set-buffer "*phps-mode-lex-analyzer*")
- (unless (= (point) index)
- (goto-char index))
-
- (when (< index (point-max))
-
- ;; Only lex if we have not lexed this position recently
- (unless (and
+ (if (= (point) index) nil (goto-char index))
+ (if (< index (point-max))
+ (progn
+ (if (and
phps-mode-lexer--generated-new-tokens-index
- (=
- phps-mode-lexer--generated-new-tokens-index
- index))
- (phps-mode-lexer--re2c))
-
- (let ((first (car (reverse phps-mode-lexer--generated-new-tokens))))
-
- (cond
-
- ;; Lexer has moved forward - lex again
- ((and
- (not first)
- (not (equal index semantic-lex-end-point)))
- (setq
- phps-mode-parser-lex-analyzer--index
- semantic-lex-end-point)
- (setq
- first
- (funcall
- phps-mode-parser-lex-analyzer--function
- phps-mode-parser-lex-analyzer--index)))
-
- ;; Skip open and close tag
- ((or
- (equal (car first) 'T_OPEN_TAG)
- (equal (car first) 'T_CLOSE_TAG))
- (setq
- phps-mode-parser-lex-analyzer--index
- (cdr (cdr first)))
- (setq
- first
- (funcall
- phps-mode-parser-lex-analyzer--function
- phps-mode-parser-lex-analyzer--index)))
-
- ;; Open tag with echo is replaced with echo
- ((equal (car first) 'T_OPEN_TAG_WITH_ECHO)
- (setf
- (car first)
- 'T_ECHO)
- (setq
- phps-mode-parser-lex-analyzer--index
- (cdr (cdr first))))
-
- )
-
- first))))
+ (= phps-mode-lexer--generated-new-tokens-index index))
+ nil
+ (phps-mode-lexer--re2c))
+ (let ((first (car (reverse
phps-mode-lexer--generated-new-tokens))))
+ (cond
+
+ ((and
+ (not first)
+ (not (equal index semantic-lex-end-point)))
+ (setq-local
+ phps-mode-parser-lex-analyzer--index
+ semantic-lex-end-point)
+ (setq
+ first
+ (funcall
+ phps-mode-parser-lex-analyzer--function
+ phps-mode-parser-lex-analyzer--index)))
+
+ ((or
+ (equal (car first) 'T_OPEN_TAG)
+ (equal (car first) 'T_CLOSE_TAG))
+ (setq-local
+ phps-mode-parser-lex-analyzer--index
+ (cdr (cdr first)))
+ (setq
+ first
+ (funcall
+ phps-mode-parser-lex-analyzer--function
+ phps-mode-parser-lex-analyzer--index)))
+
+ ((equal (car first) 'T_OPEN_TAG_WITH_ECHO)
+ (let* ((v first)) (setcar v 'T_ECHO))))
+
+ first)))))
"The custom lex-analyzer.")
(defconst
diff --git a/phps-mode-parser.el b/phps-mode-parser.el
index de5abb5..66adf7e 100644
--- a/phps-mode-parser.el
+++ b/phps-mode-parser.el
@@ -62,7 +62,7 @@
(defconst
phps-mode-parser-lex-analyzer--function
- (lambda (index) (save-current-buffer (set-buffer "*phps-mode-lex-analyzer*")
(if (= (point) index) nil (goto-char index)) (if (< index (point-max)) (progn
(if (and phps-mode-lexer--generated-new-tokens-index (=
phps-mode-lexer--generated-new-tokens-index index)) nil
(phps-mode-lexer--re2c)) (let ((first (car (reverse
phps-mode-lexer--generated-new-tokens)))) (cond ((and (not first) (not (equal
index semantic-lex-end-point))) (setq phps-mode-parser-lex-analyzer--index
semantic-lex-end-p [...]
+ (lambda (index) (save-current-buffer (set-buffer "*phps-mode-lex-analyzer*")
(if (= (point) index) nil (goto-char index)) (if (< index (point-max)) (progn
(if (and phps-mode-lexer--generated-new-tokens-index (=
phps-mode-lexer--generated-new-tokens-index index)) nil
(phps-mode-lexer--re2c)) (let ((first (car (reverse
phps-mode-lexer--generated-new-tokens)))) (cond ((and (not first) (not (equal
index semantic-lex-end-point))) (set (make-local-variable
'phps-mode-parser-lex-analyzer--ind [...]
"The lex-analyzer function.")
(defconst
@@ -169,7 +169,7 @@
"Lex-analyze failed to peek next look-ahead at %s, error: %s"
index
error))))
- (reverse look-ahead)))
+ (nreverse look-ahead)))
(defun
phps-mode-parser-lex-analyzer--pop-token ()
diff --git a/test/phps-mode-test-parser.el b/test/phps-mode-test-parser.el
index 5ed4db0..d23b74c 100644
--- a/test/phps-mode-test-parser.el
+++ b/test/phps-mode-test-parser.el
@@ -96,7 +96,7 @@
(lambda()
(should
(equal
- '(80 459 466 411 156 102 79)
+ '(80 459 466 411 333 332 154 102 79)
(phps-mode-parser-parse)))))
- [elpa] externals/phps-mode 7a0eecd 07/96: First test passing for parser, (continued)
- [elpa] externals/phps-mode 7a0eecd 07/96: First test passing for parser, Christian Johansson, 2021/10/29
- [elpa] externals/phps-mode 2189d31 11/96: Fixes for lexer in parser to handle T_CLOSE_TAG, Christian Johansson, 2021/10/29
- [elpa] externals/phps-mode 50ed917 12/96: Using non-parser mode for lexer, Christian Johansson, 2021/10/29
- [elpa] externals/phps-mode c15fa0c 10/96: Using parser-mode for lexer, Christian Johansson, 2021/10/29
- [elpa] externals/phps-mode ab56c99 13/96: More work on debugging parser-lexer, Christian Johansson, 2021/10/29
- [elpa] externals/phps-mode 1dd3bd3 06/96: More working on trying to get parser test working, Christian Johansson, 2021/10/29
- [elpa] externals/phps-mode 3f5c008 09/96: Optimization for lexer to only need to execute once per index, Christian Johansson, 2021/10/29
- [elpa] externals/phps-mode 2b167f3 08/96: Fixes for parsing start and end, Christian Johansson, 2021/10/29
- [elpa] externals/phps-mode 376e690 15/96: Verified parse, Christian Johansson, 2021/10/29
- [elpa] externals/phps-mode 2a9fb96 16/96: Added more tests for parser, Christian Johansson, 2021/10/29
- [elpa] externals/phps-mode 5c7c6f4 14/96: Parser passes basic lexing test,
Christian Johansson <=
- [elpa] externals/phps-mode 569505e 17/96: Added parser header and fixed byte-compilation for parser, Christian Johansson, 2021/10/29
- [elpa] externals/phps-mode 0d1843f 20/96: Started on parser integration, Christian Johansson, 2021/10/29
- [elpa] externals/phps-mode b714471 21/96: Added parse function in lex-analyzer and a test for it, Christian Johansson, 2021/10/29
- [elpa] externals/phps-mode 50a014a 18/96: Using same lexer buffer for parser as the lex-analyzer is using, Christian Johansson, 2021/10/29
- [elpa] externals/phps-mode fb9905f 19/96: Added basic translation test, Christian Johansson, 2021/10/29
- [elpa] externals/phps-mode ec18c1e 22/96: Using parser to be able to implement incremental parser, Christian Johansson, 2021/10/29
- [elpa] externals/phps-mode 1ee3094 28/96: More refactoring of the parsers lex-analyzer, Christian Johansson, 2021/10/29
- [elpa] externals/phps-mode 2ceb6e5 23/96: Added potential support for incremental parsing, Christian Johansson, 2021/10/29
- [elpa] externals/phps-mode e59d30e 26/96: Improvements in lex-analyzer for parser, Christian Johansson, 2021/10/29
- [elpa] externals/phps-mode c62ec64 27/96: Started refactor of parsers lex-analyzer, Christian Johansson, 2021/10/29