106106; ; notation as follows:
107107; ;
108108; ; any
109- ; ; Match any token
109+ ; ; Match any token
110110; ;
111111; ; name, number, string, separator
112- ; ; Match a token of the given type. "Separator" is semicolon, the
113- ; ; statement separator.
112+ ; ; Match a token of the given type. "Separator" is semicolon, the
113+ ; ; statement separator.
114114; ;
115115; ; Any other symbol
116- ; ; Match another named rule in the grammar. May be recursive.
116+ ; ; Match another named rule in the grammar. May be recursive.
117117; ;
118118; ; "STRING"
119- ; ; Match literally: a token with exactly the text "STRING".
119+ ; ; Match literally: a token with exactly the text "STRING".
120120; ;
121121; ; (kw KEYWORD ALIASES ...)
122- ; ; Match abbreviated Gnuplot keywords. KEYWORD can be a string or
123- ; ; a cons (PREFIX . SUFFIX). In the latter case, this pattern
124- ; ; will match PREFIX plus any number of characters from the
125- ; ; beginning of SUFFIX. Any literal string from ALIASES will
126- ; ; also match. The token-id of the matching token is mutated to
127- ; ; the canonical value of KEYWORD.
128- ; ; Example:
129- ; ; (kw ("linew" ."idth") "lw") matches "linew", "linewi",
130- ; ; ... "linewidth" as well as "lw". Any of these tokens will
131- ; ; appear as "linewidth" in subsequent processing. (This is
132- ; ; important for the "info-keyword" form, see below).
122+ ; ; Match abbreviated Gnuplot keywords. KEYWORD can be a string or
123+ ; ; a cons (PREFIX . SUFFIX). In the latter case, this pattern
124+ ; ; will match PREFIX plus any number of characters from the
125+ ; ; beginning of SUFFIX. Any literal string from ALIASES will
126+ ; ; also match. The token-id of the matching token is mutated to
127+ ; ; the canonical value of KEYWORD.
128+ ; ; Example:
129+ ; ; (kw ("linew" ."idth") "lw") matches "linew", "linewi",
130+ ; ; ... "linewidth" as well as "lw". Any of these tokens will
131+ ; ; appear as "linewidth" in subsequent processing. (This is
132+ ; ; important for the "info-keyword" form, see below).
133133; ;
134134; ; The other pattern forms combine simpler patterns, much like regular
135135; ; expressions or PEGs (parsing expression grammars):
136136; ;
137137; ; (sequence { (:eldoc "eldoc string") }
138138; ; { (:info "info page") }
139139; ; { (:no-info) }
140- ; ; PATTERN PATTERN... )
141- ; ; Match all the PATTERNs in sequence or fail. Sequences can also
142- ; ; have optional ElDoc strings and info pages associated with
143- ; ; them; the innermost ElDoc or info page around point is the one
144- ; ; shown to the user. Alternatively, either property may be a
145- ; ; symbol, which should be a function to be called to get the
146- ; ; real value. Finally, if no ElDoc string is specified but the
147- ; ; variable `gnuplot-eldoc-hash' contains a value for the name of
148- ; ; the info page at point, that value is used as the ElDoc string
149- ; ; instead.
140+ ; ; PATTERN PATTERN... )
141+ ; ; Match all the PATTERNs in sequence or fail. Sequences can also
142+ ; ; have optional ElDoc strings and info pages associated with
143+ ; ; them; the innermost ElDoc or info page around point is the one
144+ ; ; shown to the user. Alternatively, either property may be a
145+ ; ; symbol, which should be a function to be called to get the
146+ ; ; real value. Finally, if no ElDoc string is specified but the
147+ ; ; variable `gnuplot-eldoc-hash' contains a value for the name of
148+ ; ; the info page at point, that value is used as the ElDoc string
149+ ; ; instead.
150150; ;
151- ; ; For better readability, sequence forms can also be written as
152- ; ; a vector, omitting the `sequence' : [PATTERN PATTERN ...]
151+ ; ; For better readability, sequence forms can also be written as
152+ ; ; a vector, omitting the `sequence' : [PATTERN PATTERN ...]
153153; ;
154154; ; (either PATTERN PATTERN...)
155- ; ; Match the first PATTERN to succeed, or fail if none
156- ; ; matches. Like regexp `|' .
155+ ; ; Match the first PATTERN to succeed, or fail if none
156+ ; ; matches. Like regexp `|' .
157157; ;
158158; ; (many PATTERN)
159- ; ; Match PATTERN zero or more times, greedily; like regexp
160- ; ; `*' . Unlike a regular expression matcher, the parsing machine
161- ; ; will not backtrack and try to match fewer times if a later
162- ; ; part of the pattern fails. This applies equally to the other
163- ; ; non-deterministic forms "either" and "maybe".
159+ ; ; Match PATTERN zero or more times, greedily; like regexp
160+ ; ; `*' . Unlike a regular expression matcher, the parsing machine
161+ ; ; will not backtrack and try to match fewer times if a later
162+ ; ; part of the pattern fails. This applies equally to the other
163+ ; ; non-deterministic forms "either" and "maybe".
164164; ;
165165; ; (maybe PATTERN)
166- ; ; Match PATTERN zero or one times, like regexp `?' .
166+ ; ; Match PATTERN zero or one times, like regexp `?' .
167167; ;
168168; ; (capture NAME PATTERN)
169- ; ; Match PATTERN, capturing the tokens in a capture group named
170- ; ; NAME. Capture groups are stored in `gnuplot-captures'
171- ; ; and can be retrieved using `gnuplot-capture-group' . This is
172- ; ; used to store the plotting style, which we need in order to
173- ; ; give the correct ElDoc string for "using" clauses, and for
174- ; ; info keywords (see below)
169+ ; ; Match PATTERN, capturing the tokens in a capture group named
170+ ; ; NAME. Capture groups are stored in `gnuplot-captures'
171+ ; ; and can be retrieved using `gnuplot-capture-group' . This is
172+ ; ; used to store the plotting style, which we need in order to
173+ ; ; give the correct ElDoc string for "using" clauses, and for
174+ ; ; info keywords (see below)
175175; ;
176176; ; (info-keyword PATTERN)
177- ; ; Match PATTERN, and use whatever the value of the first token
178- ; ; it matches is to look up info pages for this pattern. Most
179- ; ; Gnuplot info pages have the same name as the keyword they
180- ; ; document, so by using this we only have to put :info
181- ; ; properties on the few that don't, such as "set".
177+ ; ; Match PATTERN, and use whatever the value of the first token
178+ ; ; it matches is to look up info pages for this pattern. Most
179+ ; ; Gnuplot info pages have the same name as the keyword they
180+ ; ; document, so by using this we only have to put :info
181+ ; ; properties on the few that don't, such as "set".
182182; ;
183183; ; For convenience, "many", "maybe", "capture" and "info-keyword"
184184; ; wrap the rest of their arguments in an implicit "sequence" form,
185185; ; so we can write (maybe "," expression) instead of
186186; ; (maybe (sequence "," expression))
187187; ;
188188; ; (delimited-list PATTERN SEPARATOR)
189- ; ; Match a list of PATTERNs separated by SEPARATOR. Sugar for:
190- ; ; (sequence PATTERN (many (sequence SEPARATOR PATTERN)))
189+ ; ; Match a list of PATTERNs separated by SEPARATOR. Sugar for:
190+ ; ; (sequence PATTERN (many (sequence SEPARATOR PATTERN)))
191191; ;
192192; ; (assert LISP-FORM)
193- ; ; Evaluate LISP-FORM and fail if it returns NIL. We need this in
194- ; ; the patterns for "plot" and "splot" to check whether the
195- ; ; command at point should be parsed in parametric mode or
196- ; ; not. See `gnuplot-guess-parametric-p' .
193+ ; ; Evaluate LISP-FORM and fail if it returns NIL. We need this in
194+ ; ; the patterns for "plot" and "splot" to check whether the
195+ ; ; command at point should be parsed in parametric mode or
196+ ; ; not. See `gnuplot-guess-parametric-p' .
197197; ;
198198; ;
199199; ; Bugs, TODOs, etc.
251251; ;;; The tokenizer.
252252
253253(defstruct gnuplot-token
254- start ; Buffer start position
255- end ; Buffer end position
256- id ; Text
257- type) ; a symbol: name, number, string, operator, separator
254+ start ; Buffer start position
255+ end ; Buffer end position
256+ id ; Text
257+ type) ; a symbol: name, number, string, operator, separator
258258
259259(defvar gnuplot-operator-regexp
260260 (eval-when-compile
@@ -353,41 +353,41 @@ name; otherwise continues tokenizing up to the token at point. FIXME."
353353; ; instructions" are the following:
354354; ;
355355; ; (any)
356- ; ; Match any token (fails only at end of command).
356+ ; ; Match any token (fails only at end of command).
357357; ;
358358; ; (literal LITERAL NO-COMPLETE)
359- ; ; Match token with `gnuplot-token-id' LITERAL or fail. If we
360- ; ; have reached the token before point, include LITERAL in the
361- ; ; completion list unless NO-COMPLETE is non-`nil' .
359+ ; ; Match token with `gnuplot-token-id' LITERAL or fail. If we
360+ ; ; have reached the token before point, include LITERAL in the
361+ ; ; completion list unless NO-COMPLETE is non-`nil' .
362362; ;
363363; ; (token-type TYPE)
364- ; ; Match a token with `gnuplot-token-type' TYPE, or fail.
364+ ; ; Match a token with `gnuplot-token-type' TYPE, or fail.
365365; ;
366366; ; (keyword REGEXP NAME)
367- ; ; Match any token whose `gnuplot-token-id' matches REGEXP. Use
368- ; ; NAME for the completion list.
367+ ; ; Match any token whose `gnuplot-token-id' matches REGEXP. Use
368+ ; ; NAME for the completion list.
369369; ;
370370; ; (jump OFFSET FIXED)
371- ; ; Jump to (set PC to) OFFSET if FIXED is non-nil, otherwise to
372- ; ; PC + OFFSET
371+ ; ; Jump to (set PC to) OFFSET if FIXED is non-nil, otherwise to
372+ ; ; PC + OFFSET
373373; ;
374374; ; (call OFFSET FIXED)
375- ; ; Like "jump", but push a return address onto the stack for
376- ; ; (return). (The compiler adds the name of the rule being called
377- ; ; as a fourth element on the end of the list, but this is just a
378- ; ; comment for debugging purposes).
375+ ; ; Like "jump", but push a return address onto the stack for
376+ ; ; (return). (The compiler adds the name of the rule being called
377+ ; ; as a fourth element on the end of the list, but this is just a
378+ ; ; comment for debugging purposes).
379379; ;
380380; ; (return)
381- ; ; Return to the PC address on top of the stack, or finish
382- ; ; matching if stack is empty. (Usually this doesn't happen,
383- ; ; because the machine stops as soon as it gets to the token at
384- ; ; point).
381+ ; ; Return to the PC address on top of the stack, or finish
382+ ; ; matching if stack is empty. (Usually this doesn't happen,
383+ ; ; because the machine stops as soon as it gets to the token at
384+ ; ; point).
385385; ;
386386; ; (choice OFFSET)
387- ; ; Push a backtracking entry for location PC + OFFSET onto the
388- ; ; backtracking stack. Backtracking entries save the contents of
389- ; ; the call stack, position in the token list, the values of
390- ; ; capture groups, and the record of loop progress (see below).
387+ ; ; Push a backtracking entry for location PC + OFFSET onto the
388+ ; ; backtracking stack. Backtracking entries save the contents of
389+ ; ; the call stack, position in the token list, the values of
390+ ; ; capture groups, and the record of loop progress (see below).
391391; ;
392392; ; (check-progress)
393393; ; Break out of infinite loops, like (many (many ...)). Checks
@@ -397,38 +397,38 @@ name; otherwise continues tokenizing up to the token at point. FIXME."
397397; ; new entry onto the list.
398398; ;
399399; ; (fail)
400- ; ; Pop the most recent backtracking entry and continue from
401- ; ; there, or fail the whole match if out of backtrack
402- ; ; points. Failing to match returns the remainder of the token
403- ; ; list, although we don't currently use this for anything.
400+ ; ; Pop the most recent backtracking entry and continue from
401+ ; ; there, or fail the whole match if out of backtrack
402+ ; ; points. Failing to match returns the remainder of the token
403+ ; ; list, although we don't currently use this for anything.
404404; ;
405405; ; (commit OFFSET)
406- ; ; Discard one backtracking point and jump to PC + OFFSET. This
407- ; ; is used to make the (either) form non-deterministic.
406+ ; ; Discard one backtracking point and jump to PC + OFFSET. This
407+ ; ; is used to make the (either) form non-deterministic.
408408; ;
409409; ; (push TYPE VALUE)
410- ; ; Push an entry for an eldoc or info string (specified by TYPE)
411- ; ; onto the stack.
410+ ; ; Push an entry for an eldoc or info string (specified by TYPE)
411+ ; ; onto the stack.
412412; ;
413413; ; (pop TYPE)
414- ; ; Pop something off the stack; checks that it has the expected
415- ; ; TYPE, for safety.
414+ ; ; Pop something off the stack; checks that it has the expected
415+ ; ; TYPE, for safety.
416416; ;
417417; ; (save-start NAME)
418- ; ; Open a capture group named NAME. Pushes an entry onto
419- ; ; `gnuplot-captures' with current position in token list as the
420- ; ; start of the group.
418+ ; ; Open a capture group named NAME. Pushes an entry onto
419+ ; ; `gnuplot-captures' with current position in token list as the
420+ ; ; start of the group.
421421; ;
422422; ; (save-end NAME)
423- ; ; Close the capture group named NAME. Finds the topmost entry in
424- ; ; `gnuplot-captures' with this name and sets its endpoint to the
425- ; ; current position in token list. Error if no group with that
426- ; ; name is found.
423+ ; ; Close the capture group named NAME. Finds the topmost entry in
424+ ; ; `gnuplot-captures' with this name and sets its endpoint to the
425+ ; ; current position in token list. Error if no group with that
426+ ; ; name is found.
427427; ;
428428; ; (label NAME)
429- ; ; This should never be reached and will cause an error. The
430- ; ; compiler inserts it at the beginning of compiled rules only
431- ; ; for debugging purposes.
429+ ; ; This should never be reached and will cause an error. The
430+ ; ; compiler inserts it at the beginning of compiled rules only
431+ ; ; for debugging purposes.
432432; ;
433433
434434
@@ -490,13 +490,13 @@ name; otherwise continues tokenizing up to the token at point. FIXME."
490490 ; ; (either...): choose between patterns
491491 ((either)
492492 (cond
493- ((= (length pat) 2 ) ; trivial case
493+ ((= (length pat) 2 ) ; trivial case
494494 (gnuplot-compile-pattern (cadr pat)))
495495
496- ((> (length pat) 3 ) ; could be more efficient...
496+ ((> (length pat) 3 ) ; could be more efficient...
497497 (gnuplot-compile-pattern (gnuplot-either-helper pat)))
498498
499- (t ; two patterns
499+ (t ; two patterns
500500 (let* ((pat1 (cadr pat))
501501 (pat2 (caddr pat))
502502 (pat1-c (gnuplot-compile-pattern pat1))
@@ -514,7 +514,7 @@ name; otherwise continues tokenizing up to the token at point. FIXME."
514514 (pat1-c (gnuplot-compile-pattern pat1))
515515 (pat1-l (length pat1-c)))
516516 `((choice ,(+ pat1-l 3 ))
517- (check-progress) ; bail out of infinite loops
517+ (check-progress) ; bail out of infinite loops
518518 ,@pat1-c
519519 (commit ,(- (+ pat1-l 2 ))))))
520520
@@ -618,7 +618,7 @@ name; otherwise continues tokenizing up to the token at point. FIXME."
618618 ; ; each pattern individually, then "links" them into one vector,
619619 ; ; converting symbolic (call ...) instructions into numeric offsets
620620 (defun gnuplot-compile-grammar (grammar start-symbol )
621- (let ((compiled-pats '()) ; Alist of (name . instructions)
621+ (let ((compiled-pats '()) ; Alist of (name . instructions)
622622 ; ; Reserve space for a jump to the start symbol
623623 (code-length 1 ))
624624
@@ -1236,7 +1236,7 @@ name; otherwise continues tokenizing up to the token at point. FIXME."
12361236
12371237 (set-dgrid3d-clause
12381238 [" dgrid3d"
1239- (maybe expression) ; fixme
1239+ (maybe expression) ; fixme
12401240 (maybe " ," expression)
12411241 (either
12421242 " splines"
@@ -1445,7 +1445,7 @@ name; otherwise continues tokenizing up to the token at point. FIXME."
14451445 " gray" " color"
14461446 [" gamma" number]
14471447 [" rgbformulae" number " ," number " ," number]
1448- " defined" ; not complete
1448+ " defined" ; not complete
14491449 [" functions" expression " ," expression " ," expression]
14501450 [" file" string (many datafile-modifier)]
14511451 " RGB" " HSV" " CMY" " YIQ" " XYZ"
@@ -1547,7 +1547,7 @@ name; otherwise continues tokenizing up to the token at point. FIXME."
15471547
15481548 (set-table-clause [" table" (maybe string)])
15491549
1550- (set-terminal-clause ; not sure how to do this...
1550+ (set-terminal-clause ; not sure how to do this...
15511551 [" terminal" (maybe (either " push" " pop" ))])
15521552
15531553 (set-termoption-clause
@@ -1780,7 +1780,7 @@ nil, it parses up to the token at point and sets `gnuplot-eldoc'
17801780and `gnuplot-info-at-point' based on the contents of the stack
17811781there."
17821782 (catch 'return
1783- (let ((pc 0 ) ; Program counter
1783+ (let ((pc 0 ) ; Program counter
17841784 ; ; Stack of return addresses (return PC), eldoc strings
17851785 ; ; (eldoc STRING) and info pages (info STRING)
17861786 (stack '())
@@ -1797,7 +1797,7 @@ there."
17971797
17981798 (with-gnuplot-trace-buffer (erase-buffer ))
17991799
1800- (when start-symbol ; HACK FIXME
1800+ (when start-symbol ; HACK FIXME
18011801 (let ((look-for `(label , start-symbol )))
18021802 (while (not (equal (aref instructions pc) look-for))
18031803 (incf pc))
@@ -1972,7 +1972,7 @@ there."
19721972
19731973 ; ; Backtrack on failure
19741974 (when fail
1975- (if (not backtrack) ; Out of backtracking stack: failed match
1975+ (if (not backtrack) ; Out of backtracking stack: failed match
19761976 (throw 'return nil )
19771977 (gnuplot-trace " \t *fail*\t %s\n " (length backtrack))
19781978 (gnuplot-debug (gnuplot-dump-backtrack backtrack))
0 commit comments