X-Git-Url: https://code.consxy.com/gitweb/gitweb.cgi?p=wolf;a=blobdiff_plain;f=src%2Fmain%2Fchecker.lisp;h=3a78d88980958db5d1085f47b31d2369ce687c99;hp=2513812cc26d76f95f13e0cf7f163e8c94ed5e70;hb=02e970926c489005f408d69d363d017fb0abfe53;hpb=4ce7dfc301ff2317fe5591a9c23f17e8ac7b7367 diff --git a/src/main/checker.lisp b/src/main/checker.lisp index 2513812..3a78d88 100644 --- a/src/main/checker.lisp +++ b/src/main/checker.lisp @@ -8,7 +8,7 @@ ; * No line longer than 120 characters ; * No use of unexported symbols in other packages ; * No tabs -; - Only one space between elements in a form on a single line +; * Only one space between elements in a form on a single line ; * in-package must be first line in file unless file is package.lisp ; * No whitespace at end of line ; * No lines that are only whitespace @@ -18,8 +18,8 @@ ; * No hanging close parens ; ; Exceptions -; - comments -; - multiline strings +; * comments +; * multiline strings ; Some thoughts ; - form starting reader macros will have to be hand added to this code @@ -45,11 +45,13 @@ :beginning-of-line-with-separator ; empty space in there :beginning-of-symbols :beginning-of-symbols-with-separator + :comment-with-separator ; weird edge case for pre-function comments + :beginning-of-line-with-comment-and-separator ; weird edge case part 2 :first-symbol ; first symbol of form/line :all ; matches everything + :in-string ))) - (defun set-state (state) (when (not (find state *possible-states*)) (error "Can't set state to ~A" state)) @@ -119,6 +121,12 @@ ; These are in reverse order (progn (setf *evaluators* nil) + (defevaluator :beginning-of-symbols " *;[^\\n]*" + (lambda () (set-state :normal))) + (defevaluator :beginning-of-symbols-with-separator " *;[^\\n]*" + (lambda () (set-state :comment-with-separator))) + (defevaluator :normal " *;[^\\n]*" + (lambda () (set-state :normal))) (defevaluator :normal "\\(" (lambda () (push (list *line-no* *col-no*) *form-stack*) @@ -143,9 +151,22 @@ (incf *line-no*) (setf *col-no* -1) (set-state :beginning-of-line))) + (defevaluator :comment-with-separator "\\n" + (lambda () + (incf *line-no*) + (setf *col-no* -1) + (set-state :beginning-of-line-with-comment-and-separator) + nil)) (defevaluator :normal " +\\n" (constantly "No whitespace at end of line")) (defevaluator :beginning-of-line " *" (lambda () (set-state :beginning-of-symbols))) (defevaluator :beginning-of-line-with-separator " *" (lambda () (set-state :beginning-of-symbols-with-separator))) + (defevaluator :beginning-of-line-with-comment-and-separator "\\n" + (lambda () + (progn + (incf *line-no*) + (setf *col-no* -1) + (set-state :beginning-of-line-with-separator)))) + (defevaluator :beginning-of-line-with-comment-and-separator " *" (lambda () (set-state :beginning-of-symbols-with-separator))) (defevaluator :beginning-of-symbols "\\n" (lambda () (if @@ -175,6 +196,15 @@ ((< 50 (- *line-no* (car form))) "Forms can't be over 50 lines long") (t (setf *form-ended-on-same-line* (= *line-no* (car form))) nil))))) (defevaluator :normal "::" (constantly "No internal symbols from other packages")) + (defevaluator :in-string "\\\\\"" (constantly nil)) + (defevaluator :normal "\"" (lambda () (set-state :in-string))) + (defevaluator :in-string "\"" (lambda () (set-state :normal))) + (defevaluator :in-string "\\n" + (lambda () + (incf *line-no*) + (setf *col-no* -1) + nil)) + (defevaluator :in-string "." (constantly nil)) (defevaluator :first-symbol "\\n" (constantly "No new line after opening form")) (defevaluator :first-symbol " " (constantly "No space after opening parens")) (defevaluator :first-symbol "" @@ -184,4 +214,5 @@ ((and *form-stack* (/= (1+ (cadr (car *form-stack*))) *col-no*)) "All form elements must be indented equally") (t (set-state :normal))))) + (defevaluator :normal " " (constantly "Only one space between items of a form")) (defevaluator :normal "." (constantly nil)))