11extern crate docopt;
22extern crate regex;
3- extern crate regex_syntax as syntax;
4- extern crate regex_syntax2;
3+ extern crate regex_syntax2 as syntax;
54extern crate serde;
65#[ macro_use]
76extern crate serde_derive;
@@ -12,14 +11,14 @@ use std::process;
1211use std:: result;
1312
1413use docopt:: Docopt ;
14+ use syntax:: hir:: Hir ;
15+ use syntax:: hir:: literal:: Literals ;
1516use regex:: internal:: { Compiler , LiteralSearcher } ;
16- use syntax:: { ExprBuilder , Expr , Literals } ;
1717
1818const USAGE : & ' static str = "
1919Usage:
2020 regex-debug [options] ast <pattern>
21- regex-debug [options] ast2 <pattern>
22- regex-debug [options] hir2 <pattern>
21+ regex-debug [options] hir <pattern>
2322 regex-debug [options] prefixes <patterns> ...
2423 regex-debug [options] suffixes <patterns> ...
2524 regex-debug [options] anchors <pattern>
@@ -54,8 +53,7 @@ Options:
5453#[ derive( Deserialize ) ]
5554struct Args {
5655 cmd_ast : bool ,
57- cmd_ast2 : bool ,
58- cmd_hir2 : bool ,
56+ cmd_hir : bool ,
5957 cmd_prefixes : bool ,
6058 cmd_suffixes : bool ,
6159 cmd_anchors : bool ,
@@ -98,10 +96,8 @@ fn main() {
9896fn run ( args : & Args ) -> Result < ( ) > {
9997 if args. cmd_ast {
10098 cmd_ast ( args)
101- } else if args. cmd_ast2 {
102- cmd_ast2 ( args)
103- } else if args. cmd_hir2 {
104- cmd_hir2 ( args)
99+ } else if args. cmd_hir {
100+ cmd_hir ( args)
105101 } else if args. cmd_prefixes {
106102 cmd_literals ( args)
107103 } else if args. cmd_suffixes {
@@ -118,22 +114,16 @@ fn run(args: &Args) -> Result<()> {
118114}
119115
120116fn cmd_ast ( args : & Args ) -> Result < ( ) > {
121- let ast = try!( args. parse_one ( ) ) ;
122- println ! ( "{:#?}" , ast) ;
123- Ok ( ( ) )
124- }
125-
126- fn cmd_ast2 ( args : & Args ) -> Result < ( ) > {
127- use regex_syntax2:: ast:: parse:: Parser ;
117+ use syntax:: ast:: parse:: Parser ;
128118
129119 let mut parser = Parser :: new ( ) ;
130120 let ast = try!( parser. parse ( & args. arg_pattern ) ) ;
131121 println ! ( "{:#?}" , ast) ;
132122 Ok ( ( ) )
133123}
134124
135- fn cmd_hir2 ( args : & Args ) -> Result < ( ) > {
136- use regex_syntax2 :: ParserBuilder ;
125+ fn cmd_hir ( args : & Args ) -> Result < ( ) > {
126+ use syntax :: ParserBuilder ;
137127
138128 let mut parser = ParserBuilder :: new ( )
139129 . allow_invalid_utf8 ( false )
@@ -213,17 +203,17 @@ fn cmd_compile(args: &Args) -> Result<()> {
213203}
214204
215205impl Args {
216- fn parse_one ( & self ) -> Result < Expr > {
206+ fn parse_one ( & self ) -> Result < Hir > {
217207 parse ( & self . arg_pattern )
218208 }
219209
220- fn parse_many ( & self ) -> Result < Vec < Expr > > {
210+ fn parse_many ( & self ) -> Result < Vec < Hir > > {
221211 self . arg_patterns . iter ( ) . map ( |s| parse ( s) ) . collect ( )
222212 }
223213
224- fn literals < F : Fn ( & mut Literals , & Expr ) -> bool > (
214+ fn literals < F : Fn ( & mut Literals , & Hir ) -> bool > (
225215 & self ,
226- exprs : & [ Expr ] ,
216+ exprs : & [ Hir ] ,
227217 get_literals : F ,
228218 ) -> Literals {
229219 let mut lits = Some ( self . empty_literals ( ) ) ;
@@ -251,8 +241,13 @@ impl Args {
251241 }
252242}
253243
254- fn parse ( re : & str ) -> Result < Expr > {
255- ExprBuilder :: new ( ) . allow_bytes ( true ) . parse ( re) . map_err ( From :: from)
244+ fn parse ( re : & str ) -> Result < Hir > {
245+ use syntax:: ParserBuilder ;
246+ ParserBuilder :: new ( )
247+ . allow_invalid_utf8 ( true )
248+ . build ( )
249+ . parse ( re)
250+ . map_err ( From :: from)
256251}
257252
258253fn escape_unicode ( bytes : & [ u8 ] ) -> String {
0 commit comments