Good tools for tidy and lint newlisp code

Started by ssqq, July 24, 2016, 12:52:16 AM

Previous topic - Next topic

ssqq

I re-design these two tools now:



tidy newlisp:

could find loss ")" or more ")". while, letn, dotimes all indent two space.



https://github.com/songzan/newlisp-spp/blob/master/tools/lint.lsp">https://github.com/songzan/newlisp-spp/ ... s/lint.lsp">https://github.com/songzan/newlisp-spp/blob/master/tools/lint.lsp



usage: > newlisp tidy.lsp target.lsp



lint nelisp:

could check un-declare symbol and un-used symbol.



https://github.com/songzan/newlisp-spp/blob/master/toos/lint.lsp">https://github.com/songzan/newlisp-spp/ ... s/lint.lsp">https://github.com/songzan/newlisp-spp/blob/master/toos/lint.lsp



usage: newlisp lint.lsp target.lsp



or you could puts them in your bin path:



newlisp -x lint.lsp lint
chmod 755 lint
sudo mv lint /usr/bin/lint
newlisp -x tidy.lsp tidy
chmod 755 tidy
sudo mv tidy /usr/bin/tidy

ssqq

#1
When we use newlisp write code, the interpreter could not do anything for us. Because newLISP must be rapidly, more and more.



So, we could do something for to more stable code:



1. un-used symbol:



(define (foo x y) (+ x 1))


below code, symbol 'y' have not used, It's may not any dangrous. but:



(define (foo x) (+ x y))

If we use an un-declare symbol, may be occure some accident.



If we could not find below error, may enlarge error:



(define (foo x) (set 'y 10) (+ x y))

Now, all function in current Context would see this symbol, if you use this symbol, the value

may not be control by you.



all of it could not be find by newLISP interpreter, but Lint.lsp could do it.



> newlisp lint.lsp target.lsp

or you could compiler it in first.

> lint target.lsp