~evhan/beaker

f78da6533006154f9d32796ca3a3d21361cda8cb — Evan Hanson 2 years ago deced79
Add "chicken-lint" program
4 files changed, 66 insertions(+), 10 deletions(-)

M README.md
M beaker.egg
M beaker.wiki.in
A chicken-lint.scm
M README.md => README.md +4 -4
@@ 6,10 6,10 @@ Lab supplies for CHICKEN Scheme.

Beaker is a collection of development tools.

It is currently fairly limited, including only a single program and a
small handful of libraries to make development easier. If you have an
idea for something that would be useful to include, don't hesitate to
contact the author.
It is currently fairly limited, including only two programs and a small
handful of libraries to make common development tasks easier. If you
have an idea for something that would be useful to include, don't
hesitate to contact the author.

## Documentation


M beaker.egg => beaker.egg +3 -2
@@ 12,7 12,7 @@
  (vector-lib "2.0")
  (with-current-directory "1.0.0"))
 (component-options
  (csc-options "-d3" "-O0" "-X" "module-declarations"))
  (csc-options "-X" "module-declarations"))
 (components
  (extension beaker
   (modules)


@@ 30,5 30,6 @@
   (source "lib/beaker/markdown.scm")
   (component-dependencies beaker.egg.info))
  (program chicken-clean
   (linkage static)
   (component-dependencies beaker.interactive))
  (program chicken-lint
   (component-dependencies beaker.interactive))))

M beaker.wiki.in => beaker.wiki.in +8 -4
@@ 8,10 8,10 @@ Lab supplies for CHICKEN Scheme.

Beaker is a collection of development tools.

It is currently fairly limited, including only a single program and a
small handful of libraries to make development easier. If you have an
idea for something that would be useful to include, don't hesitate to
contact the [[##author|author]].
It is currently fairly limited, including only two programs and a small
handful of libraries to make common development tasks easier. If you
have an idea for something that would be useful to include, don't
hesitate to contact the [[##author|author]].

== Dependencies



@@ 23,6 23,10 @@ contact the [[##author|author]].

#(document-program "chicken-clean.scm" "./chicken-clean -help")

=== chicken-lint

#(document-program "chicken-lint.scm" "./chicken-lint -help")

== Extensions

=== Repository Management

A chicken-lint.scm => chicken-lint.scm +51 -0
@@ 0,0 1,51 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;; Lint Scheme source files.
;;;
;;; Copyright (c) 2018, Evan Hanson
;;;
;;; See LICENSE for details.
;;;

;;
;; The `chicken-lint` analyses a program with a set of simple lint rules.
;;
;; Issues are written as s-expressions to standard error.
;;
(declare
  (module (chicken-lint))
  (import (chicken foreign)
          (chicken format)
          (chicken pathname)
          (chicken process)
          (chicken process-context)))

(define (usage status)
  (printf "Usage: ~a [csc-options ...] filename ..." (pathname-file (program-name)))
  (exit status))

(define (csc)
  (make-pathname
   (foreign-value "C_TARGET_BIN_HOME" c-string)
   (foreign-value "C_CSC_PROGRAM" c-string)))

(define (csc-options)
  (list "-analyze-only" "-extend" "beaker" "-no-warnings" "-optimize-level" "0"))

(define (analyse-program args)
  (receive (_ _ status) (process-wait (process-run (csc) (append (csc-options) args)))
    (exit status)))

(define (main)
  (let ((args '()))
    ((flip for-each)
     (command-line-arguments)
     (lambda (arg)
       (if (member arg '("-h" "-help" "--help"))
           (usage 0)
           (set! args (cons arg args)))))
    (analyse-program (reverse args))))

(cond-expand
  (compiling (main))
  (else))