From c3dc447fe4d4197528ffc19dee76e2431b2863a6 Mon Sep 17 00:00:00 2001 From: John Lorentzson Date: Wed, 9 Jul 2025 14:36:47 +0200 Subject: [PATCH] Remove any trace of the attempt to parse in C6L comments --- wip-duuqnd/user-side-compiler/parser.lisp | 34 +++++++------------- wip-duuqnd/user-side-compiler/tokenizer.lisp | 19 ----------- 2 files changed, 11 insertions(+), 42 deletions(-) diff --git a/wip-duuqnd/user-side-compiler/parser.lisp b/wip-duuqnd/user-side-compiler/parser.lisp index 28e6b89..201c206 100644 --- a/wip-duuqnd/user-side-compiler/parser.lisp +++ b/wip-duuqnd/user-side-compiler/parser.lisp @@ -7,7 +7,6 @@ parser's debug output.") ;;; Token stream (defvar *token-stream*) -(defvar *token-comment* nil) (defun previous-token () (cdr *token-stream*)) @@ -20,9 +19,6 @@ parser's debug output.") ((pop-token () (setf (cdr *token-stream*) (pop (car *token-stream*))) (let ((got (previous-token))) - (if (comment-p (peek-token)) - (setf *token-comment* (pop (car *token-stream*))) - (setf *token-comment* nil)) got))) (cond ((and (keywordp token) (typep (peek-token) 'token-keyword) @@ -145,7 +141,6 @@ parser's debug output.") (token-not 'node-expr-not) (token-minus 'node-expr-negate)) :source *syntax-source* - :comment *token-comment* :operator-token (previous-token) :operand (match-syntax primary)) (match-syntax call)))) @@ -169,7 +164,6 @@ parser's debug output.") comma ',' is required to separate arguments."))) (make-instance 'node-call :source *syntax-source* - :comment *token-comment* :callee (transform name 'asm-function) :arguments arguments)) (t name))) @@ -184,7 +178,6 @@ comma ',' is required to separate arguments."))) "Closing parenthesis ')' required after grouping expression.") (make-instance 'node-expr-grouping :source *syntax-source* - :comment *token-comment* :expression expr))) ((match-token 'token-end-of-statement) (error-parser (source (previous-token)) @@ -201,7 +194,6 @@ comma ',' is required to separate arguments."))) (setf r-value (match-syntax expression)) (make-instance 'node-assignment :source *syntax-source* - :comment *token-comment* :variable (transform l-value 'reference-variable) :value r-value)) l-value)) @@ -224,13 +216,10 @@ comma ',' is required to separate arguments."))) "End-of-statement required after FOR's THEN, got ~A" (peek-token))))) ((match-token 'token-end-of-statement) - ;; Empty statement, might contain comment - (make-instance 'node-nop - :source *syntax-source* - :comment *token-comment*)) + ;; Empty statement + (make-instance 'node-nop :source *syntax-source*)) (t (let ((expr (match-syntax assignment))) - ;;(setf (comment expr) *token-comment*) (consume-token 'token-end-of-statement (format nil "Couldn't find end of expression. ~A found instead." (peek-token))) @@ -323,16 +312,15 @@ comma ',' is required to separate arguments."))) (transform else 'node)))) (define-syntax-matcher program (statements) - (let ((*token-comment* nil)) - (loop :for statement := (match-syntax statement) - :unless (typep statement 'node-nop) - :do (push statement statements) - :until (null (peek-token))) - (setf statements (wire-up-statements (nreverse statements))) - (make-instance 'node-program - :source *syntax-source* - :statements statements - :next (first statements)))) + (loop :for statement := (match-syntax statement) + :unless (typep statement 'node-nop) + :do (push statement statements) + :until (null (peek-token))) + (setf statements (wire-up-statements (nreverse statements))) + (make-instance 'node-program + :source *syntax-source* + :statements statements + :next (first statements))) ;;; Testing jigs diff --git a/wip-duuqnd/user-side-compiler/tokenizer.lisp b/wip-duuqnd/user-side-compiler/tokenizer.lisp index a240692..252d64d 100644 --- a/wip-duuqnd/user-side-compiler/tokenizer.lisp +++ b/wip-duuqnd/user-side-compiler/tokenizer.lisp @@ -63,15 +63,6 @@ reading immediately. Should be a subset of *SPECIAL-TOKEN-CHARS*.") (define-transformation (token (token-number integer)) (value token)) -(defclass token-comment (token) - ((%text :accessor text :initarg :text))) - -(defmethod comment-p (obj) - nil) - -(defmethod comment-p ((obj token-comment)) - t) - ;; Special syntax tokens (defmacro define-atomic-token (name) @@ -143,12 +134,6 @@ reading immediately. Should be a subset of *SPECIAL-TOKEN-CHARS*.") ((member text *syntax-keywords* :test #'equalp) (make-instance 'token-keyword :source source :name (intern (string-upcase text) (find-package '#:keyword)))) - ((member (aref text 0) *line-comment-chars*) - (let ((start (position-if-not #'whitespacep (subseq text 1)))) - (make-instance 'token-comment - :source source - :text (if (null start) "" - (subseq text start))))) ((valid-name-p text) (make-instance 'token-name :source source :name text)) (t (error 'tokenizer-error :source source :format-arguments (list text) @@ -189,11 +174,7 @@ reading immediately. Should be a subset of *SPECIAL-TOKEN-CHARS*.") ((and (member char *line-comment-chars* :test #'char=) (not in-comment-p)) (unless (zerop (length token-text-buffer)) (next-token)) - (vector-push char token-text-buffer) (setf in-comment-p t)) - ;; Comment character (next-token'd by newline) - (in-comment-p - (vector-push char token-text-buffer)) ;; Non-whitespace non-comment characters ((and (not (whitespacep char)) (not in-comment-p)) (vector-push char token-text-buffer)