Skip to content

Commit 41a8792

Browse files
committed
[main] use docopt instead of docopt_macros
1 parent 8a45c7a commit 41a8792

File tree

11 files changed

+167
-97
lines changed

11 files changed

+167
-97
lines changed

Cargo.lock

Lines changed: 33 additions & 37 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,11 @@ version = "0.0.1"
55
authors = ["Jauhien Piatlicki <jauhien@gentoo.org>"]
66

77
[dependencies]
8-
docopt = "*"
9-
docopt_macros = "*"
8+
docopt = "0.6"
109
llvm-sys = "*"
1110
regex = "*"
1211
regex_macros = "*"
13-
rustc-serialize = "*"
12+
rustc-serialize = "0.3"
1413

1514
[dependencies.iron_llvm]
1615
git = "https://github.com/jauhien/iron-llvm.git"

README.in.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ the latest Rust and on improvinvg the way it uses LLVM.
4545
* [User-defined binary operators](#user-defined-binary-operators)
4646
* [User-defined unary operators](#user-defined-unary-operators)
4747
* [Painting the Mandelbrot set](#painting-the-mandelbrot-set)
48-
* [Extending Kaleidoscope: mutable variables](#extending-kaleidoscope-mutable-variables)
48+
* [Chapter 6. Extending Kaleidoscope: mutable variables](#chapter-6-extending-kaleidoscope-mutable-variables)
4949

5050

5151
## Chapter 0. Introduction
@@ -2178,7 +2178,7 @@ entry:
21782178
}
21792179
```
21802180

2181-
Yes, we work with complex numbers using our simple languages. Now we are ready to paint some
2181+
Yes, we work with complex numbers using our simple language. Now we are ready to paint some
21822182
nice pictures.
21832183

21842184
```
@@ -2366,4 +2366,4 @@ So we see that Kaleidoscope has grown to a real and powerful language.
23662366
As usually you can experiment with
23672367
[the full code for this chapter](https://github.com/jauhien/iron-kaleidoscope/tree/master/chapters/5).
23682368

2369-
## Extending Kaleidoscope: mutable variables
2369+
## Chapter 6. Extending Kaleidoscope: mutable variables

README.md

Lines changed: 31 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ the latest Rust and on improvinvg the way it uses LLVM.
4545
* [User-defined binary operators](#user-defined-binary-operators)
4646
* [User-defined unary operators](#user-defined-unary-operators)
4747
* [Painting the Mandelbrot set](#painting-the-mandelbrot-set)
48-
* [Extending Kaleidoscope: mutable variables](#extending-kaleidoscope-mutable-variables)
48+
* [Chapter 6. Extending Kaleidoscope: mutable variables](#chapter-6-extending-kaleidoscope-mutable-variables)
4949

5050

5151
## Chapter 0. Introduction
@@ -946,17 +946,28 @@ start from command line options parsing. We will use
946946
[docopt](https://github.com/docopt/docopt.rs) library for this:
947947

948948
```rust
949-
docopt!(Args, "
949+
use docopt::Docopt;
950+
951+
const USAGE: &'static str = "
950952
Usage: iron_kaleidoscope [(-l | -p | -i)]
951953
952954
Options:
953955
-l Run only lexer and show its output.
954956
-p Run only parser and show its output.
955957
-i Run only IR builder and show its output.
956-
");
958+
";
959+
960+
#[derive(Debug, RustcDecodable)]
961+
struct Args {
962+
flag_l: bool,
963+
flag_p: bool,
964+
flag_i: bool
965+
}
957966

958967
fn main() {
959-
let args: Args = Args::docopt().decode().unwrap_or_else(|e| e.exit());
968+
let args: Args = Docopt::new(USAGE)
969+
.and_then(|d| d.decode())
970+
.unwrap_or_else(|e| e.exit());
960971

961972
let stage = if args.flag_l {
962973
Tokens
@@ -2295,9 +2306,6 @@ Now we modify the main function appropriately, so it calls the main loop
22952306
for the `Exec` stage by default.
22962307

22972308
```rust
2298-
#![feature(plugin)]
2299-
#![plugin(docopt_macros)]
2300-
23012309
extern crate rustc_serialize;
23022310
extern crate docopt;
23032311

@@ -2310,17 +2318,28 @@ use iron_kaleidoscope::driver::{main_loop,
23102318
Tokens
23112319
};
23122320

2313-
docopt!(Args, "
2321+
use docopt::Docopt;
2322+
2323+
const USAGE: &'static str = "
23142324
Usage: iron_kaleidoscope [(-l | -p | -i)]
23152325
23162326
Options:
23172327
-l Run only lexer and show its output.
23182328
-p Run only parser and show its output.
23192329
-i Run only IR builder and show its output.
2320-
");
2330+
";
2331+
2332+
#[derive(Debug, RustcDecodable)]
2333+
struct Args {
2334+
flag_l: bool,
2335+
flag_p: bool,
2336+
flag_i: bool
2337+
}
23212338

23222339
fn main() {
2323-
let args: Args = Args::docopt().decode().unwrap_or_else(|e| e.exit());
2340+
let args: Args = Docopt::new(USAGE)
2341+
.and_then(|d| d.decode())
2342+
.unwrap_or_else(|e| e.exit());
23242343

23252344
let stage = if args.flag_l {
23262345
Tokens
@@ -3848,7 +3867,7 @@ entry:
38483867
}
38493868
```
38503869

3851-
Yes, we work with complex numbers using our simple languages. Now we are ready to paint some
3870+
Yes, we work with complex numbers using our simple language. Now we are ready to paint some
38523871
nice pictures.
38533872

38543873
```
@@ -4036,4 +4055,4 @@ So we see that Kaleidoscope has grown to a real and powerful language.
40364055
As usually you can experiment with
40374056
[the full code for this chapter](https://github.com/jauhien/iron-kaleidoscope/tree/master/chapters/5).
40384057

4039-
## Extending Kaleidoscope: mutable variables
4058+
## Chapter 6. Extending Kaleidoscope: mutable variables

chapters/0/src/main.rs

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
#![feature(plugin)]
2-
#![plugin(docopt_macros)]
3-
41
extern crate rustc_serialize;
52
extern crate docopt;
63

@@ -10,17 +7,28 @@ use iron_kaleidoscope::driver::{main_loop,
107
Tokens
118
};
129

13-
docopt!(Args, "
10+
use docopt::Docopt;
11+
12+
const USAGE: &'static str = "
1413
Usage: iron_kaleidoscope [(-l | -p | -i)]
1514
1615
Options:
1716
-l Run only lexer and show its output.
1817
-p Run only parser and show its output.
1918
-i Run only IR builder and show its output.
20-
");
19+
";
20+
21+
#[derive(Debug, RustcDecodable)]
22+
struct Args {
23+
flag_l: bool,
24+
flag_p: bool,
25+
flag_i: bool
26+
}
2127

2228
fn main() {
23-
let args: Args = Args::docopt().decode().unwrap_or_else(|e| e.exit());
29+
let args: Args = Docopt::new(USAGE)
30+
.and_then(|d| d.decode())
31+
.unwrap_or_else(|e| e.exit());
2432

2533
if args.flag_p || args.flag_i {
2634
unimplemented!();

chapters/1/src/main.rs

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
#![feature(plugin)]
2-
#![plugin(docopt_macros)]
3-
41
extern crate rustc_serialize;
52
extern crate docopt;
63

@@ -11,17 +8,28 @@ use iron_kaleidoscope::driver::{main_loop,
118
Tokens
129
};
1310

14-
docopt!(Args, "
11+
use docopt::Docopt;
12+
13+
const USAGE: &'static str = "
1514
Usage: iron_kaleidoscope [(-l | -p | -i)]
1615
1716
Options:
1817
-l Run only lexer and show its output.
1918
-p Run only parser and show its output.
2019
-i Run only IR builder and show its output.
21-
");
20+
";
21+
22+
#[derive(Debug, RustcDecodable)]
23+
struct Args {
24+
flag_l: bool,
25+
flag_p: bool,
26+
flag_i: bool
27+
}
2228

2329
fn main() {
24-
let args: Args = Args::docopt().decode().unwrap_or_else(|e| e.exit());
30+
let args: Args = Docopt::new(USAGE)
31+
.and_then(|d| d.decode())
32+
.unwrap_or_else(|e| e.exit());
2533

2634
let stage = if args.flag_l {
2735
Tokens

0 commit comments

Comments
 (0)