aboutsummaryrefslogtreecommitdiff
path: root/lib/style-reader.js
diff options
context:
space:
mode:
Diffstat (limited to 'lib/style-reader.js')
-rw-r--r--lib/style-reader.js23
1 files changed, 21 insertions, 2 deletions
diff --git a/lib/style-reader.js b/lib/style-reader.js
index d749743..be5d5d3 100644
--- a/lib/style-reader.js
+++ b/lib/style-reader.js
@@ -1,9 +1,25 @@
var lop = require("lop");
var RegexTokeniser = lop.RegexTokeniser;
+var documentMatchers = require("./document-matchers");
var htmlPaths = require("./html-paths");
exports.readHtmlPath = readHtmlPath;
+exports.readDocumentMatcher = readDocumentMatcher;
+
+
+function readDocumentMatcher(string) {
+ var paragraphRule = lop.rules.then(
+ lop.rules.token("identifier", "p"),
+ function() {
+ return documentMatchers.paragraph();
+ }
+ );
+
+ var matcherRule = paragraphRule;
+
+ return parseString(matcherRule, string);
+}
function readHtmlPath(string) {
@@ -55,10 +71,13 @@ function readHtmlPath(string) {
),
htmlPaths.elements
);
-
+ return parseString(styleRule, string);
+}
+
+function parseString(rule, string) {
var tokens = tokenise(string);
var parser = lop.Parser();
- var parseResult = parser.parseTokens(styleRule, tokens);
+ var parseResult = parser.parseTokens(rule, tokens);
if (!parseResult.isSuccess()) {
throw new Error("Failed to parse: " + describeFailure(parseResult));
}