Skip to content

Commit 59099c7

Browse files
committed
---
yaml --- r: 112874 b: refs/heads/auto c: dbea485 h: refs/heads/master v: v3
1 parent db503ce commit 59099c7

File tree

12 files changed

+122
-367
lines changed

12 files changed

+122
-367
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0
1313
refs/tags/release-0.3.1: 495bae036dfe5ec6ceafd3312b4dca48741e845b
1414
refs/tags/release-0.4: e828ea2080499553b97dfe33b3f4d472b4562ad7
1515
refs/tags/release-0.5: 7e3bcfbf21278251ee936ad53e92e9b719702d73
16-
refs/heads/auto: a3f9f37014c77cda1ae53bf0984190e877aa413a
16+
refs/heads/auto: dbea4853a97ff7bc2e7a25f41be6c49b7dc6e960
1717
refs/heads/servo: af82457af293e2a842ba6b7759b70288da276167
1818
refs/tags/release-0.6: b4ebcfa1812664df5e142f0134a5faea3918544c
1919
refs/tags/0.1: b19db808c2793fe2976759b85a355c3ad8c8b336

branches/auto/src/libregex/compile.rs

Lines changed: 26 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#![allow(visible_private_types)]
1414

1515
use std::cmp;
16+
use std::iter;
1617
use parse;
1718
use parse::{
1819
Flags, FLAG_EMPTY,
@@ -88,7 +89,7 @@ pub struct Program {
8889

8990
impl Program {
9091
/// Compiles a Regex given its AST.
91-
pub fn new(ast: parse::Ast) -> (Program, Vec<Option<~str>>) {
92+
pub fn new(ast: ~parse::Ast) -> (Program, ~[Option<~str>]) {
9293
let mut c = Compiler {
9394
insts: Vec::with_capacity(100),
9495
names: Vec::with_capacity(10),
@@ -103,16 +104,16 @@ impl Program {
103104
// This is a bit hacky since we have to skip over the initial
104105
// 'Save' instruction.
105106
let mut pre = StrBuf::with_capacity(5);
106-
for inst in c.insts.slice_from(1).iter() {
107-
match *inst {
107+
for i in iter::range(1, c.insts.len()) {
108+
match *c.insts.get(i) {
108109
OneChar(c, FLAG_EMPTY) => pre.push_char(c),
109110
_ => break
110111
}
111112
}
112113

113-
let Compiler { insts, names } = c;
114+
let names = c.names.as_slice().into_owned();
114115
let prog = Program {
115-
insts: insts,
116+
insts: c.insts,
116117
prefix: pre.into_owned(),
117118
};
118119
(prog, names)
@@ -143,48 +144,48 @@ struct Compiler<'r> {
143144
// The only tricky thing here is patching jump/split instructions to point to
144145
// the right instruction.
145146
impl<'r> Compiler<'r> {
146-
fn compile(&mut self, ast: parse::Ast) {
147+
fn compile(&mut self, ast: ~parse::Ast) {
147148
match ast {
148-
Nothing => {},
149-
Literal(c, flags) => self.push(OneChar(c, flags)),
150-
Dot(nl) => self.push(Any(nl)),
151-
Class(ranges, flags) =>
149+
~Nothing => {},
150+
~Literal(c, flags) => self.push(OneChar(c, flags)),
151+
~Dot(nl) => self.push(Any(nl)),
152+
~Class(ranges, flags) =>
152153
self.push(CharClass(ranges, flags)),
153-
Begin(flags) => self.push(EmptyBegin(flags)),
154-
End(flags) => self.push(EmptyEnd(flags)),
155-
WordBoundary(flags) => self.push(EmptyWordBoundary(flags)),
156-
Capture(cap, name, x) => {
154+
~Begin(flags) => self.push(EmptyBegin(flags)),
155+
~End(flags) => self.push(EmptyEnd(flags)),
156+
~WordBoundary(flags) => self.push(EmptyWordBoundary(flags)),
157+
~Capture(cap, name, x) => {
157158
let len = self.names.len();
158159
if cap >= len {
159160
self.names.grow(10 + cap - len, &None)
160161
}
161162
*self.names.get_mut(cap) = name;
162163

163164
self.push(Save(2 * cap));
164-
self.compile(*x);
165+
self.compile(x);
165166
self.push(Save(2 * cap + 1));
166167
}
167-
Cat(xs) => {
168+
~Cat(xs) => {
168169
for x in xs.move_iter() {
169170
self.compile(x)
170171
}
171172
}
172-
Alt(x, y) => {
173+
~Alt(x, y) => {
173174
let split = self.empty_split(); // push: split 0, 0
174175
let j1 = self.insts.len();
175-
self.compile(*x); // push: insts for x
176+
self.compile(x); // push: insts for x
176177
let jmp = self.empty_jump(); // push: jmp 0
177178
let j2 = self.insts.len();
178-
self.compile(*y); // push: insts for y
179+
self.compile(y); // push: insts for y
179180
let j3 = self.insts.len();
180181

181182
self.set_split(split, j1, j2); // split 0, 0 -> split j1, j2
182183
self.set_jump(jmp, j3); // jmp 0 -> jmp j3
183184
}
184-
Rep(x, ZeroOne, g) => {
185+
~Rep(x, ZeroOne, g) => {
185186
let split = self.empty_split();
186187
let j1 = self.insts.len();
187-
self.compile(*x);
188+
self.compile(x);
188189
let j2 = self.insts.len();
189190

190191
if g.is_greedy() {
@@ -193,11 +194,11 @@ impl<'r> Compiler<'r> {
193194
self.set_split(split, j2, j1);
194195
}
195196
}
196-
Rep(x, ZeroMore, g) => {
197+
~Rep(x, ZeroMore, g) => {
197198
let j1 = self.insts.len();
198199
let split = self.empty_split();
199200
let j2 = self.insts.len();
200-
self.compile(*x);
201+
self.compile(x);
201202
let jmp = self.empty_jump();
202203
let j3 = self.insts.len();
203204

@@ -208,9 +209,9 @@ impl<'r> Compiler<'r> {
208209
self.set_split(split, j3, j2);
209210
}
210211
}
211-
Rep(x, OneMore, g) => {
212+
~Rep(x, OneMore, g) => {
212213
let j1 = self.insts.len();
213-
self.compile(*x);
214+
self.compile(x);
214215
let split = self.empty_split();
215216
let j2 = self.insts.len();
216217

branches/auto/src/libregex/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,7 @@
362362
html_root_url = "http://static.rust-lang.org/doc/master")]
363363

364364
#![feature(macro_rules, phase)]
365-
#![deny(missing_doc, deprecated_owned_vector)]
365+
#![deny(missing_doc)]
366366

367367
extern crate collections;
368368
#[cfg(test)]

0 commit comments

Comments
 (0)