1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2025-12-20 08:07:59 +01:00

Add named groups (a la Python) to util.regexp.

This commit is contained in:
Kris Maglione
2011-01-12 12:25:46 -05:00
parent d6e22872d3
commit c3a90cf2b3
10 changed files with 68 additions and 51 deletions

View File

@@ -1049,18 +1049,16 @@ var Commands = Module("commands", {
validName: Class.memoize(function () RegExp("^" + this.nameRegexp.source + "$")),
CommandMatch: Struct("match", "spec", "prespace", "count", "cmd", "bang", "space", "args"),
commandRegexp: Class.memoize(function () util.regexp(<![CDATA[
^
(
([:\s]*)
( (?:\d+ | %)? )
( (?:<name> | !)? )
(!?)
(\s*)
(?P<spec>
(?P<prespace> [:\s]*)
(?P<count> (?:\d+ | %)? )
(?P<cmd> (?:<name> | !)? )
(?P<bang> !?)
(?P<space> \s*)
)
(
(?P<args>
(?:. | \n)*?
)?
$
@@ -1229,7 +1227,6 @@ var Commands = Module("commands", {
let match = commands.commandRegexp.exec(args.commandString);
if (!match)
return;
match = commands.CommandMatch.apply(null, match);
context.advance(match.prespace.length + match.count.length);
if (!(match.bang || match.space)) {