Skip to content

Commit

Permalink
Obliterate uses of #\Newline (might help with #19)
Browse files Browse the repository at this point in the history
  • Loading branch information
Shinmera committed Apr 19, 2019
1 parent 36e9915 commit 27ebdf7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
4 changes: 2 additions & 2 deletions grammar.lisp
Expand Up @@ -8,7 +8,7 @@

;;; Lexer
(define-reference whitespace
#\Newline #\Space #\Tab)
#\Linefeed #\Return #\Space #\Tab)

(define-object integer-token
(and (v (or decimal-token
Expand Down Expand Up @@ -48,7 +48,7 @@
(intern (string-upcase (first v)) :keyword))

(define-object preprocessor-token
(and (v #\#) (* (v (notany (#\Newline)))))
(and (v #\#) (* (v (notany (#\Return #\Linefeed)))))
(list 'preprocessor-directive (coerce v 'string)))

(defmacro define-operator-objects (&body names)
Expand Down
9 changes: 5 additions & 4 deletions parser.lisp
Expand Up @@ -78,7 +78,8 @@
(loop until (end-of-tokens-p)
for char = (peek)
do (if (or (char= char #\Space)
(char= char #\Newline))
(char= char #\Linefeed)
(char= char #\Return))
(advance)
(return))))

Expand Down Expand Up @@ -180,7 +181,7 @@
(normalize-shader-source stream)))
(stream
(string-trim
'(#\Newline #\Space)
'(#\Return #\Linefeed #\Space)
(with-output-to-string (output)
(loop for char = (read-char input NIL)
while char
Expand All @@ -197,7 +198,7 @@
((#\Return #\Linefeed)
(when (newline-p (peek-char NIL input NIL))
(read-char input))
(write-char #\Newline output))
(write-char #\Linefeed output))
;; Handle comments
(#\/
(case (peek-char NIL input)
Expand All @@ -206,7 +207,7 @@
until (or (not char)
(and (not (char= #\\ prev))
(newline-p char))))
(write-char #\Newline output))
(write-char #\Linefeed output))
(#\* (loop for prev = #\ then char
for char = (read-char input)
until (and (char= #\* prev)
Expand Down

0 comments on commit 27ebdf7

Please sign in to comment.