mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-06-28 22:10:29 +02:00
whitespace changes
* module/language/elisp/bindings.scm: * module/language/elisp/compile-tree-il.scm: * module/language/elisp/lexer.scm: * module/language/elisp/parser.scm: * module/language/elisp/runtime.scm: * module/language/elisp/runtime/function-slot.scm: * module/language/elisp/runtime/macro-slot.scm: Ensure that all top-level forms and comments are separated by exactly one newline. Remove blank lines in most procedure bodies. Delete trailing whitespace.
This commit is contained in:
parent
802b47bdc6
commit
372b11fc73
8 changed files with 75 additions and 119 deletions
|
@ -34,20 +34,17 @@
|
|||
|
||||
; TODO: #@count comments
|
||||
|
||||
|
||||
; Report an error from the lexer (that is, invalid input given).
|
||||
|
||||
(define (lexer-error port msg . args)
|
||||
(apply error msg args))
|
||||
|
||||
|
||||
; In a character, set a given bit. This is just some bit-wise or'ing on the
|
||||
; characters integer code and converting back to character.
|
||||
|
||||
(define (set-char-bit chr bit)
|
||||
(logior chr (ash 1 bit)))
|
||||
|
||||
|
||||
; Check if a character equals some other. This is just like char=? except that
|
||||
; the tested one could be EOF in which case it simply isn't equal.
|
||||
|
||||
|
@ -55,7 +52,6 @@
|
|||
(and (not (eof-object? tested))
|
||||
(char=? tested should-be)))
|
||||
|
||||
|
||||
; For a character (as integer code), find the real character it represents or
|
||||
; #\nul if out of range. This is used to work with Scheme character functions
|
||||
; like char-numeric?.
|
||||
|
@ -65,7 +61,6 @@
|
|||
(integer->char chr)
|
||||
#\nul))
|
||||
|
||||
|
||||
; Return the control modified version of a character. This is not just setting
|
||||
; a modifier bit, because ASCII conrol characters must be handled as such, and
|
||||
; in elisp C-? is the delete character for historical reasons.
|
||||
|
@ -80,7 +75,6 @@
|
|||
((#\@) 0)
|
||||
(else (set-char-bit chr 26))))))
|
||||
|
||||
|
||||
; Parse a charcode given in some base, basically octal or hexadecimal are
|
||||
; needed. A requested number of digits can be given (#f means it does
|
||||
; not matter and arbitrary many are allowed), and additionally early
|
||||
|
@ -113,7 +107,6 @@
|
|||
(lexer-error port "invalid digit in escape-code" base cur))
|
||||
(iterate (+ (* result base) value) (1+ procdigs)))))))
|
||||
|
||||
|
||||
; Read a character and process escape-sequences when necessary. The special
|
||||
; in-string argument defines if this character is part of a string literal or
|
||||
; a single character literal, the difference being that in strings the
|
||||
|
@ -129,13 +122,11 @@
|
|||
(#\S . 25) (#\M . ,(if in-string 7 27))))
|
||||
(cur (read-char port)))
|
||||
(if (char=? cur #\\)
|
||||
|
||||
; Handle an escape-sequence.
|
||||
(let* ((escaped (read-char port))
|
||||
(esc-code (assq-ref basic-escape-codes escaped))
|
||||
(meta (assq-ref meta-bits escaped)))
|
||||
(cond
|
||||
|
||||
; Meta-check must be before esc-code check because \s- must be
|
||||
; recognized as the super-meta modifier if a - follows.
|
||||
; If not, it will be caught as \s -> space escape code.
|
||||
|
@ -143,16 +134,13 @@
|
|||
(if (not (char=? (read-char port) #\-))
|
||||
(error "expected - after control sequence"))
|
||||
(set-char-bit (get-character port in-string) meta))
|
||||
|
||||
; One of the basic control character escape names?
|
||||
(esc-code esc-code)
|
||||
|
||||
; Handle \ddd octal code if it is one.
|
||||
((and (char>=? escaped #\0) (char<? escaped #\8))
|
||||
(begin
|
||||
(unread-char escaped port)
|
||||
(charcode-escape port 8 3 #t)))
|
||||
|
||||
; Check for some escape-codes directly or otherwise
|
||||
; use the escaped character literally.
|
||||
(else
|
||||
|
@ -169,12 +157,10 @@
|
|||
((#\u) (charcode-escape port 16 4 #f))
|
||||
((#\U) (charcode-escape port 16 8 #f))
|
||||
(else (char->integer escaped))))))
|
||||
|
||||
; No escape-sequence, just the literal character.
|
||||
; But remember to get the code instead!
|
||||
(char->integer cur))))
|
||||
|
||||
|
||||
; Read a symbol or number from a port until something follows that marks the
|
||||
; start of a new token (like whitespace or parentheses). The data read is
|
||||
; returned as a string for further conversion to the correct type, but we also
|
||||
|
@ -184,11 +170,13 @@
|
|||
; if it is possibly an integer or a float.
|
||||
|
||||
(define integer-regex (make-regexp "^[+-]?[0-9]+\\.?$"))
|
||||
|
||||
(define float-regex
|
||||
(make-regexp "^[+-]?([0-9]+\\.?[0-9]*|[0-9]*\\.?[0-9]+)(e[+-]?[0-9]+)?$"))
|
||||
|
||||
; A dot is also allowed literally, only a single dort alone is parsed as the
|
||||
; 'dot' terminal for dotted lists.
|
||||
|
||||
(define no-escape-punctuation (string->char-set "-+=*/_~!@$%^&:<>{}?."))
|
||||
|
||||
(define (get-symbol-or-number port)
|
||||
|
@ -220,7 +208,6 @@
|
|||
(unread-char c port)
|
||||
(finish))))))
|
||||
|
||||
|
||||
; Parse a circular structure marker without the leading # (which was already
|
||||
; read and recognized), that is, a number as identifier and then either
|
||||
; = or #.
|
||||
|
@ -239,7 +226,6 @@
|
|||
((#\#) `(circular-ref . ,id))
|
||||
((#\=) `(circular-def . ,id))
|
||||
(else (lexer-error port "invalid circular marker character" type))))))
|
||||
|
||||
|
||||
; Main lexer routine, which is given a port and does look for the next token.
|
||||
|
||||
|
@ -257,23 +243,18 @@
|
|||
; and actually point to the very character to be read.
|
||||
(c (read-char port)))
|
||||
(cond
|
||||
|
||||
; End of input must be specially marked to the parser.
|
||||
((eof-object? c) '*eoi*)
|
||||
|
||||
; Whitespace, just skip it.
|
||||
((char-whitespace? c) (lex port))
|
||||
|
||||
; The dot is only the one for dotted lists if followed by
|
||||
; whitespace. Otherwise it is considered part of a number of symbol.
|
||||
((and (char=? c #\.)
|
||||
(char-whitespace? (peek-char port)))
|
||||
(return 'dot #f))
|
||||
|
||||
; Continue checking for literal character values.
|
||||
(else
|
||||
(case c
|
||||
|
||||
; A line comment, skip until end-of-line is found.
|
||||
((#\;)
|
||||
(let iterate ()
|
||||
|
@ -281,11 +262,9 @@
|
|||
(if (or (eof-object? cur) (char=? cur #\newline))
|
||||
(lex port)
|
||||
(iterate)))))
|
||||
|
||||
; A character literal.
|
||||
((#\?)
|
||||
(return 'character (get-character port #f)))
|
||||
|
||||
; A literal string. This is mainly a sequence of characters just
|
||||
; as in the character literals, the only difference is that escaped
|
||||
; newline and space are to be completely ignored and that meta-escapes
|
||||
|
@ -307,12 +286,10 @@
|
|||
(iterate (cons (integer->char (get-character port #t))
|
||||
result-chars))))))
|
||||
(else (iterate (cons cur result-chars)))))))
|
||||
|
||||
; Circular markers (either reference or definition).
|
||||
((#\#)
|
||||
(let ((mark (get-circular-marker port)))
|
||||
(return (car mark) (cdr mark))))
|
||||
|
||||
; Parentheses and other special-meaning single characters.
|
||||
((#\() (return 'paren-open #f))
|
||||
((#\)) (return 'paren-close #f))
|
||||
|
@ -320,7 +297,6 @@
|
|||
((#\]) (return 'square-close #f))
|
||||
((#\') (return 'quote #f))
|
||||
((#\`) (return 'backquote #f))
|
||||
|
||||
; Unquote and unquote-splicing.
|
||||
((#\,)
|
||||
(if (is-char? (peek-char port) #\@)
|
||||
|
@ -328,7 +304,6 @@
|
|||
(error "expected @ in unquote-splicing")
|
||||
(return 'unquote-splicing #f))
|
||||
(return 'unquote #f)))
|
||||
|
||||
; Remaining are numbers and symbols. Process input until next
|
||||
; whitespace is found, and see if it looks like a number
|
||||
; (float/integer) or symbol and return accordingly.
|
||||
|
@ -369,7 +344,6 @@
|
|||
num)))
|
||||
(else (error "wrong number/symbol type" type)))))))))))
|
||||
|
||||
|
||||
; Build a lexer thunk for a port. This is the exported routine which can be
|
||||
; used to create a lexer for the parser to use.
|
||||
|
||||
|
@ -377,7 +351,6 @@
|
|||
(lambda ()
|
||||
(lex port)))
|
||||
|
||||
|
||||
; Build a special lexer that will only read enough for one expression and then
|
||||
; always return end-of-input.
|
||||
; If we find one of the quotation stuff, one more expression is needed in any
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue