UNPKG

canonical

Version:

Canonical code style linter and formatter for JavaScript, SCSS and CSS.

1 lines 52.6 kB
'use strict';var Node=require('../node/basic-node');var NodeType=require('../node/node-types');var TokenType=require('../token-types');module.exports = (function(){var tokens, tokensLength, pos, needInfo;var rules={'arguments':function(){return checkArguments(pos) && getArguments();}, 'atkeyword':function(){return checkAtkeyword(pos) && getAtkeyword();}, 'atruleb':function(){return checkAtruleb(pos) && getAtruleb();}, 'atruler':function(){return checkAtruler(pos) && getAtruler();}, 'atrulerq':function(){return checkAtrulerq(pos) && getAtrulerq();}, 'atrulers':function(){return checkAtrulers(pos) && getAtrulers();}, 'atrules':function(){return checkAtrules(pos) && getAtrules();}, 'attrib':function(){return checkAttrib(pos) && getAttrib();}, 'attrselector':function(){return checkAttrselector(pos) && getAttrselector();}, 'block':function(){return checkBlock(pos) && getBlock();}, 'brackets':function(){return checkBrackets(pos) && getBrackets();}, 'class':function(){return checkClass(pos) && getClass();}, 'combinator':function(){return checkCombinator(pos) && getCombinator();}, 'commentML':function(){return checkCommentML(pos) && getCommentML();}, 'commentSL':function(){return checkCommentSL(pos) && getCommentSL();}, 'condition':function(){return checkCondition(pos) && getCondition();}, 'conditionalStatement':function(){return checkConditionalStatement(pos) && getConditionalStatement();}, 'declaration':function(){return checkDeclaration(pos) && getDeclaration();}, 'declDelim':function(){return checkDeclDelim(pos) && getDeclDelim();}, 'default':function(){return checkDefault(pos) && getDefault();}, 'delim':function(){return checkDelim(pos) && getDelim();}, 'dimension':function(){return checkDimension(pos) && getDimension();}, 'expression':function(){return checkExpression(pos) && getExpression();}, 'extend':function(){return checkExtend(pos) && getExtend();}, 'function':function(){return checkFunction(pos) && getFunction();}, 'ident':function(){return checkIdent(pos) && getIdent();}, 'important':function(){return checkImportant(pos) && getImportant();}, 'include':function(){return checkInclude(pos) && getInclude();}, 'interpolation':function(){return checkInterpolation(pos) && getInterpolation();}, 'loop':function(){return checkLoop(pos) && getLoop();}, 'mixin':function(){return checkMixin(pos) && getMixin();}, 'namespace':function(){return checkNamespace(pos) && getNamespace();}, 'nth':function(){return checkNth(pos) && getNth();}, 'nthselector':function(){return checkNthselector(pos) && getNthselector();}, 'number':function(){return checkNumber(pos) && getNumber();}, 'operator':function(){return checkOperator(pos) && getOperator();}, 'parentheses':function(){return checkParentheses(pos) && getParentheses();}, 'parentselector':function(){return checkParentSelector(pos) && getParentSelector();}, 'percentage':function(){return checkPercentage(pos) && getPercentage();}, 'placeholder':function(){return checkPlaceholder(pos) && getPlaceholder();}, 'progid':function(){return checkProgid(pos) && getProgid();}, 'property':function(){return checkProperty(pos) && getProperty();}, 'propertyDelim':function(){return checkPropertyDelim(pos) && getPropertyDelim();}, 'pseudoc':function(){return checkPseudoc(pos) && getPseudoc();}, 'pseudoe':function(){return checkPseudoe(pos) && getPseudoe();}, 'ruleset':function(){return checkRuleset(pos) && getRuleset();}, 's':function(){return checkS(pos) && getS();}, 'selector':function(){return checkSelector(pos) && getSelector();}, 'shash':function(){return checkShash(pos) && getShash();}, 'simpleselector':function(){return checkSimpleSelector(pos) && getSimpleSelector();}, 'string':function(){return checkString(pos) && getString();}, 'stylesheet':function(){return checkStylesheet(pos) && getStylesheet();}, 'unary':function(){return checkUnary(pos) && getUnary();}, 'uri':function(){return checkUri(pos) && getUri();}, 'value':function(){return checkValue(pos) && getValue();}, 'variable':function(){return checkVariable(pos) && getVariable();}, 'variableslist':function(){return checkVariablesList(pos) && getVariablesList();}, 'vhash':function(){return checkVhash(pos) && getVhash();}};function throwError(i){var ln=i?tokens[i].ln:tokens[pos].ln;throw {line:ln, syntax:'scss'};}function checkExcluding(exclude, i){var start=i;while(i < tokensLength) {if(exclude[tokens[i++].type])break;}return i - start - 2;}function joinValues(start, finish){var s='';for(var i=start; i < finish + 1; i++) {s += tokens[i].value;}return s;}function joinValues2(start, num){if(start + num - 1 >= tokensLength)return;var s='';for(var i=0; i < num; i++) {s += tokens[start + i].value;}return s;}function getLastPosition(content, line, column, colOffset){return typeof content === 'string'?getLastPositionForString(content, line, column, colOffset):getLastPositionForArray(content, line, column, colOffset);}function getLastPositionForString(content, line, column, colOffset){var position=[];if(!content){position = [line, column];if(colOffset)position[1] += colOffset - 1;return position;}var lastLinebreak=content.lastIndexOf('\n');var endsWithLinebreak=lastLinebreak === content.length - 1;var splitContent=content.split('\n');var linebreaksCount=splitContent.length - 1;var prevLinebreak=linebreaksCount === 0 || linebreaksCount === 1?-1:content.length - splitContent[linebreaksCount - 1].length - 2;var offset=endsWithLinebreak?linebreaksCount - 1:linebreaksCount;position[0] = line + offset;if(endsWithLinebreak){offset = prevLinebreak !== -1?content.length - prevLinebreak:content.length - 1;}else {offset = linebreaksCount !== 0?content.length - lastLinebreak - column - 1:content.length - 1;}position[1] = column + offset;if(!colOffset)return position;if(endsWithLinebreak){position[0]++;position[1] = colOffset;}else {position[1] += colOffset;}return position;}function getLastPositionForArray(content, line, column, colOffset){var position;if(content.length === 0){position = [line, column];}else {var c=content[content.length - 1];if(c.hasOwnProperty('end')){position = [c.end.line, c.end.column];}else {position = getLastPosition(c.content, line, column);}}if(!colOffset)return position;if(tokens[pos - 1].type !== 'Newline'){position[1] += colOffset;}else {position[0]++;position[1] = 1;}return position;}function newNode(type, content, line, column, end){if(!end)end = getLastPosition(content, line, column);return new Node({type:type, content:content, start:{line:line, column:column}, end:{line:end[0], column:end[1]}, syntax:'scss'});}function checkAny(i){return checkBrackets(i) || checkParentheses(i) || checkString(i) || checkVariablesList(i) || checkVariable(i) || checkPlaceholder(i) || checkPercentage(i) || checkDimension(i) || checkNumber(i) || checkUri(i) || checkExpression(i) || checkFunction(i) || checkIdent(i) || checkClass(i) || checkUnary(i);}function getAny(){if(checkBrackets(pos))return getBrackets();else if(checkParentheses(pos))return getParentheses();else if(checkString(pos))return getString();else if(checkVariablesList(pos))return getVariablesList();else if(checkVariable(pos))return getVariable();else if(checkPlaceholder(pos))return getPlaceholder();else if(checkPercentage(pos))return getPercentage();else if(checkDimension(pos))return getDimension();else if(checkNumber(pos))return getNumber();else if(checkUri(pos))return getUri();else if(checkExpression(pos))return getExpression();else if(checkFunction(pos))return getFunction();else if(checkIdent(pos))return getIdent();else if(checkClass(pos))return getClass();else if(checkUnary(pos))return getUnary();}function checkArguments(i){var start=i, l;if(i >= tokensLength || tokens[i].type !== TokenType.LeftParenthesis)return 0;i++;while(i < tokens[start].right) {if(l = checkArgument(i))i += l;else return 0;}return tokens[start].right - start + 1;}function checkArgument(i){return checkBrackets(i) || checkParentheses(i) || checkDeclaration(i) || checkFunction(i) || checkVariablesList(i) || checkVariable(i) || checkSC(i) || checkDelim(i) || checkDeclDelim(i) || checkString(i) || checkPercentage(i) || checkDimension(i) || checkNumber(i) || checkUri(i) || checkInterpolation(i) || checkIdent(i) || checkVhash(i) || checkOperator(i) || checkUnary(i);}function getArgument(){if(checkBrackets(pos))return getBrackets();else if(checkParentheses(pos))return getParentheses();else if(checkDeclaration(pos))return getDeclaration();else if(checkFunction(pos))return getFunction();else if(checkVariablesList(pos))return getVariablesList();else if(checkVariable(pos))return getVariable();else if(checkSC(pos))return getSC();else if(checkDelim(pos))return getDelim();else if(checkDeclDelim(pos))return getDeclDelim();else if(checkString(pos))return getString();else if(checkPercentage(pos))return getPercentage();else if(checkDimension(pos))return getDimension();else if(checkNumber(pos))return getNumber();else if(checkUri(pos))return getUri();else if(checkInterpolation(pos))return getInterpolation();else if(checkIdent(pos))return getIdent();else if(checkVhash(pos))return getVhash();else if(checkOperator(pos))return getOperator();else if(checkUnary(pos))return getUnary();}function checkAtkeyword(i){var l;if(i >= tokensLength || tokens[i++].type !== TokenType.CommercialAt)return 0;return (l = checkIdent(i))?l + 1:0;}function getAtkeyword(){var startPos=pos, x;pos++;x = [getIdent()];var token=tokens[startPos];return newNode(NodeType.AtkeywordType, x, token.ln, token.col);}function checkAttrib(i){if(i >= tokensLength || tokens[i].type !== TokenType.LeftSquareBracket || !tokens[i].right)return 0;return tokens[i].right - i + 1;}function getAttrib(){if(checkAttrib1(pos))return getAttrib1();if(checkAttrib2(pos))return getAttrib2();}function checkAttrib1(i){var start=i, l;if(i++ >= tokensLength)return 0;if(l = checkSC(i))i += l;if(l = checkIdent(i))i += l;else return 0;if(l = checkSC(i))i += l;if(l = checkAttrselector(i))i += l;else return 0;if(l = checkSC(i))i += l;if(l = checkIdent(i) || checkString(i))i += l;else return 0;if(l = checkSC(i))i += l;return tokens[i].type === TokenType.RightSquareBracket?i - start:0;}function getAttrib1(){var startPos=pos, x;var token=tokens[startPos];var line=token.ln;var column=token.col;pos++;x = [].concat(getSC()).concat([getIdent()]).concat(getSC()).concat([getAttrselector()]).concat(getSC()).concat([checkString(pos)?getString():getIdent()]).concat(getSC());var end=getLastPosition(x, line, column + 1, 1);pos++;return newNode(NodeType.AttribType, x, token.ln, token.col, end);}function checkAttrib2(i){var start=i, l;if(i++ >= tokensLength)return 0;if(l = checkSC(i))i += l;if(l = checkIdent(i))i += l;else return 0;if(l = checkSC(i))i += l;return tokens[i].type === TokenType.RightSquareBracket?i - start:0;}function getAttrib2(){var startPos=pos, x;var token=tokens[startPos];var line=token.ln;var column=token.col;pos++;x = [].concat(getSC()).concat([getIdent()]).concat(getSC());var end=getLastPosition(x, line, column + 1, 1);pos++;return newNode(NodeType.AttribType, x, token.ln, token.col, end);}function checkAttrselector(i){if(i >= tokensLength)return 0;if(tokens[i].type === TokenType.EqualsSign)return 1;if(tokens[i].type === TokenType.VerticalLine && (!tokens[i + 1] || tokens[i + 1].type !== TokenType.EqualsSign))return 1;if(!tokens[i + 1] || tokens[i + 1].type !== TokenType.EqualsSign)return 0;switch(tokens[i].type){case TokenType.Tilde:case TokenType.CircumflexAccent:case TokenType.DollarSign:case TokenType.Asterisk:case TokenType.VerticalLine:return 2;}return 0;}function getAttrselector(){var startPos=pos, s=tokens[pos++].value;if(tokens[pos] && tokens[pos].type === TokenType.EqualsSign)s += tokens[pos++].value;var token=tokens[startPos];return newNode(NodeType.AttrselectorType, s, token.ln, token.col);}function checkAtrule(i){var l;if(i >= tokensLength)return 0;if(tokens[i].atrule_l !== undefined)return tokens[i].atrule_l;if(l = checkAtruler(i))tokens[i].atrule_type = 1;else if(l = checkAtruleb(i))tokens[i].atrule_type = 2;else if(l = checkAtrules(i))tokens[i].atrule_type = 3;else return 0;tokens[i].atrule_l = l;return l;}function getAtrule(){switch(tokens[pos].atrule_type){case 1:return getAtruler();case 2:return getAtruleb();case 3:return getAtrules();}}function checkAtruleb(i){var start=i, l;if(i >= tokensLength)return 0;if(l = checkAtkeyword(i))i += l;else return 0;if(l = checkTsets(i))i += l;if(l = checkBlock(i))i += l;else return 0;return i - start;}function getAtruleb(){var startPos=pos, x;x = [getAtkeyword()].concat(getTsets()).concat([getBlock()]);var token=tokens[startPos];return newNode(NodeType.AtrulebType, x, token.ln, token.col);}function checkAtruler(i){var start=i, l;if(i >= tokensLength)return 0;if(l = checkAtkeyword(i))i += l;else return 0;if(l = checkAtrulerq(i))i += l;if(i < tokensLength && tokens[i].type === TokenType.LeftCurlyBracket)i++;else return 0;if(l = checkAtrulers(i))i += l;if(i < tokensLength && tokens[i].type === TokenType.RightCurlyBracket)i++;else return 0;return i - start;}function getAtruler(){var startPos=pos, x;x = [getAtkeyword(), getAtrulerq()];x.push(getAtrulers());var token=tokens[startPos];return newNode(NodeType.AtrulerType, x, token.ln, token.col);}function checkAtrulerq(i){return checkTsets(i);}function getAtrulerq(){var startPos=pos, x;x = getTsets();var token=tokens[startPos];return newNode(NodeType.AtrulerqType, x, token.ln, token.col);}function checkAtrulers(i){var start=i, l;if(i >= tokensLength)return 0;if(l = checkSC(i))i += l;while(l = checkRuleset(i) || checkAtrule(i) || checkSC(i)) {i += l;}tokens[i].atrulers_end = 1;if(l = checkSC(i))i += l;return i - start;}function getAtrulers(){var startPos=pos, x;var token=tokens[startPos];var line=token.ln;var column=token.col;pos++;x = getSC();while(!tokens[pos].atrulers_end) {if(checkSC(pos))x = x.concat(getSC());else if(checkAtrule(pos))x.push(getAtrule());else if(checkRuleset(pos))x.push(getRuleset());}x = x.concat(getSC());var end=getLastPosition(x, line, column, 1);pos++;return newNode(NodeType.AtrulersType, x, token.ln, token.col, end);}function checkAtrules(i){var start=i, l;if(i >= tokensLength)return 0;if(l = checkAtkeyword(i))i += l;else return 0;if(l = checkTsets(i))i += l;return i - start;}function getAtrules(){var startPos=pos, x;x = [getAtkeyword()].concat(getTsets());var token=tokens[startPos];return newNode(NodeType.AtrulesType, x, token.ln, token.col);}function checkBlock(i){return i < tokensLength && tokens[i].type === TokenType.LeftCurlyBracket?tokens[i].right - i + 1:0;}function getBlock(){var startPos=pos, end=tokens[pos].right, x=[];var token=tokens[startPos];var line=token.ln;var column=token.col;pos++;while(pos < end) {if(checkBlockdecl(pos))x = x.concat(getBlockdecl());else throwError();}var end_=getLastPosition(x, line, column, 1);pos = end + 1;return newNode(NodeType.BlockType, x, token.ln, token.col, end_);}function checkBlockdecl(i){var l;if(i >= tokensLength)return 0;if(l = checkBlockdecl1(i))tokens[i].bd_type = 1;else if(l = checkBlockdecl2(i))tokens[i].bd_type = 2;else if(l = checkBlockdecl3(i))tokens[i].bd_type = 3;else if(l = checkBlockdecl4(i))tokens[i].bd_type = 4;else return 0;return l;}function getBlockdecl(){switch(tokens[pos].bd_type){case 1:return getBlockdecl1();case 2:return getBlockdecl2();case 3:return getBlockdecl3();case 4:return getBlockdecl4();}}function checkBlockdecl1(i){var start=i, l;if(l = checkSC(i))i += l;if(l = checkConditionalStatement(i))tokens[i].bd_kind = 1;else if(l = checkInclude(i))tokens[i].bd_kind = 2;else if(l = checkExtend(i))tokens[i].bd_kind = 4;else if(l = checkLoop(i))tokens[i].bd_kind = 3;else if(l = checkAtrule(i))tokens[i].bd_kind = 6;else if(l = checkRuleset(i))tokens[i].bd_kind = 7;else if(l = checkDeclaration(i))tokens[i].bd_kind = 5;else return 0;i += l;if(i < tokensLength && (l = checkDeclDelim(i)))i += l;else return 0;if(l = checkSC(i))i += l;return i - start;}function getBlockdecl1(){var sc=getSC(), x;switch(tokens[pos].bd_kind){case 1:x = getConditionalStatement();break;case 2:x = getInclude();break;case 3:x = getLoop();break;case 4:x = getExtend();break;case 5:x = getDeclaration();break;case 6:x = getAtrule();break;case 7:x = getRuleset();break;}return sc.concat([x]).concat([getDeclDelim()]).concat(getSC());}function checkBlockdecl2(i){var start=i, l;if(l = checkSC(i))i += l;if(l = checkConditionalStatement(i))tokens[i].bd_kind = 1;else if(l = checkInclude(i))tokens[i].bd_kind = 2;else if(l = checkExtend(i))tokens[i].bd_kind = 4;else if(l = checkLoop(i))tokens[i].bd_kind = 3;else if(l = checkAtrule(i))tokens[i].bd_kind = 6;else if(l = checkRuleset(i))tokens[i].bd_kind = 7;else if(l = checkDeclaration(i))tokens[i].bd_kind = 5;else return 0;i += l;if(l = checkSC(i))i += l;return i - start;}function getBlockdecl2(){var sc=getSC(), x;switch(tokens[pos].bd_kind){case 1:x = getConditionalStatement();break;case 2:x = getInclude();break;case 3:x = getLoop();break;case 4:x = getExtend();break;case 5:x = getDeclaration();break;case 6:x = getAtrule();break;case 7:x = getRuleset();break;}return sc.concat([x]).concat(getSC());}function checkBlockdecl3(i){var start=i, l;if(l = checkSC(i))i += l;if(l = checkDeclDelim(i))i += l;else return 0;if(l = checkSC(i))i += l;return i - start;}function getBlockdecl3(){return getSC().concat([getDeclDelim()]).concat(getSC());}function checkBlockdecl4(i){return checkSC(i);}function getBlockdecl4(){return getSC();}function checkBrackets(i){if(i >= tokensLength || tokens[i].type !== TokenType.LeftSquareBracket)return 0;return tokens[i].right - i + 1;}function getBrackets(){var startPos=pos;var token=tokens[startPos];var line=token.ln;var column=token.col;pos++;var tsets=getTsets();var end=getLastPosition(tsets, line, column, 1);pos++;return newNode(NodeType.BracketsType, tsets, token.ln, token.col, end);}function checkClass(i){var start=i, l;if(i >= tokensLength)return 0;if(tokens[i].class_l)return tokens[i].class_l;if(tokens[i++].type !== TokenType.FullStop)return 0;while(i < tokensLength) {if(l = checkInterpolation(i) || checkIdent(i))i += l;else break;}return i - start;}function getClass(){var startPos=pos, x=[];pos++;while(pos < tokensLength) {if(checkInterpolation(pos))x.push(getInterpolation());else if(checkIdent(pos))x.push(getIdent());else break;}var token=tokens[startPos];return newNode(NodeType.ClassType, x, token.ln, token.col);}function checkCombinator(i){if(i >= tokensLength)return 0;switch(tokens[i].type){case TokenType.PlusSign:case TokenType.GreaterThanSign:case TokenType.Tilde:return 1;}return 0;}function getCombinator(){var startPos=pos, x;x = tokens[pos++].value;var token=tokens[startPos];return newNode(NodeType.CombinatorType, x, token.ln, token.col);}function checkCommentML(i){return i < tokensLength && tokens[i].type === TokenType.CommentML?1:0;}function getCommentML(){var startPos=pos, s=tokens[pos].value.substring(2), l=s.length;var token=tokens[startPos];var line=token.ln;var column=token.col;if(s.charAt(l - 2) === '*' && s.charAt(l - 1) === '/')s = s.substring(0, l - 2);var end=getLastPosition(s, line, column, 2);if(end[0] === line)end[1] += 2;pos++;return newNode(NodeType.CommentMLType, s, token.ln, token.col, end);}function checkCommentSL(i){return i < tokensLength && tokens[i].type === TokenType.CommentSL?1:0;}function getCommentSL(){var startPos=pos, x;var token=tokens[startPos];var line=token.ln;var column=token.col;x = tokens[pos++].value.substring(2);var end=getLastPosition(x, line, column + 2);return newNode(NodeType.CommentSLType, x, token.ln, token.col, end);}function checkCondition(i){var start=i, l, _i, s;if(i >= tokensLength)return 0;if(l = checkAtkeyword(i))i += l;else return 0;if(['if', 'else'].indexOf(tokens[start + 1].value) < 0)return 0;while(i < tokensLength) {if(l = checkBlock(i))break;s = checkSC(i);_i = i + s;if(l = _checkCondition(_i))i += l + s;else break;}return i - start;}function _checkCondition(i){return checkVariable(i) || checkNumber(i) || checkIdent(i) || checkOperator(i) || checkCombinator(i) || checkString(i);}function getCondition(){var startPos=pos, x=[];var s;var _pos;x.push(getAtkeyword());while(pos < tokensLength) {if(checkBlock(pos))break;s = checkSC(pos);_pos = pos + s;if(!_checkCondition(_pos))break;if(s)x = x.concat(getSC());x.push(_getCondition());}var token=tokens[startPos];return newNode(NodeType.ConditionType, x, token.ln, token.col);}function _getCondition(){if(checkVariable(pos))return getVariable();if(checkNumber(pos))return getNumber();if(checkIdent(pos))return getIdent();if(checkOperator(pos))return getOperator();if(checkCombinator(pos))return getCombinator();if(checkString(pos))return getString();}function checkConditionalStatement(i){var start=i, l;if(i >= tokensLength)return 0;if(l = checkCondition(i))i += l;else return 0;if(l = checkSC(i))i += l;if(l = checkBlock(i))i += l;else return 0;return i - start;}function getConditionalStatement(){var startPos=pos, x=[];x.push(getCondition());x = x.concat(getSC());x.push(getBlock());var token=tokens[startPos];return newNode(NodeType.ConditionalStatementType, x, token.ln, token.col);}function checkDeclaration(i){var start=i, l;if(i >= tokensLength)return 0;if(l = checkProperty(i))i += l;else return 0;if(l = checkSC(i))i += l;if(l = checkPropertyDelim(i))i++;else return 0;if(l = checkSC(i))i += l;if(l = checkValue(i))i += l;else return 0;return i - start;}function getDeclaration(){var startPos=pos, x=[];x.push(getProperty());x = x.concat(getSC());x.push(getPropertyDelim());x = x.concat(getSC());x.push(getValue());var token=tokens[startPos];return newNode(NodeType.DeclarationType, x, token.ln, token.col);}function checkDeclDelim(i){return i < tokensLength && tokens[i].type === TokenType.Semicolon?1:0;}function getDeclDelim(){var startPos=pos++;var token=tokens[startPos];return newNode(NodeType.DeclDelimType, ';', token.ln, token.col);}function checkDeepSelector(i){if(tokens[i + 2] && tokens[i].value + tokens[i + 1].value + tokens[i + 2].value === '/deep/'){return 3;}}function getDeepSelector(){var _pos=pos++;var ident=getIdent();ident.content = '/deep/';ident.start.column -= 1;ident.end.column += 4;pos = _pos + 3;return ident;}function checkDefault(i){var start=i, l;if(i >= tokensLength || tokens[i++].type !== TokenType.ExclamationMark)return 0;if(l = checkSC(i))i += l;return tokens[i].value === 'default'?i - start + 1:0;}function getDefault(){var startPos=pos, sc;var token=tokens[startPos];var line=token.ln;var column=token.col;pos++;sc = getSC();var end=getLastPosition(sc, line, column, 7);pos++;var x=sc.length?sc:[];return newNode(NodeType.DefaultType, x, token.ln, token.col, end);}function checkDelim(i){return i < tokensLength && tokens[i].type === TokenType.Comma?1:0;}function getDelim(){var startPos=pos;pos++;var token=tokens[startPos];return newNode(NodeType.DelimType, ',', token.ln, token.col);}function checkDimension(i){var ln=checkNumber(i), li;if(i >= tokensLength || !ln || i + ln >= tokensLength)return 0;return (li = checkNmName2(i + ln))?ln + li:0;}function getDimension(){var startPos=pos, x=[getNumber()], token=tokens[pos], ident=newNode(NodeType.IdentType, getNmName2(), token.ln, token.col);x.push(ident);token = tokens[startPos];return newNode(NodeType.DimensionType, x, token.ln, token.col);}function checkExpression(i){var start=i;if(i >= tokensLength || tokens[i++].value !== 'expression' || i >= tokensLength || tokens[i].type !== TokenType.LeftParenthesis)return 0;return tokens[i].right - start + 1;}function getExpression(){var startPos=pos;var e;var token=tokens[startPos];var line=token.ln;var column=token.col;pos++;e = joinValues(pos + 1, tokens[pos].right - 1);var end=getLastPosition(e, line, column, 1);if(end[0] === line)end[1] += 11;pos = tokens[pos].right + 1;return newNode(NodeType.ExpressionType, e, token.ln, token.col, end);}function checkExtend(i){var start=i;var l;if(i >= tokensLength)return 0;if(l = checkAtkeyword(i))i += l;else return 0;if(tokens[start + 1].value !== 'extend')return 0;if(l = checkSC(i))i += l;else return 0;if(l = checkIncludeSelector(i))i += l;else return 0;return i - start;}function getExtend(){var startPos=pos, x=[];x.push(getAtkeyword());x = x.concat(getSC());x.push(getIncludeSelector());var token=tokens[startPos];return newNode(NodeType.ExtendType, x, token.ln, token.col);}function checkFunction(i){var start=i, l;if(i >= tokensLength)return 0;if(l = checkIdent(i))i += l;else return 0;return i < tokensLength && tokens[i].type === TokenType.LeftParenthesis?tokens[i].right - start + 1:0;}function getFunction(){var startPos=pos, ident=getIdent(), x=[ident], body;body = ident.content === 'not'?getNotArguments():getArguments();x.push(body);var token=tokens[startPos];return newNode(NodeType.FunctionType, x, token.ln, token.col);}function getArguments(){var startPos=pos, x=[], body;var token=tokens[startPos];var line=token.ln;var column=token.col;pos++;while(pos < tokensLength && tokens[pos].type !== TokenType.RightParenthesis) {if(checkDeclaration(pos))x.push(getDeclaration());else if(checkArgument(pos)){body = getArgument();if(typeof body.content === 'string')x.push(body);else x = x.concat(body);}else if(checkClass(pos))x.push(getClass());else throwError();}var end=getLastPosition(x, line, column, 1);pos++;return newNode(NodeType.ArgumentsType, x, token.ln, token.col, end);}function getNotArguments(){var startPos=pos, x=[];var token=tokens[startPos];var line=token.ln;var column=token.col;pos++;while(pos < tokensLength && tokens[pos].type !== TokenType.RightParenthesis) {if(checkSimpleSelector(pos))x.push(getSimpleSelector());else throwError();}var end=getLastPosition(x, line, column, 1);pos++;return newNode(NodeType.ArgumentsType, x, token.ln, token.col, end);}function checkIdent(i){var start=i, interpolations=[], wasIdent, wasInt=false, l;if(i >= tokensLength)return 0;if(tokens[i].type === TokenType.LowLine)return checkIdentLowLine(i);if(tokens[i].type === TokenType.HyphenMinus && tokens[i + 1].type === TokenType.DecimalNumber)return 0;if(l = _checkIdent(i))i += l;else return 0;wasIdent = tokens[i - 1].type === TokenType.Identifier;while(i < tokensLength) {l = _checkIdent(i);if(!l)break;wasIdent = true;i += l;}if(!wasIdent && !wasInt && tokens[start].type !== TokenType.Asterisk)return 0;tokens[start].ident_last = i - 1;if(interpolations.length)tokens[start].interpolations = interpolations;return i - start;}function _checkIdent(i){if(tokens[i].type === TokenType.HyphenMinus || tokens[i].type === TokenType.Identifier || tokens[i].type === TokenType.DollarSign || tokens[i].type === TokenType.LowLine || tokens[i].type === TokenType.DecimalNumber || tokens[i].type === TokenType.Asterisk)return 1;return 0;}function checkIdentLowLine(i){var start=i;if(i++ >= tokensLength)return 0;for(; i < tokensLength; i++) {if(tokens[i].type !== TokenType.HyphenMinus && tokens[i].type !== TokenType.DecimalNumber && tokens[i].type !== TokenType.LowLine && tokens[i].type !== TokenType.Identifier)break;}tokens[start].ident_last = i - 1;return i - start;}function getIdent(){var startPos=pos, x=joinValues(pos, tokens[pos].ident_last);pos = tokens[pos].ident_last + 1;var token=tokens[startPos];return newNode(NodeType.IdentType, x, token.ln, token.col);}function checkImportant(i){var start=i, l;if(i >= tokensLength || tokens[i++].type !== TokenType.ExclamationMark)return 0;if(l = checkSC(i))i += l;return tokens[i].value === 'important'?i - start + 1:0;}function getImportant(){var startPos=pos, x=[];var token=tokens[startPos];var line=token.ln;var column=token.col;pos++;x = x.concat(getSC());var end=getLastPosition(x, line, column, 9);pos++;return newNode(NodeType.ImportantType, x, token.ln, token.col, end);}function checkInclude(i){var l;if(i >= tokensLength)return 0;if(l = checkInclude1(i))tokens[i].include_type = 1;else if(l = checkInclude2(i))tokens[i].include_type = 2;else if(l = checkInclude3(i))tokens[i].include_type = 3;else if(l = checkInclude4(i))tokens[i].include_type = 4;return l;}function getInclude(){switch(tokens[pos].include_type){case 1:return getInclude1();case 2:return getInclude2();case 3:return getInclude3();case 4:return getInclude4();}}function checkInclude1(i){var start=i, l;if(l = checkAtkeyword(i))i += l;else return 0;if(tokens[start + 1].value !== 'include')return 0;if(l = checkSC(i))i += l;else return 0;if(l = checkIncludeSelector(i))i += l;else return 0;if(l = checkSC(i))i += l;if(l = checkArguments(i))i += l;else return 0;if(l = checkSC(i))i += l;if(l = checkBlock(i))i += l;else return 0;return i - start;}function getInclude1(){var startPos=pos, x=[];x.push(getAtkeyword());x = x.concat(getSC());x.push(getIncludeSelector());x = x.concat(getSC());x.push(getArguments());x = x.concat(getSC());x.push(getBlock());var token=tokens[startPos];return newNode(NodeType.IncludeType, x, token.ln, token.col);}function checkInclude2(i){var start=i, l;if(l = checkAtkeyword(i))i += l;else return 0;if(tokens[start + 1].value !== 'include')return 0;if(l = checkSC(i))i += l;else return 0;if(l = checkIncludeSelector(i))i += l;else return 0;if(l = checkSC(i))i += l;if(l = checkArguments(i))i += l;else return 0;return i - start;}function getInclude2(){var startPos=pos, x=[];x.push(getAtkeyword());x = x.concat(getSC());x.push(getIncludeSelector());x = x.concat(getSC());x.push(getArguments());var token=tokens[startPos];return newNode(NodeType.IncludeType, x, token.ln, token.col);}function checkInclude3(i){var start=i, l;if(l = checkAtkeyword(i))i += l;else return 0;if(tokens[start + 1].value !== 'include')return 0;if(l = checkSC(i))i += l;else return 0;if(l = checkIncludeSelector(i))i += l;else return 0;if(l = checkSC(i))i += l;if(l = checkBlock(i))i += l;else return 0;return i - start;}function getInclude3(){var startPos=pos, x=[];x.push(getAtkeyword());x = x.concat(getSC());x.push(getIncludeSelector());x = x.concat(getSC());x.push(getBlock());var token=tokens[startPos];return newNode(NodeType.IncludeType, x, token.ln, token.col);}function checkInclude4(i){var start=i, l;if(l = checkAtkeyword(i))i += l;else return 0;if(tokens[start + 1].value !== 'include')return 0;if(l = checkSC(i))i += l;else return 0;if(l = checkIncludeSelector(i))i += l;else return 0;return i - start;}function getInclude4(){var startPos=pos, x=[];x.push(getAtkeyword());x = x.concat(getSC());x.push(getIncludeSelector());var token=tokens[startPos];return newNode(NodeType.IncludeType, x, token.ln, token.col);}function checkIncludeSelector(i){var start=i, l;while(i < tokensLength) {if(l = checkIncludeSelector_(i))i += l;else break;}return i - start;}function getIncludeSelector(){var startPos=pos, x=[], t;while(pos < tokensLength && checkIncludeSelector_(pos)) {t = getIncludeSelector_();if(typeof t.content === 'string')x.push(t);else x = x.concat(t);}var token=tokens[startPos];return newNode(NodeType.SimpleselectorType, x, token.ln, token.col);}function checkIncludeSelector_(i){return checkNthselector(i) || checkAttrib(i) || checkPseudo(i) || checkShash(i) || checkPlaceholder(i) || checkIdent(i) || checkClass(i) || checkInterpolation(i);}function getIncludeSelector_(){if(checkNthselector(pos))return getNthselector();else if(checkAttrib(pos))return getAttrib();else if(checkPseudo(pos))return getPseudo();else if(checkShash(pos))return getShash();else if(checkPlaceholder(pos))return getPlaceholder();else if(checkIdent(pos))return getIdent();else if(checkClass(pos))return getClass();else if(checkInterpolation(pos))return getInterpolation();}function checkInterpolation(i){var start=i, l;if(i >= tokensLength)return 0;if(tokens[i].type !== TokenType.NumberSign || !tokens[i + 1] || tokens[i + 1].type !== TokenType.LeftCurlyBracket)return 0;i += 2;if(l = checkVariable(i))tokens[i].interpolation_child = 1;else if(l = checkFunction(i))tokens[i].interpolation_child = 2;else return 0;i += l;return tokens[i].type === TokenType.RightCurlyBracket?i - start + 1:0;}function getInterpolation(){var startPos=pos, x=[];var token=tokens[startPos];var line=token.ln;var column=token.col;pos += 2;var childType=tokens[pos].interpolation_child;if(childType === 1)x.push(getVariable());else if(childType === 2)x.push(getFunction());var end=getLastPosition(x, line, column, 1);pos++;return newNode(NodeType.InterpolationType, x, token.ln, token.col, end);}function checkLoop(i){var start=i, l;if(i >= tokensLength)return 0;if(l = checkAtkeyword(i))i += l;else return 0;if(['for', 'each', 'while'].indexOf(tokens[start + 1].value) < 0)return 0;while(i < tokensLength) {if(l = checkBlock(i)){i += l;break;}else if(l = checkVariable(i) || checkNumber(i) || checkIdent(i) || checkSC(i) || checkOperator(i) || checkCombinator(i) || checkString(i))i += l;else return 0;}return i - start;}function getLoop(){var startPos=pos, x=[];x.push(getAtkeyword());while(pos < tokensLength) {if(checkBlock(pos)){x.push(getBlock());break;}else if(checkVariable(pos))x.push(getVariable());else if(checkNumber(pos))x.push(getNumber());else if(checkIdent(pos))x.push(getIdent());else if(checkOperator(pos))x.push(getOperator());else if(checkCombinator(pos))x.push(getCombinator());else if(checkSC(pos))x = x.concat(getSC());else if(checkString(pos))x.push(getString());}var token=tokens[startPos];return newNode(NodeType.LoopType, x, token.ln, token.col);}function checkMixin(i){var start=i, l;if(i >= tokensLength)return 0;if((l = checkAtkeyword(i)) && tokens[i + 1].value === 'mixin')i += l;else return 0;if(l = checkSC(i))i += l;if(l = checkIdent(i))i += l;else return 0;if(l = checkSC(i))i += l;if(l = checkArguments(i))i += l;if(l = checkSC(i))i += l;if(l = checkBlock(i))i += l;else return 0;return i - start;}function getMixin(){var startPos=pos, x=[getAtkeyword()];x = x.concat(getSC());if(checkIdent(pos))x.push(getIdent());x = x.concat(getSC());if(checkArguments(pos))x.push(getArguments());x = x.concat(getSC());if(checkBlock(pos))x.push(getBlock());var token=tokens[startPos];return newNode(NodeType.MixinType, x, token.ln, token.col);}function checkNamespace(i){return i < tokensLength && tokens[i].type === TokenType.VerticalLine?1:0;}function getNamespace(){var startPos=pos;pos++;var token=tokens[startPos];return newNode(NodeType.NamespaceType, '|', token.ln, token.col);}function checkNmName(i){var start=i;if(i >= tokensLength)return 0;if(tokens[i].type === TokenType.HyphenMinus || tokens[i].type === TokenType.LowLine || tokens[i].type === TokenType.Identifier || tokens[i].type === TokenType.DecimalNumber)i++;else return 0;for(; i < tokensLength; i++) {if(tokens[i].type !== TokenType.HyphenMinus && tokens[i].type !== TokenType.LowLine && tokens[i].type !== TokenType.Identifier && tokens[i].type !== TokenType.DecimalNumber)break;}tokens[start].nm_name_last = i - 1;return i - start;}function getNmName(){var s=joinValues(pos, tokens[pos].nm_name_last);pos = tokens[pos].nm_name_last + 1;return s;}function checkNmName2(i){if(tokens[i].type === TokenType.Identifier)return 1;else if(tokens[i].type !== TokenType.DecimalNumber)return 0;i++;return i < tokensLength && tokens[i].type === TokenType.Identifier?2:1;}function getNmName2(){var s=tokens[pos].value;if(tokens[pos++].type === TokenType.DecimalNumber && pos < tokensLength && tokens[pos].type === TokenType.Identifier)s += tokens[pos++].value;return s;}function checkNth(i){if(i >= tokensLength)return 0;return checkNth1(i) || checkNth2(i);}function checkNth1(i){var start=i;for(; i < tokensLength; i++) {if(tokens[i].type !== TokenType.DecimalNumber && tokens[i].value !== 'n')break;}if(i !== start)tokens[start].nth_last = i - 1;return i - start;}function getNth(){var startPos=pos, x;if(tokens[pos].nth_last){x = joinValues(pos, tokens[pos].nth_last);pos = tokens[pos].nth_last + 1;}else {x = tokens[pos++].value;}var token=tokens[startPos];return newNode(NodeType.NthType, x, token.ln, token.col);}function checkNth2(i){return tokens[i].value === 'even' || tokens[i].value === 'odd'?1:0;}function checkNthf(i){var start=i, l=0;if(tokens[i++].type !== TokenType.Colon)return 0;l++;if(tokens[i++].value !== 'nth' || tokens[i++].value !== '-')return 0;l += 2;if('child' === tokens[i].value){l += 1;}else if('last-child' === tokens[i].value + tokens[i + 1].value + tokens[i + 2].value){l += 3;}else if('of-type' === tokens[i].value + tokens[i + 1].value + tokens[i + 2].value){l += 3;}else if('last-of-type' === tokens[i].value + tokens[i + 1].value + tokens[i + 2].value + tokens[i + 3].value + tokens[i + 4].value){l += 5;}else return 0;tokens[start + 1].nthf_last = start + l - 1;return l;}function getNthf(){pos++;var s=joinValues(pos, tokens[pos].nthf_last);pos = tokens[pos].nthf_last + 1;return s;}function checkNthselector(i){var start=i, l;if(i >= tokensLength)return 0;if(l = checkNthf(i))i += l;else return 0;if(tokens[i].type !== TokenType.LeftParenthesis || !tokens[i].right)return 0;l++;var rp=tokens[i++].right;while(i < rp) {if(l = checkSC(i) || checkUnary(i) || checkInterpolation(i) || checkNth(i))i += l;else return 0;}return rp - start + 1;}function getNthselector(){var token=tokens[pos];var nthf=newNode(NodeType.IdentType, getNthf(), token.ln, token.col);var x=[];var line=token.ln;var column=token.col;x.push(nthf);pos++;while(tokens[pos].type !== TokenType.RightParenthesis) {if(checkSC(pos))x = x.concat(getSC());else if(checkUnary(pos))x.push(getUnary());else if(checkInterpolation(pos))x.push(getInterpolation());else if(checkNth(pos))x.push(getNth());}var end=getLastPosition(x, line, column, 1);pos++;return newNode(NodeType.NthselectorType, x, token.ln, token.col, end);}function checkNumber(i){if(i >= tokensLength)return 0;if(tokens[i].number_l)return tokens[i].number_l;if(i < tokensLength && tokens[i].type === TokenType.DecimalNumber && (!tokens[i + 1] || tokens[i + 1] && tokens[i + 1].type !== TokenType.FullStop))return (tokens[i].number_l = 1, tokens[i].number_l);if(i < tokensLength && tokens[i].type === TokenType.DecimalNumber && tokens[i + 1] && tokens[i + 1].type === TokenType.FullStop && (!tokens[i + 2] || tokens[i + 2].type !== TokenType.DecimalNumber))return (tokens[i].number_l = 2, tokens[i].number_l);if(i < tokensLength && tokens[i].type === TokenType.FullStop && tokens[i + 1].type === TokenType.DecimalNumber)return (tokens[i].number_l = 2, tokens[i].number_l);if(i < tokensLength && tokens[i].type === TokenType.DecimalNumber && tokens[i + 1] && tokens[i + 1].type === TokenType.FullStop && tokens[i + 2] && tokens[i + 2].type === TokenType.DecimalNumber)return (tokens[i].number_l = 3, tokens[i].number_l);return 0;}function getNumber(){var s='', startPos=pos, l=tokens[pos].number_l;for(var j=0; j < l; j++) {s += tokens[pos + j].value;}pos += l;var token=tokens[startPos];return newNode(NodeType.NumberType, s, token.ln, token.col);}function checkOperator(i){if(i >= tokensLength)return 0;switch(tokens[i].type){case TokenType.Solidus:case TokenType.Comma:case TokenType.Colon:case TokenType.EqualsSign:case TokenType.EqualitySign:case TokenType.InequalitySign:case TokenType.LessThanSign:case TokenType.GreaterThanSign:case TokenType.Asterisk:return 1;}return 0;}function getOperator(){var startPos=pos, x=tokens[pos++].value;var token=tokens[startPos];return newNode(NodeType.OperatorType, x, token.ln, token.col);}function checkParentheses(i){if(i >= tokensLength || tokens[i].type !== TokenType.LeftParenthesis)return 0;return tokens[i].right - i + 1;}function getParentheses(){var type=NodeType.ParenthesesType, token=tokens[pos], line=token.ln, column=token.col;pos++;var tsets=getTsets();var end=getLastPosition(tsets, line, column, 1);pos++;return newNode(type, tsets, line, column, end);}function checkParentSelector(i){return i < tokensLength && tokens[i].type === TokenType.Ampersand?1:0;}function getParentSelector(){var startPos=pos;pos++;var token=tokens[startPos];return newNode(NodeType.ParentSelectorType, '&', token.ln, token.col);}function checkPercentage(i){var x;if(i >= tokensLength)return 0;x = checkNumber(i);if(!x || i + x >= tokensLength)return 0;return tokens[i + x].type === TokenType.PercentSign?x + 1:0;}function getPercentage(){var startPos=pos, x=[getNumber()];var token=tokens[startPos];var line=token.ln;var column=token.col;var end=getLastPosition(x, line, column, 1);pos++;return newNode(NodeType.PercentageType, x, token.ln, token.col, end);}function checkPlaceholder(i){var l;if(i >= tokensLength)return 0;if(tokens[i].placeholder_l)return tokens[i].placeholder_l;if(tokens[i].type === TokenType.PercentSign && (l = checkIdent(i + 1))){tokens[i].placeholder_l = l + 1;return l + 1;}else return 0;}function getPlaceholder(){var startPos=pos, x=[];pos++;x.push(getIdent());var token=tokens[startPos];return newNode(NodeType.PlaceholderType, x, token.ln, token.col);}function checkProgid(i){var start=i, l;if(i >= tokensLength)return 0;if(joinValues2(i, 6) === 'progid:DXImageTransform.Microsoft.')i += 6;else return 0;if(l = checkIdent(i))i += l;else return 0;if(l = checkSC(i))i += l;if(tokens[i].type === TokenType.LeftParenthesis){tokens[start].progid_end = tokens[i].right;i = tokens[i].right + 1;}else return 0;return i - start;}function getProgid(){var startPos=pos, progid_end=tokens[pos].progid_end, x=joinValues(pos, progid_end);pos = progid_end + 1;var token=tokens[startPos];return newNode(NodeType.ProgidType, x, token.ln, token.col);}function checkProperty(i){var start=i, l;if(i >= tokensLength)return 0;if(l = checkVariable(i) || checkIdent(i))i += l;else return 0;return i - start;}function getProperty(){var startPos=pos, x=[];x.push(checkVariable(pos)?getVariable():getIdent());var token=tokens[startPos];return newNode(NodeType.PropertyType, x, token.ln, token.col);}function checkPropertyDelim(i){return i < tokensLength && tokens[i].type === TokenType.Colon?1:0;}function getPropertyDelim(){var startPos=pos;pos++;var token=tokens[startPos];return newNode(NodeType.PropertyDelimType, ':', token.ln, token.col);}function checkPseudo(i){return checkPseudoe(i) || checkPseudoc(i);}function getPseudo(){if(checkPseudoe(pos))return getPseudoe();if(checkPseudoc(pos))return getPseudoc();}function checkPseudoe(i){var l;if(i >= tokensLength || tokens[i++].type !== TokenType.Colon || i >= tokensLength || tokens[i++].type !== TokenType.Colon)return 0;return (l = checkInterpolation(i) || checkIdent(i))?l + 2:0;}function getPseudoe(){var startPos=pos, x=[];pos += 2;x.push(checkInterpolation(pos)?getInterpolation():getIdent());var token=tokens[startPos];return newNode(NodeType.PseudoeType, x, token.ln, token.col);}function checkPseudoc(i){var l;if(i >= tokensLength || tokens[i++].type !== TokenType.Colon)return 0;return (l = checkInterpolation(i) || checkFunction(i) || checkIdent(i))?l + 1:0;}function getPseudoc(){var startPos=pos, x=[];pos++;if(checkInterpolation(pos))x.push(getInterpolation());else if(checkFunction(pos))x.push(getFunction());else x.push(getIdent());var token=tokens[startPos];return newNode(NodeType.PseudocType, x, token.ln, token.col);}function checkRuleset(i){var start=i, l;if(i >= tokensLength)return 0;if(tokens[start].ruleset_l)return tokens[start].ruleset_l;while(i < tokensLength) {if(l = checkBlock(i)){i += l;break;}else if(l = checkSelector(i))i += l;else return 0;}tokens[start].ruleset_l = i - start;return i - start;}function getRuleset(){var startPos=pos, x=[];while(pos < tokensLength) {if(checkBlock(pos)){x.push(getBlock());break;}else if(checkSelector(pos))x.push(getSelector());else break;}var token=tokens[startPos];return newNode(NodeType.RulesetType, x, token.ln, token.col);}function checkS(i){return i < tokensLength && tokens[i].ws?tokens[i].ws_last - i + 1:0;}function getS(){var startPos=pos, x=joinValues(pos, tokens[pos].ws_last);pos = tokens[pos].ws_last + 1;var token=tokens[startPos];return newNode(NodeType.SType, x, token.ln, token.col);}function checkSC(i){if(i >= tokensLength)return 0;var l, lsc=0;while(i < tokensLength) {if(!(l = checkS(i)) && !(l = checkCommentML(i)) && !(l = checkCommentSL(i)))break;i += l;lsc += l;}return lsc || 0;}function getSC(){var sc=[];if(pos >= tokensLength)return sc;while(pos < tokensLength) {if(checkS(pos))sc.push(getS());else if(checkCommentML(pos))sc.push(getCommentML());else if(checkCommentSL(pos))sc.push(getCommentSL());else break;}return sc;}function checkSelector(i){var start=i, l;while(i < tokensLength) {if(l = checkSimpleSelector(i) || checkDelim(i))i += l;else break;}if(i !== start)tokens[start].selector_end = i - 1;return i - start;}function getSelector(){var startPos=pos, x=[], selector_end=tokens[pos].selector_end;while(pos <= selector_end) {x.push(checkDelim(pos)?getDelim():getSimpleSelector());}var token=tokens[startPos];return newNode(NodeType.SelectorType, x, token.ln, token.col);}function checkShash(i){var l;if(i >= tokensLength || tokens[i].type !== TokenType.NumberSign)return 0;return (l = checkNmName(i + 1))?l + 1:0;}function getShash(){var startPos=pos, x=[];pos++;var ln=tokens[pos].ln;var col=tokens[pos].col;var ident=newNode(NodeType.IdentType, getNmName(), ln, col);x.push(ident);var token=tokens[startPos];return newNode(NodeType.ShashType, x, token.ln, token.col);}function checkSimpleSelector(i){var start=i, l;while(i < tokensLength) {if(l = checkSimpleSelector1(i))i += l;else break;}return i - start;}function getSimpleSelector(){var startPos=pos, x=[], t;while(pos < tokensLength) {if(!checkSimpleSelector1(pos))break;t = getSimpleSelector1();if(needInfo && typeof t[1] === 'string' || typeof t[0] === 'string')x.push(t);else x = x.concat(t);}var token=tokens[startPos];return newNode(NodeType.SimpleselectorType, x, token.ln, token.col);}function checkSimpleSelector1(i){var l;if(l = checkParentSelector(i))tokens[i].simpleselector1_child = 1;else if(l = checkInterpolation(i))tokens[i].simpleselector1_child = 2;else if(l = checkNthselector(i))tokens[i].simpleselector1_child = 3;else if(l = checkCombinator(i))tokens[i].simpleselector1_child = 4;else if(l = checkAttrib(i))tokens[i].simpleselector1_child = 5;else if(l = checkPseudo(i))tokens[i].simpleselector1_child = 6;else if(l = checkShash(i))tokens[i].simpleselector1_child = 7;else if(l = checkAny(i))tokens[i].simpleselector1_child = 8;else if(l = checkSC(i))tokens[i].simpleselector1_child = 9;else if(l = checkNamespace(i))tokens[i].simpleselector1_child = 10;else if(l = checkDeepSelector(i))tokens[i].simpleselector1_child = 11;return l;}function getSimpleSelector1(){var childType=tokens[pos].simpleselector1_child;if(childType === 1)return getParentSelector();if(childType === 2)return getInterpolation();if(childType === 3)return getNthselector();if(childType === 4)return getCombinator();if(childType === 5)return getAttrib();if(childType === 6)return getPseudo();if(childType === 7)return getShash();if(childType === 8)return getAny();if(childType === 9)return getSC();if(childType === 10)return getNamespace();if(childType === 11)return getDeepSelector();}function checkString(i){return i < tokensLength && (tokens[i].type === TokenType.StringSQ || tokens[i].type === TokenType.StringDQ)?1:0;}function getString(){var startPos=pos, x=tokens[pos++].value;var token=tokens[startPos];return newNode(NodeType.StringType, x, token.ln, token.col);}function checkStylesheet(i){var start=i, l;while(i < tokensLength) {if(l = checkSC(i) || checkDeclaration(i) || checkDeclDelim(i) || checkInclude(i) || checkExtend(i) || checkMixin(i) || checkLoop(i) || checkConditionalStatement(i) || checkAtrule(i) || checkRuleset(i))i += l;else throwError(i);}return i - start;}function getStylesheet(){var startPos=pos, x=[];while(pos < tokensLength) {if(checkSC(pos))x = x.concat(getSC());else if(checkRuleset(pos))x.push(getRuleset());else if(checkInclude(pos))x.push(getInclude());else if(checkExtend(pos))x.push(getExtend());else if(checkMixin(pos))x.push(getMixin());else if(checkLoop(pos))x.push(getLoop());else if(checkConditionalStatement(pos))x.push(getConditionalStatement());else if(checkAtrule(pos))x.push(getAtrule());else if(checkDeclaration(pos))x.push(getDeclaration());else if(checkDeclDelim(pos))x.push(getDeclDelim());else throwError();}var token=tokens[startPos];return newNode(NodeType.StylesheetType, x, token.ln, token.col);}function checkTset(i){return checkVhash(i) || checkAny(i) || checkSC(i) || checkOperator(i) || checkInterpolation(i);}function getTset(){if(checkVhash(pos))return getVhash();else if(checkAny(pos))return getAny();else if(checkSC(pos))return getSC();else if(checkOperator(pos))return getOperator();else if(checkInterpolation(pos))return getInterpolation();}function checkTsets(i){var start=i, l;if(i >= tokensLength)return 0;while(l = checkTset(i)) {i += l;}return i - start;}function getTsets(){var x=[], t;while(t = getTset()) {if(typeof t.content === 'string')x.push(t);else x = x.concat(t);}return x;}function checkUnary(i){return i < tokensLength && (tokens[i].type === TokenType.HyphenMinus || tokens[i].type === TokenType.PlusSign)?1:0;}function getUnary(){var startPos=pos, x=tokens[pos++].value;var token=tokens[startPos];return newNode(NodeType.UnaryType, x, token.ln, token.col);}function checkUri(i){var start=i;if(i >= tokensLength || tokens[i++].value !== 'url' || i >= tokensLength || tokens[i].type !== TokenType.LeftParenthesis)return 0;return tokens[i].right - start + 1;}function getUri(){var startPos=pos, uriExcluding={}, uri, token, l, raw;pos += 2;uriExcluding[TokenType.Space] = 1;uriExcluding[TokenType.Tab] = 1;uriExcluding[TokenType.Newline] = 1;uriExcluding[TokenType.LeftParenthesis] = 1;uriExcluding[TokenType.RightParenthesis] = 1;if(checkUri1(pos)){uri = [].concat(getSC()).concat([getString()]).concat(getSC());}else {uri = [].concat(getSC());l = checkExcluding(uriExcluding, pos);token = tokens[pos];raw = newNode(NodeType.RawType, joinValues(pos, pos + l), token.ln, token.col);uri.push(raw);pos += l + 1;uri = uri.concat(getSC());}token = tokens[startPos];var line=token.ln;var column=token.col;var end=getLastPosition(uri, line, column, 1);pos++;return newNode(NodeType.UriType, uri, token.ln, token.col, end);}function checkUri1(i){var start=i, l;if(i >= tokensLength)return 0;if(l = checkSC(i))i += l;if(tokens[i].type !== TokenType.StringDQ && tokens[i].type !== TokenType.StringSQ)return 0;i++;if(l = checkSC(i))i += l;return i