forked from chyanju/__archived__Medjai
-
Notifications
You must be signed in to change notification settings - Fork 0
/
parser-run.rkt
25 lines (23 loc) · 976 Bytes
/
parser-run.rkt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#lang rosette
; a simplified version of cairo_run.py
(require racket/cmdline
(prefix-in parser: "./medjai/v-parser.rkt"))
; parse command line arguments
(define arg-vheader #f)
(define arg-output #f)
(define arg-spec-name "my_spec")
(define arg-vname
(command-line
#:program "parser-run.rkt"
#:once-any
[("--header") p-vheader "path to a header for Cairo specifications (.cairo)" (set! arg-vheader p-vheader)]
#:once-any
[("--spec-name") p-spec-name "name of specification function" (set! arg-spec-name p-spec-name)]
#:once-any
[("--output") p-output "path to the output file (.cairo)" (set! arg-output p-output)]
#:args (vname)
vname))
(when (and (not (null? arg-vname)) (not (null? arg-vheader)))
(let ([out (if arg-output (open-output-file arg-output #:exists 'replace) (current-output-port))])
(parser:convert-spec arg-vname arg-spec-name #:header arg-vheader #:print-func (curryr displayln out))
(close-output-port out)))