Hi everybody,
those of you who were on the #chicken IRC yesterday may remember my cumbersome
tries with this. Since I am not always able to be on IRC all the time, I'll try
with a email.
I'm working on a syntax checker for Flycheck (on Emacs). Following Mario Goulart
tips, I am using this:
csc -A -M -P <filename.scm>
I've attached the files I am working on. As you can see, there's a main file
(stitchcounter.scm) and a unit (io-utils.scm).
If I do this:
csc -A -M -P stitchcounter.scm
I get this:
Warning: reference to possibly unbound identifier `get-num' in:
Warning: pick
Warning: option-2
Warning: option-1
Error: module unresolved: main
Error: shell command terminated with non-zero exit status 256:
'/usr/local/bin/chicken' 'stitchcounter.scm' -output-file 'stitchcounter.c'
-analyze-only -module -check-syntax
I see 2 problems here:
- I don't understand the warnings: get-num is defined in io-utils.scm and
stitchcounter.scm uses it correctly (I can produce a binary compiling those 2
files)
- the Error terminated abruptly and so the syntax checker in Flycheck doesn't
work
Any ideas?
Kind regards
--
Manuel Uberti
https://manuel-uberti.github.io
GPG fingerprint = 8702 9F53 2466 A6B5 E3F4 6B44 4E57 A6C4 CAA4 8F62
;;; Library io-utils.scm
;; Common I/O utilities
(declare (unit io-utils))
(use extras)
(use input-parse)
;; Print a prompt and wait for an input from the user
(define (get-input prompt)
(printf "~A" prompt)
(read-text-line))
;; Print a prompt and specifically ask for a number
(define (get-num prompt)
(let* ((v (get-input prompt))
(vl (string-split v " " #f))
(vc (if (pair? vl) (car vl) "")))
(if (number? (string->number vc))
(string->number vc)
(get-num (conc "Please specify a valid number.\n" prompt)))))
#!/bin/sh
#| -*- scheme -*-
exec csi -s $0 "$@"
|#
;;; stitchcounter.scm
(declare (uses io-utils))
(define cms-per-square 10.0)
;; Calculate stitches from the original gauge
(define (option-1)
(let* ((orows
(get-num "Number of rows/rounds as listed in pattern gauge: "))
(osts
(get-num "Number of stitches as listed in pattern gauge: "))
(rows
(get-num "Number of rows/rounds in gauge you want to use: "))
(sts
(get-num "Number of stitches in gauge you want to use: "))
(ovalr
(get-num "Total rows/rounds of pattern: "))
(resr
(round (/ (* rows ovalr) orows)))
(ovals
(get-num "Stitches to CO for your project: "))
(ress
(round (/ (* sts ovals) osts))))
(printf "Final rows/rounds: ~A / Final stitches: ~A\n" resr ress)))
;; Calculate stitches from dimensions
(define (option-2)
(let* ((units
(get-num "Dimension of swatch [4 inches, 10 cms, etc.]: "))
(rows
(get-num "Rows/rounds in gauge: "))
(sts
(get-num "Stitches in gauge: "))
(rows1cm
(/ rows units))
(sts1cm
(/ sts units))
(cm
(get-num "Cms/inches of your project: "))
(resr
(* rows1cm cm))
(ress
(* sts1cm cm)))
(printf "Final rows/rounds: ~A / Final stitches: ~A\n" resr ress)))
(define (pick prompt)
(let ((input (get-num prompt)))
(cond
((= 1 input) (option-1))
((= 2 input) (option-2))
((= 3 input) (exit))
(else (pick prompt)))))
;; Main
(define (stitchcounter)
(print "\nStitchcounter: useful tool to help knitting and crocheting")
(print "Options:\n")
(print "\t1 Change gauge in a pattern")
(print "\t (Pattern lists gauge and width, you want to knit")
(print "\t the same width with a different gauge)\n")
(print "\t2 Calculate number of stitches to CO")
(print "\t (You have a given gauge, calculate how many stiches/rows")
(print "\t you need to get a given dimension)\n")
(print "\t3 Quit")
(pick "\nPick your option: "))
(stitchcounter)
_______________________________________________
Chicken-users mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/chicken-users