227
227
228
228
; ;;; The tokenizer.
229
229
230
- (cl-defstruct gnuplot-token
230
+ (cl-defstruct (gnuplot-context--token
231
+ (:constructor gnuplot-context--token-make)
232
+ (:copier nil ))
231
233
start ; Buffer start position
232
234
end ; Buffer end position
233
235
id ; Text
250
252
`((looking-at , regexp )
251
253
(let ((str (match-string-no-properties 0 )))
252
254
(forward-char (length str))
253
- (make- gnuplot-token :id str
255
+ (gnuplot-context-- token-make :id str
254
256
:type ', token-type
255
257
:start (match-beginning 0 )
256
258
:end (match-end 0 ))))))
257
259
rules))))
258
260
259
261
(defun gnuplot-context--tokenize (&optional completing-p )
260
262
" Tokenize the Gnuplot command at point.
261
- Return a list of `gnuplot-token' objects.
263
+ Return a list of `gnuplot-context-- token' objects.
262
264
263
265
If COMPLETING-P is non-nil, omits the token at point if it is a
264
266
name; otherwise continues tokenizing up to the token at point. FIXME."
@@ -294,7 +296,7 @@ name; otherwise continues tokenizing up to the token at point. FIXME."
294
296
(let* ((bounds (bounds-of-thing-at-point 'sexp ))
295
297
(to (or (cdr bounds) stop-point)))
296
298
(goto-char to)
297
- (make- gnuplot-token
299
+ (gnuplot-context-- token-make
298
300
:id (buffer-substring-no-properties from to)
299
301
:type 'string
300
302
:start from :end to)))
@@ -312,8 +314,8 @@ name; otherwise continues tokenizing up to the token at point. FIXME."
312
314
; ; in that position for completion.
313
315
(if (and completing-p
314
316
tokens
315
- (eq (gnuplot-token-type (car tokens)) 'name )
316
- (<= (point ) (gnuplot-token-end (car tokens))))
317
+ (eq (gnuplot-context-- token-type (car tokens)) 'name )
318
+ (<= (point ) (gnuplot-context-- token-end (car tokens))))
317
319
(pop tokens))
318
320
319
321
(nreverse tokens)))
@@ -333,15 +335,15 @@ name; otherwise continues tokenizing up to the token at point. FIXME."
333
335
; ; Match any token (fails only at end of command).
334
336
; ;
335
337
; ; (literal LITERAL NO-COMPLETE)
336
- ; ; Match token with `gnuplot-token-id' LITERAL or fail. If we
338
+ ; ; Match token with `gnuplot-context-- token-id' LITERAL or fail. If we
337
339
; ; have reached the token before point, include LITERAL in the
338
340
; ; completion list unless NO-COMPLETE is non-`nil' .
339
341
; ;
340
342
; ; (token-type TYPE)
341
- ; ; Match a token with `gnuplot-token-type' TYPE, or fail.
343
+ ; ; Match a token with `gnuplot-context-- token-type' TYPE, or fail.
342
344
; ;
343
345
; ; (keyword REGEXP NAME)
344
- ; ; Match any token whose `gnuplot-token-id' matches REGEXP. Use
346
+ ; ; Match any token whose `gnuplot-context-- token-id' matches REGEXP. Use
345
347
; ; NAME for the completion list.
346
348
; ;
347
349
; ; (jump OFFSET FIXED)
@@ -1804,7 +1806,7 @@ there."
1804
1806
(opcode (car inst))
1805
1807
(token (car tokens))
1806
1808
(end-of-tokens (null tokens)))
1807
- (gnuplot-context--trace " %s\t %s\t %s\n " pc inst (and token (gnuplot-token-id token)))
1809
+ (gnuplot-context--trace " %s\t %s\t %s\n " pc inst (and token (gnuplot-context-- token-id token)))
1808
1810
1809
1811
(cl-case opcode
1810
1812
; ; (literal LITERAL NO-COMPLETE)
@@ -1817,7 +1819,7 @@ there."
1817
1819
(push expect gnuplot-context--completions))
1818
1820
(fail))
1819
1821
1820
- ((not (equal (gnuplot-token-id token) expect))
1822
+ ((not (equal (gnuplot-context-- token-id token) expect))
1821
1823
(fail))
1822
1824
1823
1825
; ; otherwise succeed
@@ -1827,7 +1829,7 @@ there."
1827
1829
((token-type)
1828
1830
(let ((expect (cadr inst)))
1829
1831
(if (or end-of-tokens
1830
- (not (eq (gnuplot-token-type token) expect)))
1832
+ (not (eq (gnuplot-context-- token-type token) expect)))
1831
1833
(fail)
1832
1834
(advance))))
1833
1835
@@ -1841,12 +1843,12 @@ there."
1841
1843
(push name gnuplot-context--completions)
1842
1844
(fail))
1843
1845
1844
- ((not (string-match-p regexp (gnuplot-token-id token)))
1846
+ ((not (string-match-p regexp (gnuplot-context-- token-id token)))
1845
1847
(fail))
1846
1848
1847
1849
; ; otherwise succeed
1848
1850
(t
1849
- (setf (gnuplot-token-id token) name)
1851
+ (setf (gnuplot-context-- token-id token) name)
1850
1852
(advance)))))
1851
1853
1852
1854
; ; (any): match any token
@@ -1999,7 +2001,7 @@ there."
1999
2001
(setq gnuplot-context--info-at-point
2000
2002
(cond
2001
2003
((eq info 'first-token )
2002
- (gnuplot-token-id (car position)))
2004
+ (gnuplot-context-- token-id (car position)))
2003
2005
((functionp info) (funcall info))
2004
2006
(t info)))
2005
2007
(when gnuplot-context--info-at-point
@@ -2141,7 +2143,7 @@ clause."
2141
2143
(3d-p (gnuplot-context--capture-group :splot-command ))
2142
2144
(column-description nil ))
2143
2145
(if with-style
2144
- (let ((with-style-string (gnuplot-token-id (car with-style))))
2146
+ (let ((with-style-string (gnuplot-context-- token-id (car with-style))))
2145
2147
(setq column-description
2146
2148
(or (and 3d-p
2147
2149
(cdr (assoc with-style-string gnuplot-context--using-3d-eldoc)))
0 commit comments