mirror of
https://github.com/weiju/amiga-stuff
synced 2026-09-17 14:04:47 +00:00
racket version of fdtool can now recognize and extract function definitions
This commit is contained in:
+11
-4
@@ -3,6 +3,10 @@
|
|||||||
;; Writing the tool in a Lisp makes is easier to run it on
|
;; Writing the tool in a Lisp makes is easier to run it on
|
||||||
;; a classic Amiga
|
;; a classic Amiga
|
||||||
|
|
||||||
|
;; This file is intended to be used as a Racket module,
|
||||||
|
;; so here are the exports
|
||||||
|
(provide process-fd)
|
||||||
|
|
||||||
;; FD file comments start with a '*'
|
;; FD file comments start with a '*'
|
||||||
(define (fd-comment? line)
|
(define (fd-comment? line)
|
||||||
(char=? #\* (string-ref line 0)))
|
(char=? #\* (string-ref line 0)))
|
||||||
@@ -12,7 +16,7 @@
|
|||||||
|
|
||||||
;; takes a command line and modifies the params hash accordingly
|
;; takes a command line and modifies the params hash accordingly
|
||||||
(define (process-command params line)
|
(define (process-command params line)
|
||||||
(print line)
|
;;(print line)
|
||||||
(cond [(string=? line "##private") (hash-set! params "is-private" #T)]
|
(cond [(string=? line "##private") (hash-set! params "is-private" #T)]
|
||||||
[(string=? line "##public") (hash-set! params "is-private" #F)]
|
[(string=? line "##public") (hash-set! params "is-private" #F)]
|
||||||
[(and (> (string-length line) 7) (string=? (substring line 0 6) "##base"))
|
[(and (> (string-length line) 7) (string=? (substring line 0 6) "##base"))
|
||||||
@@ -21,12 +25,15 @@
|
|||||||
(hash-set! params "bias" (string->number (substring line 7)))])
|
(hash-set! params "bias" (string->number (substring line 7)))])
|
||||||
params)
|
params)
|
||||||
|
|
||||||
|
;; process a function definition, extracting the function name,
|
||||||
|
;; the parameter names and the assigned registers
|
||||||
(define (process-fundef params line)
|
(define (process-fundef params line)
|
||||||
;; TODO
|
(let* ([fun-regexp #rx"^([^()]+)[(]([^()]*)[)][(]([^()]*)[)].*$"]
|
||||||
(printf "~s\n" line))
|
[fun-match (regexp-match fun-regexp line)])
|
||||||
|
(cond [fun-match (print (cdr fun-match))])))
|
||||||
|
|
||||||
;; Process the input file line-by-line
|
;; Process the input file line-by-line
|
||||||
(define (process filename)
|
(define (process-fd filename)
|
||||||
;; params is a hash, could be a struct as well
|
;; params is a hash, could be a struct as well
|
||||||
(let* ([params (make-hash '(("base" . "") ("is-private" . #T) ("bias" . 0)))]
|
(let* ([params (make-hash '(("base" . "") ("is-private" . #T) ("bias" . 0)))]
|
||||||
[lines (filter (lambda (x) (not (fd-comment? x))) (file->lines filename))])
|
[lines (filter (lambda (x) (not (fd-comment? x))) (file->lines filename))])
|
||||||
|
|||||||
Reference in New Issue
Block a user