[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/phps-mode e698a2e 64/96: Re-generated parser with autom
From: |
Christian Johansson |
Subject: |
[elpa] externals/phps-mode e698a2e 64/96: Re-generated parser with automated grammar |
Date: |
Fri, 29 Oct 2021 11:14:48 -0400 (EDT) |
branch: externals/phps-mode
commit e698a2e4ab028fd22c3f42c6e3a6902ee232a37b
Author: Christian Johansson <christian@cvj.se>
Commit: Christian Johansson <christian@cvj.se>
Re-generated parser with automated grammar
---
phps-mode-parser.el | 190 +++++-----------------------------------------------
1 file changed, 18 insertions(+), 172 deletions(-)
diff --git a/phps-mode-parser.el b/phps-mode-parser.el
index 8afaa3a..8881fcf 100644
--- a/phps-mode-parser.el
+++ b/phps-mode-parser.el
@@ -24,42 +24,42 @@
(defvar
phps-mode-parser--action-tables
- #s(hash-table size 42072 test equal rehash-size 1.5 rehash-threshold 0.8125
data (0 0 1 1 2 2 3 3 4 4 5 2 6 2 7 2 8 2 9 9 10 10 11 2 12 12 13 2 14 14 15 15
16 16 17 2 18 18 19 19 20 14 21 21 22 10 23 23 24 24 25 25 26 2 27 2 28 10 29
10 30 30 31 31 32 32 33 33 34 10 35 10 36 36 37 37 38 38 39 18 40 10 41 10 42
21 43 2 44 2 45 45 46 46 47 2 48 10 49 49 50 10 51 51 52 10 53 53 54 54 55 55
56 56 57 57 58 58 59 59 60 2 61 2 62 2 63 2 64 14 65 65 66 66 67 67 68 2 69 10
70 2 71 71 72 72 73 7 [...]
+ #s(hash-table size 28048 test equal rehash-size 1.5 rehash-threshold 0.8125
data (0 0 1 1 2 2 3 3 4 4 5 2 6 2 7 2 8 8 9 2 10 10 11 11 12 2 13 13 14 2 15 15
16 16 17 17 18 2 19 16 20 20 21 15 22 22 23 11 24 24 25 25 26 26 27 2 28 2 29
11 30 11 31 31 32 32 33 33 34 34 35 11 36 11 37 37 38 38 39 39 40 16 41 11 42
11 43 22 44 2 45 2 46 46 47 16 48 2 49 11 50 50 51 11 52 52 53 11 54 54 55 55
56 56 57 57 58 58 59 59 60 60 61 2 62 2 63 2 64 2 65 15 66 66 67 67 68 68 69 2
70 11 71 2 72 16 73 7 [...]
"The generated action-tables.")
(defvar
phps-mode-parser--distinct-action-tables
- #s(hash-table size 18699 test equal rehash-size 1.5 rehash-threshold 0.8125
data (0 ((("!") reduce 80) (("\"") reduce 80) (($) reduce 80) (("$") reduce 80)
(("(") reduce 80) (("+") reduce 80) (("-") reduce 80) (("@") reduce 80)
((T_ABSTRACT) reduce 80) ((T_ARRAY) reduce 80) ((T_ARRAY_CAST) reduce 80)
((T_ATTRIBUTE) reduce 80) ((T_BOOL_CAST) reduce 80) ((T_BREAK) reduce 80)
((T_CLASS) reduce 80) ((T_CLASS_C) reduce 80) ((T_CLONE) reduce 80) ((T_CONST)
reduce 80) ((T_CONSTANT_ENCAPSED_ST [...]
+ #s(hash-table size 12466 test equal rehash-size 1.5 rehash-threshold 0.8125
data (0 ((("!") reduce 80) (("\"") reduce 80) (($) reduce 80) (("$") reduce 80)
(("(") reduce 80) (("+") reduce 80) (("-") reduce 80) ((";") reduce 80) (("@")
reduce 80) ((T_ABSTRACT) reduce 80) ((T_ARRAY) reduce 80) ((T_ARRAY_CAST)
reduce 80) ((T_ATTRIBUTE) reduce 80) ((T_BOOL_CAST) reduce 80) ((T_BREAK)
reduce 80) ((T_CLASS) reduce 80) ((T_CLASS_C) reduce 80) ((T_CLONE) reduce 80)
((T_CONST) reduce 80) ((T_CO [...]
"The generated distinct action-tables.")
(defvar
phps-mode-parser--goto-tables
- #s(hash-table size 42072 test equal rehash-size 1.5 rehash-threshold 0.8125
data (0 0 1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 11 11 12 12 13 13 14 14 15
9 16 9 17 15 18 16 19 9 20 17 21 18 22 19 23 9 24 9 25 20 26 21 27 22 28 23 29
24 30 25 31 9 32 9 33 9 34 26 35 27 36 9 37 9 38 28 39 29 40 30 41 31 42 32 43
33 44 34 45 9 46 9 47 35 48 36 49 9 50 37 51 9 52 38 53 9 54 39 55 9 56 9 57 9
58 40 59 9 60 41 61 42 62 43 63 44 64 45 65 46 66 47 67 48 68 49 69 50 70 51 71
9 72 9 73 52 74 53 [...]
+ #s(hash-table size 28048 test equal rehash-size 1.5 rehash-threshold 0.8125
data (0 0 1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 8 11 10 12 11 13 12 14 13 15
14 16 15 17 8 18 16 19 17 20 8 21 18 22 19 23 20 24 8 25 8 26 21 27 22 28 23 29
24 30 25 31 26 32 8 33 8 34 8 35 27 36 28 37 8 38 8 39 29 40 30 41 31 42 32 43
33 44 34 45 35 46 8 47 36 48 37 49 38 50 8 51 39 52 8 53 40 54 8 55 41 56 8 57
8 58 8 59 42 60 8 61 43 62 44 63 45 64 46 65 47 66 48 67 49 68 50 69 51 70 52
71 53 72 54 73 8 74 [...]
"The generated goto-tables.")
(defvar
phps-mode-parser--distinct-goto-tables
- #s(hash-table size 18699 test equal rehash-size 1.5 rehash-threshold 0.8125
data (0 ((top_statement_list 1)) 1 (("!" 2) ("\"" 3) ("$" 4) ("(" 5) ("+" 6)
("-" 7) ("@" 8) (T_ABSTRACT 9) (T_ARRAY 10) (T_ARRAY_CAST 11) (T_ATTRIBUTE 12)
(T_BOOL_CAST 13) (T_BREAK 14) (T_CLASS 15) (T_CLASS_C 16) (T_CLONE 17) (T_CONST
18) (T_CONSTANT_ENCAPSED_STRING 19) (T_CONTINUE 20) (T_DEC 21) (T_DECLARE 22)
(T_DIR 23) (T_DNUMBER 24) (T_DO 25) (T_DOUBLE_CAST 26) (T_ECHO 27) (T_EMPTY 28)
(T_EVAL 29) (T_EXIT [...]
+ #s(hash-table size 18699 test equal rehash-size 1.5 rehash-threshold 0.8125
data (0 ((top_statement_list 1)) 1 (("!" 2) ("\"" 3) ("$" 4) ("(" 5) ("+" 6)
("-" 7) (";" 8) ("@" 9) (T_ABSTRACT 10) (T_ARRAY 11) (T_ARRAY_CAST 12)
(T_ATTRIBUTE 13) (T_BOOL_CAST 14) (T_BREAK 15) (T_CLASS 16) (T_CLASS_C 17)
(T_CLONE 18) (T_CONST 19) (T_CONSTANT_ENCAPSED_STRING 20) (T_CONTINUE 21)
(T_DEC 22) (T_DECLARE 23) (T_DIR 24) (T_DNUMBER 25) (T_DO 26) (T_DOUBLE_CAST
27) (T_ECHO 28) (T_EMPTY 29) (T_EVAL 30) [...]
"The generated distinct goto-tables.")
(defvar
phps-mode-parser--table-productions-number-reverse
- #s(hash-table size 730 test equal rehash-size 1.5 rehash-threshold 0.8125
data (0 ((start) (top_statement_list)) 1 ((reserved_non_modifiers) (T_INCLUDE))
2 ((reserved_non_modifiers) (T_INCLUDE_ONCE)) 3 ((reserved_non_modifiers)
(T_EVAL)) 4 ((reserved_non_modifiers) (T_REQUIRE)) 5 ((reserved_non_modifiers)
(T_REQUIRE_ONCE)) 6 ((reserved_non_modifiers) (T_LOGICAL_OR)) 7
((reserved_non_modifiers) (T_LOGICAL_XOR)) 8 ((reserved_non_modifiers)
(T_LOGICAL_AND)) 9 ((reserved_non_modifiers) (T_ [...]
+ #s(hash-table size 730 test equal rehash-size 1.5 rehash-threshold 0.8125
data (0 ((start) (top_statement_list)) 1 ((reserved_non_modifiers) (T_INCLUDE))
2 ((reserved_non_modifiers) (T_INCLUDE_ONCE)) 3 ((reserved_non_modifiers)
(T_EVAL)) 4 ((reserved_non_modifiers) (T_REQUIRE)) 5 ((reserved_non_modifiers)
(T_REQUIRE_ONCE)) 6 ((reserved_non_modifiers) (T_LOGICAL_OR)) 7
((reserved_non_modifiers) (T_LOGICAL_XOR)) 8 ((reserved_non_modifiers)
(T_LOGICAL_AND)) 9 ((reserved_non_modifiers) (T_ [...]
"The hash-table indexed by production-number and value is production.")
(defvar
phps-mode-parser--table-look-aheads
- #s(hash-table size 217 test equal rehash-size 1.5 rehash-threshold 0.8125
data (("!") t ("\"") t ($) t ("$") t ("%") t ("&") t ("'") t ("(") t (")") t
("*") t ("+") t (",") t ("-") t (".") t ("/") t (":") t (";") t ("<") t ("=") t
(">") t ("?") t ("@") t (PREC_ARROW_FUNCTION) t (T_ABSTRACT) t (T_AND_EQUAL) t
(T_ARG) t (T_ARRAY) t (T_ARRAY_CAST) t (T_ARROW) t (T_AS) t (T_ASSIGN) t
(T_ATTRIBUTE) t (T_BAD) t (T_BOOLEAN_AND) t (T_BOOLEAN_OR) t (T_BOOL_CAST) t
(T_BREAK) t (T_CALL) t (T_CALL [...]
+ #s(hash-table size 217 test equal rehash-size 1.5 rehash-threshold 0.8125
data (("!") t ("\"") t ($) t ("$") t ("%") t ("&") t ("(") t (")") t ("*") t
("+") t (",") t ("-") t (".") t ("/") t (":") t (";") t ("<") t ("=") t (">") t
("?") t ("@") t (PREC_ARROW_FUNCTION) t (T_ABSTRACT) t (T_AND_EQUAL) t
(T_ARRAY) t (T_ARRAY_CAST) t (T_AS) t (T_ATTRIBUTE) t (T_BOOLEAN_AND) t
(T_BOOLEAN_OR) t (T_BOOL_CAST) t (T_BREAK) t (T_CALLABLE) t (T_CASE) t
(T_CATCH) t (T_CLASS) t (T_CLASS_C) t (T_CLON [...]
"The hash-table of valid look-aheads.")
(defvar
phps-mode-parser--table-terminal-p
- #s(hash-table size 217 test equal rehash-size 1.5 rehash-threshold 0.8125
data ("!" t "%" t "&" t "(" t ")" t "*" t "+" t "." t "," t "-" t "/" t ":" t
";" t "<" t "=" t ">" t "?" t "@" t "[" t "]" t "}" t "{" t "^" t "|" t "~" t
"`" t "'" t "\"" t "$" t PREC_ARROW_FUNCTION t T_ABSTRACT t T_AND_EQUAL t T_ARG
t T_ARRAY t T_ARRAY_CAST t T_ARROW t T_AS t T_ASSIGN t T_ATTRIBUTE t T_BAD t
T_BOOL_CAST t T_BOOLEAN_AND t T_BOOLEAN_OR t T_BREAK t T_CALL t T_CALLABLE t
T_CASE t T_CATCH t T_CLASS [...]
+ #s(hash-table size 217 test equal rehash-size 1.5 rehash-threshold 0.8125
data (T_NUM_STRING t T_CURLY_OPEN t T_STRING_VARNAME t
T_DOLLAR_OPEN_CURLY_BRACES t "$" t T_NULLSAFE_OBJECT_OPERATOR t
T_OBJECT_OPERATOR t T_END_HEREDOC t T_START_HEREDOC t T_DNUMBER t T_LNUMBER t
"\"" t T_CONSTANT_ENCAPSED_STRING t T_ENCAPSED_AND_WHITESPACE t
PREC_ARROW_FUNCTION t T_YIELD_FROM t "`" t "@" t T_UNSET_CAST t T_BOOL_CAST t
T_OBJECT_CAST t T_ARRAY_CAST t T_STRING_CAST t T_DOUBLE_CAST t T_INT_CAST t T
[...]
"The hash-table of valid terminals.")
(defvar
phps-mode-parser--table-non-terminal-p
- #s(hash-table size 217 test equal rehash-size 1.5 rehash-threshold 0.8125
data (absolute_trait_method_reference t alt_if_stmt t alt_if_stmt_without_else
t anonymous_class t argument t argument_list t array_object_dereferencable t
array_pair t array_pair_list t attribute t attribute_decl t attribute_group t
attributed_class_statement t attributed_parameter t attributed_statement t
attributes t backticks_expr t backup_doc_comment t backup_fn_flags t
backup_lex_pos t callable_expr t calla [...]
+ #s(hash-table size 217 test equal rehash-size 1.5 rehash-threshold 0.8125
data (isset_variable t isset_variables t encaps_var_offset t encaps_var t
array_pair t possible_array_pair t non_empty_array_pair_list t static_member t
property_name t callable_variable t array_object_dereferencable t
fully_dereferencable t class_constant t constant t dereferencable_scalar t
encaps_list t new_variable t callable_expr t variable_class_name t member_name
t function_call t lexical_var t lexical_var [...]
"The hash-table of valid non-terminals.")
(defvar
@@ -68,16 +68,6 @@
"The hash-table of translations.")
(defvar
- phps-mode-parser-lex-analyzer--get-function
- (lambda (token) (save-current-buffer (set-buffer "*PHPs Lexer*") (let
((start (car (cdr token))) (end (cdr (cdr token)))) (if (<= end (point-max))
(progn (buffer-substring-no-properties start end))))))
- "The lex-analyzer get function.")
-
-(defvar
- phps-mode-parser-lex-analyzer--reset-function
- nil
- "The lex-analyzer reset function.")
-
-(defvar
phps-mode-parser--e-identifier
'%empty
"The e-identifier.")
@@ -105,165 +95,21 @@
nil
"Non-nil means move index to value.")
+(defvar
+ phps-mode-parser-lex-analyzer--get-function
+ (lambda (token) (save-current-buffer (set-buffer "*PHPs Lexer*") (let
((start (car (cdr token))) (end (cdr (cdr token)))) (if (<= end (point-max))
(progn (buffer-substring-no-properties start end))))))
+ "The lex-analyzer get function.")
(defvar
phps-mode-parser-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))
-
- ;; 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))
-
- (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))))
+ (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)))))
+ "The lex-analyzer function.")
- (setq
- temp-token-list-index
- (1+ temp-token-list-index))
- )))))
+(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)))))
+ "The lex-analyzer reset function.")
- (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.")
;;; Functions:
- [elpa] externals/phps-mode 945571c 65/96: Fixed byte-compilation issues with parser, (continued)
- [elpa] externals/phps-mode 945571c 65/96: Fixed byte-compilation issues with parser, Christian Johansson, 2021/10/29
- [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 <=
- [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, 2021/10/29
- [elpa] externals/phps-mode 238f967 76/96: Cleaned up lex function, Christian Johansson, 2021/10/29