Remove any trace of the attempt to parse in C6L comments
This commit is contained in:
parent
b65012ed04
commit
c3dc447fe4
2 changed files with 11 additions and 42 deletions
|
@ -7,7 +7,6 @@ parser's debug output.")
|
||||||
;;; Token stream
|
;;; Token stream
|
||||||
|
|
||||||
(defvar *token-stream*)
|
(defvar *token-stream*)
|
||||||
(defvar *token-comment* nil)
|
|
||||||
|
|
||||||
(defun previous-token ()
|
(defun previous-token ()
|
||||||
(cdr *token-stream*))
|
(cdr *token-stream*))
|
||||||
|
@ -20,9 +19,6 @@ parser's debug output.")
|
||||||
((pop-token ()
|
((pop-token ()
|
||||||
(setf (cdr *token-stream*) (pop (car *token-stream*)))
|
(setf (cdr *token-stream*) (pop (car *token-stream*)))
|
||||||
(let ((got (previous-token)))
|
(let ((got (previous-token)))
|
||||||
(if (comment-p (peek-token))
|
|
||||||
(setf *token-comment* (pop (car *token-stream*)))
|
|
||||||
(setf *token-comment* nil))
|
|
||||||
got)))
|
got)))
|
||||||
(cond ((and (keywordp token)
|
(cond ((and (keywordp token)
|
||||||
(typep (peek-token) 'token-keyword)
|
(typep (peek-token) 'token-keyword)
|
||||||
|
@ -145,7 +141,6 @@ parser's debug output.")
|
||||||
(token-not 'node-expr-not)
|
(token-not 'node-expr-not)
|
||||||
(token-minus 'node-expr-negate))
|
(token-minus 'node-expr-negate))
|
||||||
:source *syntax-source*
|
:source *syntax-source*
|
||||||
:comment *token-comment*
|
|
||||||
:operator-token (previous-token)
|
:operator-token (previous-token)
|
||||||
:operand (match-syntax primary))
|
:operand (match-syntax primary))
|
||||||
(match-syntax call))))
|
(match-syntax call))))
|
||||||
|
@ -169,7 +164,6 @@ parser's debug output.")
|
||||||
comma ',' is required to separate arguments.")))
|
comma ',' is required to separate arguments.")))
|
||||||
(make-instance 'node-call
|
(make-instance 'node-call
|
||||||
:source *syntax-source*
|
:source *syntax-source*
|
||||||
:comment *token-comment*
|
|
||||||
:callee (transform name 'asm-function)
|
:callee (transform name 'asm-function)
|
||||||
:arguments arguments))
|
:arguments arguments))
|
||||||
(t name)))
|
(t name)))
|
||||||
|
@ -184,7 +178,6 @@ comma ',' is required to separate arguments.")))
|
||||||
"Closing parenthesis ')' required after grouping expression.")
|
"Closing parenthesis ')' required after grouping expression.")
|
||||||
(make-instance 'node-expr-grouping
|
(make-instance 'node-expr-grouping
|
||||||
:source *syntax-source*
|
:source *syntax-source*
|
||||||
:comment *token-comment*
|
|
||||||
:expression expr)))
|
:expression expr)))
|
||||||
((match-token 'token-end-of-statement)
|
((match-token 'token-end-of-statement)
|
||||||
(error-parser (source (previous-token))
|
(error-parser (source (previous-token))
|
||||||
|
@ -201,7 +194,6 @@ comma ',' is required to separate arguments.")))
|
||||||
(setf r-value (match-syntax expression))
|
(setf r-value (match-syntax expression))
|
||||||
(make-instance 'node-assignment
|
(make-instance 'node-assignment
|
||||||
:source *syntax-source*
|
:source *syntax-source*
|
||||||
:comment *token-comment*
|
|
||||||
:variable (transform l-value 'reference-variable)
|
:variable (transform l-value 'reference-variable)
|
||||||
:value r-value))
|
:value r-value))
|
||||||
l-value))
|
l-value))
|
||||||
|
@ -224,13 +216,10 @@ comma ',' is required to separate arguments.")))
|
||||||
"End-of-statement required after FOR's THEN, got ~A"
|
"End-of-statement required after FOR's THEN, got ~A"
|
||||||
(peek-token)))))
|
(peek-token)))))
|
||||||
((match-token 'token-end-of-statement)
|
((match-token 'token-end-of-statement)
|
||||||
;; Empty statement, might contain comment
|
;; Empty statement
|
||||||
(make-instance 'node-nop
|
(make-instance 'node-nop :source *syntax-source*))
|
||||||
:source *syntax-source*
|
|
||||||
:comment *token-comment*))
|
|
||||||
(t
|
(t
|
||||||
(let ((expr (match-syntax assignment)))
|
(let ((expr (match-syntax assignment)))
|
||||||
;;(setf (comment expr) *token-comment*)
|
|
||||||
(consume-token 'token-end-of-statement
|
(consume-token 'token-end-of-statement
|
||||||
(format nil "Couldn't find end of expression. ~A found instead."
|
(format nil "Couldn't find end of expression. ~A found instead."
|
||||||
(peek-token)))
|
(peek-token)))
|
||||||
|
@ -323,16 +312,15 @@ comma ',' is required to separate arguments.")))
|
||||||
(transform else 'node))))
|
(transform else 'node))))
|
||||||
|
|
||||||
(define-syntax-matcher program (statements)
|
(define-syntax-matcher program (statements)
|
||||||
(let ((*token-comment* nil))
|
(loop :for statement := (match-syntax statement)
|
||||||
(loop :for statement := (match-syntax statement)
|
:unless (typep statement 'node-nop)
|
||||||
:unless (typep statement 'node-nop)
|
:do (push statement statements)
|
||||||
:do (push statement statements)
|
:until (null (peek-token)))
|
||||||
:until (null (peek-token)))
|
(setf statements (wire-up-statements (nreverse statements)))
|
||||||
(setf statements (wire-up-statements (nreverse statements)))
|
(make-instance 'node-program
|
||||||
(make-instance 'node-program
|
:source *syntax-source*
|
||||||
:source *syntax-source*
|
:statements statements
|
||||||
:statements statements
|
:next (first statements)))
|
||||||
:next (first statements))))
|
|
||||||
|
|
||||||
;;; Testing jigs
|
;;; Testing jigs
|
||||||
|
|
||||||
|
|
|
@ -63,15 +63,6 @@ reading immediately. Should be a subset of *SPECIAL-TOKEN-CHARS*.")
|
||||||
(define-transformation (token (token-number integer))
|
(define-transformation (token (token-number integer))
|
||||||
(value token))
|
(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
|
;; Special syntax tokens
|
||||||
|
|
||||||
(defmacro define-atomic-token (name)
|
(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)
|
((member text *syntax-keywords* :test #'equalp)
|
||||||
(make-instance 'token-keyword :source source
|
(make-instance 'token-keyword :source source
|
||||||
:name (intern (string-upcase text) (find-package '#:keyword))))
|
: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)
|
((valid-name-p text)
|
||||||
(make-instance 'token-name :source source :name text))
|
(make-instance 'token-name :source source :name text))
|
||||||
(t (error 'tokenizer-error :source source :format-arguments (list 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))
|
((and (member char *line-comment-chars* :test #'char=) (not in-comment-p))
|
||||||
(unless (zerop (length token-text-buffer))
|
(unless (zerop (length token-text-buffer))
|
||||||
(next-token))
|
(next-token))
|
||||||
(vector-push char token-text-buffer)
|
|
||||||
(setf in-comment-p t))
|
(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
|
;; Non-whitespace non-comment characters
|
||||||
((and (not (whitespacep char)) (not in-comment-p))
|
((and (not (whitespacep char)) (not in-comment-p))
|
||||||
(vector-push char token-text-buffer)
|
(vector-push char token-text-buffer)
|
||||||
|
|
Loading…
Add table
Reference in a new issue