-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.rkt
83 lines (62 loc) · 1.92 KB
/
main.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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#lang racket
(require "utils/filefunction.rkt"
"lang/lexer/lexer.scm"
"rules/lexer-interface.rkt"
"rules/loc-rules.rkt"
"rules/loc-eval.rkt"
)
(provide main)
(define *version* "0.0.1")
(define *work-dir* #f)
(define *output-dir* #f)
(define *show-rules* #f)
(define (main args)
(process-args args)
(if *show-rules*
(list-rules)
(if (and *work-dir* *output-dir*)
(if (directory-exists? *work-dir*)
(if (directory-exists? *output-dir*)
(lexer-and-token-dir *work-dir* *output-dir*)
(printf ("Output directory ~a not exists" *output-dir*)))
(printf ("input directory ~a not exists" *work-dir*)))
(display-help))))
(define (process-args args)
(if (member "--version" args)
(display-version)
(if (null? args)
(begin
(display-version)
(newline)
(display-help))
(parse-args args))))
(define (parse-args args)
(command-line
#:program "loxy"
#:argv args
#:help-labels "loxy options:"
#:once-each
("-i" dir
"input dir"
(set! *work-dir* (if (equal? (string-ref dir (- (string-length dir) 1)) #\/)
dir
(string-append dir "/"))))
("-o" dir
"output dir"
(set! *output-dir* (if (equal? (string-ref dir (- (string-length dir) 1)) #\/)
dir
(string-append dir "/"))))
("--list-rules"
"show list of exists rules"
(set! *show-rules* #t))
#:help-labels "Misc options:"
#:once-each
("--debug" "Activates debug information"
(void))
("--version" "Prints version number and copyright notice"
(void))
))
(define (display-version)
(printf "loxy v ~a~n" *version*))
(define (display-help)
(parse-args '("--help")))