egra: and even more faster text rendering
[iv.d.git] / srex / srex_test.d
blobd70a265aa1d839ea9a5a1526e27d61259b723d5b
1 /*
2 * Copyright 2012 Yichun "agentzh" Zhang
3 * Copyright 2007-2009 Russ Cox. All Rights Reserved.
4 * Use of this source code is governed by a BSD-style
6 * Part of this code is from the NGINX opensource project: http://nginx.org/LICENSE
8 * This library is licensed under the BSD license.
10 * Copyright (c) 2012-2014 Yichun "agentzh" Zhang.
12 * Copyright (c) 2007-2009 Russ Cox, Google Inc. All rights reserved.
14 * Redistribution and use in source and binary forms, with or without
15 * modification, are permitted provided that the following conditions are
16 * met:
18 * * Redistributions of source code must retain the above copyright
19 * notice, this list of conditions and the following disclaimer.
20 * * Redistributions in binary form must reproduce the above
21 * copyright notice, this list of conditions and the following disclaimer
22 * in the documentation and/or other materials provided with the
23 * distribution.
24 * * Neither the name of Google, Inc. nor the names of its
25 * contributors may be used to endorse or promote products derived from
26 * this software without specific prior written permission.
28 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
29 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
30 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
31 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
32 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
33 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
34 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
35 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
36 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
37 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
38 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
40 module srex_test /*is aliced*/;
42 import iv.alice;
43 import iv.vfs.io;
44 import iv.srex;
47 void main () {
48 import std.utf : byChar;
50 //enum str = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
51 enum str = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
52 enum restr = "[a]?a?(a?)a?(a?)a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
54 writeln("\n\n\n");
56 //auto pre = RegExp.create("^a+bc|d".byChar);
57 //auto re = RegExp.create("bc".byChar);
58 auto re = RegExp.create(restr.byChar);
59 if (!re.valid) {
60 writeln("*** ERROR at ", re.lastErrorPos, ": ", re.lastError);
61 assert(0);
63 writeln("captures: ", re.captureCount);
67 writeln("======================================");
68 Pike.Capture[64] ovec;
69 auto ctx = Pike.create(re, ovec[]);
70 auto res = ctx.exec(str);
71 writeln("pike: ", res);
72 if (res == 0) {
73 foreach (immutable idx; 0..re.captureCount) {
74 writeln("capture #", idx, ": s=", ovec[idx].s, "; e=", ovec[idx].e);
77 writeln("======================================");
81 writeln("======================================");
82 auto ctx = Thompson.create(re);
83 auto res = ctx.exec(str);
84 writeln("thompson: ", res);
85 writeln("======================================");