Skip to content

Commit 068f9b9

Browse files
authored
Merge pull request #97 from gwaithimirdain/parse-cmdstart
rewrite narya-parse-cmdstart, fix #96
2 parents f3703f2 + 358c9ab commit 068f9b9

File tree

1 file changed

+25
-5
lines changed

1 file changed

+25
-5
lines changed

proofgeneral/narya.el

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -133,11 +133,31 @@ Does *not* find overlays that we are at the beginning or end of (outside the mar
133133
(forward-char 1))
134134

135135
(defun narya-parse-cmdstart ()
136-
"Parse a complete command, not including any comments that follow it."
137-
(let ((parsed (proof-script-generic-parse-cmdstart)))
138-
(when (eq parsed 'cmd)
139-
(narya-skip-comments-backwards))
140-
parsed))
136+
"Parse a complete command, not including any comments that follow it.
137+
For `proof-script-parse-function'.
138+
Based on `proof-script-generic-parse-cmdstart'."
139+
(let ((case-fold-search proof-case-fold-search))
140+
(if (looking-at proof-script-comment-start-regexp)
141+
;; Find end of comment
142+
;; Narya TODO: Why don't we iterate this moving past whitespace too?
143+
(if (proof-script-generic-parse-find-comment-end) 'comment)
144+
;; Handle non-comments: assumed to be commands
145+
(when (looking-at proof-script-command-start-regexp)
146+
;; We've got at least the beginnings of a command, skip past it
147+
(goto-char (match-end 0))
148+
;; Find next command start or end of buffer
149+
(when (or (and (re-search-forward proof-script-command-start-regexp nil 'movetolimit)
150+
(goto-char (match-beginning 0)))
151+
(eq (point) (point-max)))
152+
;; If we're in an unclosed comment, back out of it
153+
(when (proof-looking-at-syntactic-context)
154+
(while (proof-looking-at-syntactic-context)
155+
(backward-char 1))
156+
;; That backs up too far
157+
(forward-char 1))
158+
;; Then back across complete comments
159+
(narya-skip-comments-backwards)
160+
'cmd)))))
141161

142162
(defun narya-retract-target (target)
143163
"Retract the span TARGET as in `proof-retract-target', if it exists.

0 commit comments

Comments
 (0)