X-Git-Url: https://code.consxy.com/gitweb/gitweb.cgi?p=wolf;a=blobdiff_plain;f=src%2Fmain%2Fchecker.lisp;h=2c42714d771c6a3affa1774944e333d70f7dbf22;hp=b369a1bb5a07f84e066d501aedf28a37107404e7;hb=7b5c585;hpb=49f4258f01eb8ab69f63730f381ba7116a90aeee diff --git a/src/main/checker.lisp b/src/main/checker.lisp index b369a1b..2c42714 100644 --- a/src/main/checker.lisp +++ b/src/main/checker.lisp @@ -6,11 +6,13 @@ ; - Top level multiline forms must be separated by exactly one space ; * No line longer than 120 characters ; - No use of unexported symbols in other packages -; - No tabs +; * No tabs ; - 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 only lines +; * No whitespace at end of line +; * No lines that are only whitespace ; - No empty lines at end of file +; * Only one in-package per file ; ; Some thoughts ; - form starting reader macros will have to be hand added to this code @@ -31,6 +33,9 @@ (defparameter *possible-states* '(:begin ; start of file :normal ; normal processing + :beginning-of-line + :beginning-of-symbols + :all ; matches everything ))) @@ -50,13 +55,13 @@ (list (lambda (state text) (and - (eql ,state state) + (or (eql :all ,state) (eql ,state state)) (or (and (symbolp text) (eql text ,match)) (and ,scanner (stringp text) (multiple-value-bind (start end) (cl-ppcre:scan ,scanner text) - (and start end (= 0 start) (/= 0 end))))))) + (and start end (= 0 start))))))) (lambda (text) (second (multiple-value-list (cl-ppcre:scan ,scanner text)))) ,func) *evaluators*)))) @@ -100,16 +105,33 @@ ; These are in reverse order (progn (setf *evaluators* nil) + (defevaluator :all "\\t" + (constantly "Must not use tabs")) (defevaluator :begin "\\(in-package[^\\)]*\\)" (lambda () (set-state :normal) nil)) (defevaluator :begin ".*" - (lambda () - "Must begin with in-package form")) + (constantly "Must begin with in-package form")) + (defevaluator :normal "\\( *in-package " + (constantly "Only one in-package per file")) (defevaluator :normal "\\n" (lambda () + (set-state :beginning-of-line) (incf *line-no*) - (setf *col-no* 0) + (setf *col-no* -1) + nil)) + (defevaluator :normal " +\\n" + (lambda () + "No whitespace at end of line")) + (defevaluator :beginning-of-line " *" + (lambda () + (set-state :beginning-of-symbols) + nil)) + (defevaluator :beginning-of-symbols "\\n" + (lambda () (when (< 0 *col-no*) "No whitespace only lines"))) + (defevaluator :beginning-of-symbols "" + (lambda () + (set-state :normal) nil)) (defevaluator :normal "\\(" (lambda () @@ -121,9 +143,12 @@ (lambda () (let ((form (pop *form-stack*))) - (when - (< 50 (- *line-no* (car form))) - "Forms can't be over 50 lines long")))) + (cond + ((not form) "Unmatched ending paren") + ((< 50 (- *line-no* (car form))) "Forms can't be over 50 lines long"))))) + +(cl-ppcre:scan (cl-ppcre:create-scanner " *") " +asdf asdf") (defevaluator :normal "." (constantly nil)) )