[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/gnuplot 3245468 084/184: Fixes to context-sensitive gramma
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/gnuplot 3245468 084/184: Fixes to context-sensitive grammar |
Date: |
Sun, 29 Aug 2021 11:03:20 -0400 (EDT) |
branch: elpa/gnuplot
commit 32454689437d0784b2ec9ef95c00d08ce5f8c8a0
Author: joddie <jonxfield@gmail.com>
Commit: joddie <jonxfield@gmail.com>
Fixes to context-sensitive grammar
- old-style one-line if() commands.
These needed a hack to gnuplot-tokenize to make sure the if()
statement is parsed from the beginning (normally, we only have to
start from the nearest preceding semicolon). Ugly but works.
- new-style block-structured if and do commands
The grammar for these is more or less right, but in most cases the
whole production won't actually match because the tokenizer doesn't
bother finding the beginning of the block and continuing over
several lines. This way means less unneeded work, and is probably
good enough for the purpose.
- allow expressions, not just numbers, in "set label"
---
gnuplot-context.el | 47 +++++++++++++++++++++++++++++++++++++----------
1 file changed, 37 insertions(+), 10 deletions(-)
diff --git a/gnuplot-context.el b/gnuplot-context.el
index 07632bd..faf53cb 100644
--- a/gnuplot-context.el
+++ b/gnuplot-context.el
@@ -406,7 +406,7 @@ off. With no argument, toggle context-sensitive mode."
start ; Buffer start position
end ; Buffer end position
id ; Text
- type) ; name, number, string, operator, end-of-command
+ type) ; a symbol: name, number, string, operator, separator
(defvar gnuplot-operator-regexp
(eval-when-compile
@@ -440,7 +440,11 @@ name; otherwise continues tokenizing up to the token at
point. FIXME"
(stop-point (min (point)
(gnuplot-point-at-end-of-command))))
(save-excursion
- (gnuplot-beginning-of-command)
+ (if (save-excursion ; HACK FIXME
+ (gnuplot-beginning-of-continuation)
+ (looking-at "\\s-*if\\s-*("))
+ (gnuplot-beginning-of-continuation)
+ (gnuplot-beginning-of-command))
(while
;; Skip whitespace and continuation lines
(progn
@@ -457,7 +461,8 @@ name; otherwise continues tokenizing up to the token at
point. FIXME"
((gnuplot-tokenize-by-regexps
("[A-Za-z_][A-Za-z0-9_]*" name)
("[0-9]+\\(\\.[0-9]*\\)?\\([eE][+-]?[0-9]+\\)?\\|\\.[0-9]+\\([eE][+-]?[0-9]+\\)?"
number)
- (gnuplot-operator-regexp operator)))
+ (gnuplot-operator-regexp operator)
+ (";" separator)))
((looking-at "['\"]")
(let* ((bounds (bounds-of-thing-at-point 'sexp))
@@ -595,7 +600,7 @@ name; otherwise continues tokenizing up to the token at
point. FIXME"
((symbolp pat)
(case pat
((any) `((any)))
- ((name number string) `((token-type ,pat)))
+ ((name number string separator) `((token-type ,pat)))
(t `((call ,pat)))))
;; Syntactic sugar: write sequences (sequence ...) as vectors [...]
@@ -910,7 +915,28 @@ name; otherwise continues tokenizing up to the token at
point. FIXME"
set-command cd-command call-command simple-command
eval-command load-command lower-raise-command pause-command
save-command system-command test-command undefine-command
- update-command assignment)))
+ update-command assignment if-command do-command)))
+
+ (command-list
+ (delimited-list command separator))
+
+ (block ["{" command-list "}"])
+
+;;; old-style one-line if(..) command
+ (if-command
+ (info-keyword
+ "if" parenthesized-expression command-list
+ (maybe separator "else" command-list)))
+
+;;; new-style block-structured if
+ (new-if-command
+ (info-keyword
+ "if" parenthesized-expression block
+ (maybe "else" block)))
+
+;;; block-structured "do"
+ (do-command
+ (info-keyword "do" iteration-spec block))
;;; PLOT, SPLOT commands
(plot-command
@@ -972,10 +998,11 @@ name; otherwise continues tokenizing up to the token at
point. FIXME"
;; Iteration: for [... ]
(iteration-spec
[(:info "iteration")
- "for" "[" name
- (either ["=" (delimited-list expression ":")]
- ["in" expression])
- "]"])
+ (many
+ "for" "[" name
+ (either ["=" (delimited-list expression ":")]
+ ["in" expression])
+ "]")])
;; Expressions to plot can be preceded by any number of
;; assignments, with or without commas
@@ -1445,7 +1472,7 @@ name; otherwise continues tokenizing up to the token at
point. FIXME"
(set-label-clause
["label"
- (maybe number)
+ (maybe expression)
(either label-clause-component expression)
(many label-clause-component)])
- [nongnu] elpa/gnuplot 18dccc2 058/184: Merge branch 'context' into devel, (continued)
- [nongnu] elpa/gnuplot 18dccc2 058/184: Merge branch 'context' into devel, ELPA Syncer, 2021/08/29
- [nongnu] elpa/gnuplot d4f8c3a 082/184: display progress while running parse tests, ELPA Syncer, 2021/08/29
- [nongnu] elpa/gnuplot 6da76ee 052/184: Merge branch 'devel', ELPA Syncer, 2021/08/29
- [nongnu] elpa/gnuplot d26d498 062/184: Added a customization option for gnuplot-inline-image-mode., ELPA Syncer, 2021/08/29
- [nongnu] elpa/gnuplot d70c94a 065/184: Better docstrings for context-sensitive and inline-image modes, ELPA Syncer, 2021/08/29
- [nongnu] elpa/gnuplot 43effb0 068/184: Add gnuplot-context to makefiles., ELPA Syncer, 2021/08/29
- [nongnu] elpa/gnuplot f0b1ea7 085/184: Update lists of font-lock keywords., ELPA Syncer, 2021/08/29
- [nongnu] elpa/gnuplot 70dd22e 060/184: Keyboard shortcut and menu item for toggling inline mode., ELPA Syncer, 2021/08/29
- [nongnu] elpa/gnuplot a0fee02 086/184: use `many1' for iteration spec, and tweak its test case, ELPA Syncer, 2021/08/29
- [nongnu] elpa/gnuplot 2dc71de 077/184: Move window-full-height-p up with other compatibility hacks, ELPA Syncer, 2021/08/29
- [nongnu] elpa/gnuplot 3245468 084/184: Fixes to context-sensitive grammar,
ELPA Syncer <=
- [nongnu] elpa/gnuplot a290617 079/184: Make info window/frame handling work alike in context and non-context modes, ELPA Syncer, 2021/08/29
- [nongnu] elpa/gnuplot af7e8de 073/184: Remove references to obsolete kw-compl and hilit19 packages, ELPA Syncer, 2021/08/29
- [nongnu] elpa/gnuplot 630c945 093/184: Clean up build process to be closer to gnuplot source tree., ELPA Syncer, 2021/08/29
- [nongnu] elpa/gnuplot c827a90 090/184: Load gnuplot-eldoc only if needed, ELPA Syncer, 2021/08/29
- [nongnu] elpa/gnuplot cabfc6c 088/184: fix annoying delay in indentation with blinking paren mode, ELPA Syncer, 2021/08/29
- [nongnu] elpa/gnuplot 327d564 091/184: Fix indentation: only outdent a maximum of one closing brace per line, ELPA Syncer, 2021/08/29
- [nongnu] elpa/gnuplot 7046fe1 092/184: Misc cleanup and documentation, ELPA Syncer, 2021/08/29
- [nongnu] elpa/gnuplot a25b290 094/184: Update README for new release., ELPA Syncer, 2021/08/29
- [nongnu] elpa/gnuplot 0134457 098/184: Add configure scripts, etc. back to repository for easier building, ELPA Syncer, 2021/08/29
- [nongnu] elpa/gnuplot 1b8e0e3 095/184: Update included info file for Gnuplot 4.6, ELPA Syncer, 2021/08/29