for (c = reader.peek(); c; c = reader.peek()) {
if (/^[^\r\n\f]$/.test(reader.peek(2))) {
ident += this.readEscape(reader.read(), true);
} else if (isNameChar(c)) {
readEscape: function(first, unescape) {
var reader = this._reader,
cssEscape += reader.read();
} while (c && isHexDigit(c) && ++i < 6);
if (cssEscape.length === 1) {
if (/^[^\r\n\f0-9a-f]$/.test(c)) {
// We should never get here (readName won't call readEscape
// if the escape sequence is bad).
throw new Error("Bad escape sequence.");
if (reader.peek() === "\n") {
} else if (/^[ \t\n\f]$/.test(c)) {
var cp = parseInt(cssEscape.slice(first.length), 16);
return String.fromCodePoint ? String.fromCodePoint(cp) :
readComment: function(first) {
var reader = this._reader,
//look for end of comment
if (comment.length > 2 && c === "*" && reader.peek() === "/") {
comment += reader.read();
},{"../util/TokenStreamBase":27,"./PropertyValuePart":11,"./Tokens":18}],18:[function(require,module,exports){
var Tokens = module.exports = [
* The following token names are defined in CSS3 Grammar: https://www.w3.org/TR/css3-syntax/#lexical
{ name: "S", whitespace: true/*, channel: "ws"*/ },
{ name: "COMMENT", comment: true, hide: true, channel: "comment" },
{ name: "INCLUDES", text: "~=" },
{ name: "DASHMATCH", text: "|=" },
{ name: "PREFIXMATCH", text: "^=" },
{ name: "SUFFIXMATCH", text: "$=" },
{ name: "SUBSTRINGMATCH", text: "*=" },
{ name: "IMPORT_SYM", text: "@import" },
{ name: "PAGE_SYM", text: "@page" },
{ name: "MEDIA_SYM", text: "@media" },
{ name: "FONT_FACE_SYM", text: "@font-face" },
{ name: "CHARSET_SYM", text: "@charset" },
{ name: "NAMESPACE_SYM", text: "@namespace" },
{ name: "SUPPORTS_SYM", text: "@supports" },
{ name: "VIEWPORT_SYM", text: ["@viewport", "@-ms-viewport", "@-o-viewport"] },
{ name: "DOCUMENT_SYM", text: ["@document", "@-moz-document"] },
{ name: "KEYFRAMES_SYM", text: [ "@keyframes", "@-webkit-keyframes", "@-moz-keyframes", "@-o-keyframes" ] },
{ name: "IMPORTANT_SYM" },
{ name: "UNICODE_RANGE" },
* The following token names are defined in CSS3 Selectors: https://www.w3.org/TR/css3-selectors/#selector-syntax
{ name: "PLUS", text: "+" },
{ name: "GREATER", text: ">" },
{ name: "COMMA", text: "," },
{ name: "TILDE", text: "~" },
* Defined in CSS3 Paged Media
{ name: "TOPLEFTCORNER_SYM", text: "@top-left-corner" },
{ name: "TOPLEFT_SYM", text: "@top-left" },
{ name: "TOPCENTER_SYM", text: "@top-center" },
{ name: "TOPRIGHT_SYM", text: "@top-right" },
{ name: "TOPRIGHTCORNER_SYM", text: "@top-right-corner" },
{ name: "BOTTOMLEFTCORNER_SYM", text: "@bottom-left-corner" },
{ name: "BOTTOMLEFT_SYM", text: "@bottom-left" },
{ name: "BOTTOMCENTER_SYM", text: "@bottom-center" },
{ name: "BOTTOMRIGHT_SYM", text: "@bottom-right" },
{ name: "BOTTOMRIGHTCORNER_SYM", text: "@bottom-right-corner" },
{ name: "LEFTTOP_SYM", text: "@left-top" },
{ name: "LEFTMIDDLE_SYM", text: "@left-middle" },
{ name: "LEFTBOTTOM_SYM", text: "@left-bottom" },
{ name: "RIGHTTOP_SYM", text: "@right-top" },
{ name: "RIGHTMIDDLE_SYM", text: "@right-middle" },
{ name: "RIGHTBOTTOM_SYM", text: "@right-bottom" },
* The following token names are defined in CSS3 Media Queries: https://www.w3.org/TR/css3-mediaqueries/#syntax
/*{ name: "MEDIA_ONLY", state: "media"},
{ name: "MEDIA_NOT", state: "media"},
{ name: "MEDIA_AND", state: "media"},*/
{ name: "RESOLUTION", state: "media" },
* The following token names are not defined in any CSS specification but are used by the lexer.
// not a real token, but useful for stupid IE filters
// part of CSS3 grammar but not the Flex code
// Not defined as tokens, but might as well be
typeMap = Object.create(null);
Tokens.unshift({ name:"EOF" });
for (var i=0, len = Tokens.length; i < len; i++) {
nameMap.push(Tokens[i].name);
Tokens[Tokens[i].name] = i;
if (Tokens[i].text instanceof Array) {
for (var j=0; j < Tokens[i].text.length; j++) {
typeMap[Tokens[i].text[j]] = i;
typeMap[Tokens[i].text] = i;
Tokens.name = function(tt) {
Tokens.type = function(c) {
},{}],19:[function(require,module,exports){
/* exported Validation */
var Matcher = require("./Matcher");
var Properties = require("./Properties");
var ValidationTypes = require("./ValidationTypes");
var ValidationError = require("./ValidationError");
var PropertyValueIterator = require("./PropertyValueIterator");
var Validation = module.exports = {
validate: function(property, value) {
var name = property.toString().toLowerCase(),
expression = new PropertyValueIterator(value),
if (name.indexOf("-") !== 0) { //vendor prefixed are ok
throw new ValidationError("Unknown property '" + property + "'.", property.line, property.col);
} else if (typeof spec !== "number") {
// All properties accept some CSS-wide values.
// https://drafts.csswg.org/css-values-3/#common-keywords
if (ValidationTypes.isAny(expression, "inherit | initial | unset")) {
if (expression.hasNext()) {
part = expression.next();
throw new ValidationError("Expected end of value but found '" + part + "'.", part.line, part.col);
// Property-specific validation.
this.singleProperty(spec, expression);
singleProperty: function(types, expression) {
value = expression.value,
result = Matcher.parse(types).match(expression);
if (expression.hasNext() && !expression.isFirst()) {
part = expression.peek();
throw new ValidationError("Expected end of value but found '" + part + "'.", part.line, part.col);
throw new ValidationError("Expected (" + ValidationTypes.describe(types) + ") but found '" + value + "'.", value.line, value.col);
} else if (expression.hasNext()) {
part = expression.next();
throw new ValidationError("Expected end of value but found '" + part + "'.", part.line, part.col);
},{"./Matcher":3,"./Properties":7,"./PropertyValueIterator":10,"./ValidationError":20,"./ValidationTypes":21}],20:[function(require,module,exports){
module.exports = ValidationError;
* Type to use when a validation error occurs.
* @namespace parserlib.util
* @param {String} message The error message.
* @param {int} line The line at which the error occurred.
* @param {int} col The column at which the error occurred.
function ValidationError(message, line, col) {
* The column at which the error occurred.
* The line at which the error occurred.
* The text representation of the unit.
ValidationError.prototype = new Error();
},{}],21:[function(require,module,exports){
var ValidationTypes = module.exports;
var Matcher = require("./Matcher");
function copy(to, from) {
Object.keys(from).forEach(function(prop) {
isLiteral: function (part, literals) {
var text = part.text.toString().toLowerCase(),
args = literals.split(" | "),
for (i=0, len=args.length; i < len && !found; i++) {
if (args[i].charAt(0) === "<") {
found = this.simple[args[i]](part);
} else if (args[i].slice(-2) === "()") {
found = (part.type === "function" &&
part.name === args[i].slice(0, -2));
} else if (text === args[i].toLowerCase()) {
isSimple: function(type) {
return Boolean(this.simple[type]);
isComplex: function(type) {
return Boolean(this.complex[type]);
describe: function(type) {
if (this.complex[type] instanceof Matcher) {
return this.complex[type].toString(0);
* Determines if the next part(s) of the given expression
* are any of the given types.
isAny: function (expression, types) {
var args = types.split(" | "),
for (i=0, len=args.length; i < len && !found && expression.hasNext(); i++) {
found = this.isType(expression, args[i]);
* Determines if the next part(s) of the given expression
isAnyOfGroup: function(expression, types) {
var args = types.split(" || "),
for (i=0, len=args.length; i < len && !found; i++) {
found = this.isType(expression, args[i]);
return found ? args[i-1] : false;
* Determines if the next part(s) of the given expression
isType: function (expression, type) {
var part = expression.peek(),
if (type.charAt(0) !== "<") {
result = this.isLiteral(part, type);