Skip to content

Commit

Permalink
Turn the venerable alias A B; to alias B = A;
Browse files Browse the repository at this point in the history
  • Loading branch information
DmitryOlshansky committed Nov 28, 2013
1 parent 9719cfc commit 924ddac
Showing 1 changed file with 34 additions and 33 deletions.
67 changes: 34 additions & 33 deletions std/regex.d
Expand Up @@ -699,7 +699,8 @@ enum RegexOption: uint {
multiline = 0x10,
singleline = 0x20
}
alias TypeTuple!('g', 'i', 'x', 'U', 'm', 's') RegexOptionNames;//do not reorder this list
//do not reorder this list
alias RegexOptionNames = TypeTuple!('g', 'i', 'x', 'U', 'm', 's');
static assert( RegexOption.max < 0x80);
enum RegexInfo : uint { oneShot = 0x80 }
alias Escapables = TypeTuple!('[', ']', '\\', '^', '$', '.', '|', '?', ',', '-',
Expand Down Expand Up @@ -751,7 +752,7 @@ enum maxCharsetUsed = 6;

enum maxCachedTries = 8;

alias CodepointTrie!8 Trie;
alias Trie = CodepointTrie!8;

Trie[const(CodepointSet)] trieCache;

Expand Down Expand Up @@ -790,7 +791,7 @@ auto memoizeExpr(string expr)()
{
if(__ctfe)
return mixin(expr);
alias typeof(mixin(expr)) T;
alias T = typeof(mixin(expr));
static T slot;
static bool initialized;
if(!initialized)
Expand All @@ -806,7 +807,7 @@ auto memoizeExpr(string expr)()
+/
@trusted const(CodepointSet) getUnicodeSet(in char[] name, bool negated, bool casefold)
{
alias comparePropertyName ucmp;
alias ucmp = comparePropertyName;
CodepointSet s;

//unicode property
Expand Down Expand Up @@ -1710,8 +1711,8 @@ struct Parser(R)
return tuple(set, op);
}

alias Stack!(CodepointSet) ValStack;
alias Stack!(Operator) OpStack;
alias ValStack = Stack!(CodepointSet);
alias OpStack = Stack!(Operator);

//parse and store IR for CodepointSet
void parseCharset()
Expand Down Expand Up @@ -1952,7 +1953,7 @@ struct Parser(R)
//\ - assumed to be processed, p - is current
const(CodepointSet) parseUnicodePropertySpec(bool negated)
{
alias comparePropertyName ucmp;
alias ucmp = comparePropertyName;
enum MAX_PROPERTY = 128;
char[MAX_PROPERTY] result;
uint k = 0;
Expand Down Expand Up @@ -1987,7 +1988,7 @@ struct Parser(R)
throw new RegexException(app.data);
}

alias BasicElementOf!R Char;
alias Char = BasicElementOf!R;
//packages parsing results into a RegEx object
@property Regex!Char program()
{
Expand Down Expand Up @@ -2059,7 +2060,7 @@ public struct Regex(Char)
@property string back() { return groups[end-1].name; }
@property bool empty() { return start >= end; }
@property size_t length() { return end - start; }
alias length opDollar;
alias opDollar = length;
@property NamedGroupRange save()
{
return NamedGroupRange(groups, start, end);
Expand Down Expand Up @@ -2520,8 +2521,8 @@ int quickTestFwd(RegEx)(uint pc, dchar front, const ref RegEx re)
public struct StaticRegex(Char)
{
private:
alias BacktrackingMatcher!(true) Matcher;
alias bool function(ref Matcher!Char) @trusted MatchFn;
alias Matcher = BacktrackingMatcher!(true);
alias MatchFn = bool function(ref Matcher!Char) @trusted;
MatchFn nativeFn;
public:
Regex!Char _regex;
Expand Down Expand Up @@ -3002,8 +3003,8 @@ unittest
{
foreach(i, v; TypeTuple!(char, wchar, dchar))
{
alias v Char;
alias immutable(v)[] String;
alias Char = v;
alias String = immutable(v)[];
auto r = regex(to!String(`abc$`));
auto kick = Kick!Char(r, new uint[256]);
assert(kick.length == 3, text(Kick.stringof," ",v.stringof, " == ", kick.length));
Expand All @@ -3028,8 +3029,8 @@ unittest
{
foreach(i, v;TypeTuple!(char, wchar, dchar))
{
alias v Char;
alias immutable(v)[] String;
alias Char = v;
alias String = immutable(v)[];
auto r = regex(to!String(`abc[a-z]`));
auto kick = Kick!Char(r, new uint[256]);
auto x = kick.search(to!String("abbabca"), 0);
Expand Down Expand Up @@ -3059,15 +3060,15 @@ unittest
test_flex!(ShiftOr)();
}

alias ShiftOr Kickstart;
alias Kickstart = ShiftOr;

//Simple UTF-string abstraction compatible with stream interface
struct Input(Char)
if(is(Char :dchar))
{
alias size_t DataIndex;
alias DataIndex = size_t;
enum { isLoopback = false };
alias const(Char)[] String;
alias String = const(Char)[];
String _origin;
size_t _index;

Expand Down Expand Up @@ -3107,7 +3108,7 @@ struct Input(Char)

struct BackLooper
{
alias size_t DataIndex;
alias DataIndex = size_t;
enum { isLoopback = true };
String _origin;
size_t _index;
Expand Down Expand Up @@ -3166,7 +3167,7 @@ template BacktrackingMatcher(bool CTregex)
@trusted struct BacktrackingMatcher(Char, Stream = Input!Char)
if(is(Char : dchar))
{
alias Stream.DataIndex DataIndex;
alias DataIndex = Stream.DataIndex;
struct State
{//top bit in pc is set if saved along with matches
DataIndex index;
Expand All @@ -3176,7 +3177,7 @@ template BacktrackingMatcher(bool CTregex)
enum stateSize = State.sizeof / size_t.sizeof;
enum initialStack = 1<<16;
alias const(Char)[] String;
alias Regex!Char RegEx;
alias RegEx = Regex!Char;
alias MatchFn = bool function (ref BacktrackingMatcher!(Char, Stream));
RegEx re; //regex program
static if(CTregex)
Expand Down Expand Up @@ -4608,7 +4609,7 @@ enum OneShot { Fwd, Bwd };
@trusted struct ThompsonMatcher(Char, Stream = Input!Char)
if(is(Char : dchar))
{
alias Stream.DataIndex DataIndex;
alias DataIndex = Stream.DataIndex;
Thread!DataIndex* freelist;
ThreadList!DataIndex clist, nlist;
DataIndex[] merge;
Expand Down Expand Up @@ -5482,8 +5483,8 @@ enum OneShot { Fwd, Bwd };
@trusted public struct Captures(R, DIndex = size_t)
if(isSomeString!R)
{//@trusted because of union inside
alias DIndex DataIndex;
alias R String;
alias DataIndex = DIndex;
alias String = R;
private:
R _input;
bool _empty;
Expand Down Expand Up @@ -5650,8 +5651,8 @@ unittest//verify example
if(isSomeString!R)
{
private:
alias BasicElementOf!R Char;
alias Engine!Char EngineType;
alias Char = BasicElementOf!R;
alias EngineType = Engine!Char;
EngineType _engine;
R _input;
Captures!(R,EngineType.DataIndex) _captures;
Expand Down Expand Up @@ -5762,8 +5763,8 @@ public:

private @trusted auto matchOnce(alias Engine, RegEx, R)(R input, RegEx re)
{
alias BasicElementOf!R Char;
alias Engine!Char EngineType;
alias Char = BasicElementOf!R;
alias EngineType = Engine!Char;

size_t size = EngineType.initialMemory(re);
void[] memory = enforce(malloc(size))[0..size];
Expand Down Expand Up @@ -5821,9 +5822,9 @@ public auto regexImpl(S)(S pattern, const(char)[] flags="")
template ctRegexImpl(alias pattern, string flags=[])
{
enum r = regex(pattern, flags);
alias BasicElementOf!(typeof(pattern)) Char;
alias Char = BasicElementOf!(typeof(pattern));
enum source = ctGenRegExCode(r);
alias BacktrackingMatcher!(true) Matcher;
alias Matcher = BacktrackingMatcher!(true);
@trusted bool func(ref Matcher!Char matcher)
{
debug(std_regex_ctr) pragma(msg, source);
Expand Down Expand Up @@ -6478,7 +6479,7 @@ public struct Splitter(Range, alias RegEx = Regex)
private:
Range _input;
size_t _offset;
alias typeof(match(Range.init,RegEx.init)) Rx;
alias Rx = typeof(match(Range.init,RegEx.init));
Rx _match;

@trusted this(Range input, RegEx separator)
Expand Down Expand Up @@ -6908,7 +6909,7 @@ unittest
int i;
foreach(Char; TypeTuple!( char, wchar, dchar))
{
alias immutable(Char)[] String;
alias String = immutable(Char)[];
String produceExpected(M,Range)(auto ref M m, Range fmt)
{
auto app = appender!(String)();
Expand Down Expand Up @@ -7216,7 +7217,7 @@ unittest
{
return std.string.toUpper(m.hit);
}
alias v String;
alias String = v;
assert(std.regex.replace!(matchFn)(to!String("ark rapacity"), regex(to!String("r")), to!String("c"))
== to!String("ack rapacity"));
assert(std.regex.replace!(matchFn)(to!String("ark rapacity"), regex(to!String("r"), "g"), to!String("c"))
Expand Down

0 comments on commit 924ddac

Please sign in to comment.