Created
June 17, 2016 11:26
-
-
Save kmizumar/908cf32318904318596c638462878f63 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env gosh | |
| (use file.util) | |
| (use gauche.collection) | |
| (use gauche.parseopt) | |
| (use gauche.process) | |
| (use slib) | |
| (use srfi-13) | |
| (use rfc.json) | |
| (use util.match) | |
| (require 'format) | |
| (define (p . args) (for-each print args)) | |
| (define (usage) | |
| (p (format #f "Usage: ~a [options] input" *program-name*) | |
| "Options:" | |
| " -h, --help : show usage") | |
| (exit 0)) | |
| (define (fn line count) | |
| (let | |
| ((match (#/^(\w+)=(\w+)\;$/ line))) | |
| (if match | |
| (format #t "Tuple2.apply(~s, ~a), // ~d~%" | |
| (match 1) | |
| (if (#/\dF/ (match 2)) | |
| "FloatType" | |
| "IntegerType") | |
| count)))) | |
| (define (to-tuple input) | |
| (with-input-from-file input | |
| (^ () | |
| (let loop ((line (read-line)) | |
| (count 1)) | |
| (cond ((eof-object? line) '()) | |
| (else (fn line count) | |
| (inc! count) | |
| (loop (read-line) count))))) | |
| :if-does-not-exist :error)) | |
| ;; Entry point | |
| (define (main args) | |
| (let-args (cdr args) | |
| ([#f "h|help" => usage] | |
| [else (opt . _) (print "Unknown option : " opt) (usage)] | |
| . args) | |
| (match args | |
| [() (usage)] | |
| [(input) | |
| (to-tuple input)] | |
| [else (usage)]))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment