1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2026-02-15 11:15:46 +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

@@ -214,6 +214,7 @@ var Hive = Class("Hive", {
},
});
try {
/**
* Manages named and unnamed user style sheets, which apply to both
* chrome and content pages.
@@ -330,16 +331,15 @@ var Styles = Module("Styles", {
let match, i = 0;
while ((!match || match[0]) && (match = Styles.propertyPattern.exec(str)))
if (always && !i++ || match[0] && match[3])
yield this.Property.fromArray(match);
yield match;
},
Property: Struct("whole", "preSpace", "name", "value", "postSpace"),
propertyPattern: util.regexp(<![CDATA[
(?:
(<space>*)
([-a-z]*)
(?P<preSpace> <space>*)
(?P<name> [-a-z]*)
(?:
<space>* : \s* (
<space>* : \s* (?P<value>
(?:
[-\w]
(?:
@@ -355,7 +355,7 @@ var Styles = Module("Styles", {
)
)?
)
(<space>* (?: ; | $) )
(?P<postSpace> <space>* (?: ; | $) )
]]>, "gi",
{
space: /(?: \s | \/\* .*? \*\/ )/,
@@ -550,6 +550,6 @@ var Styles = Module("Styles", {
endModule();
// catch(e){dump(e.fileName+":"+e.lineNumber+": "+e+"\n" + e.stack);}
} catch(e){dump(e.fileName+":"+e.lineNumber+": "+e+"\n" + e.stack);}
// vim: set fdm=marker sw=4 ts=4 et ft=javascript: