Skip to content

Commit

Permalink
use Raw consumer for Url
Browse files Browse the repository at this point in the history
  • Loading branch information
lahmatiy committed Jan 31, 2017
1 parent 4b288f6 commit 4660671
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 28 deletions.
13 changes: 3 additions & 10 deletions lib/parser/nodes/Raw.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
var TYPE = require('../../scanner').TYPE;

var WHITESPACE = TYPE.WhiteSpace;
var WHITESPACE = TYPE.Whitespace;
var LEFTPARENTHESIS = TYPE.LeftParenthesis;
var RIGHTPARENTHESIS = TYPE.RightParenthesis;
var LEFTCURLYBRACKET = TYPE.LeftCurlyBracket;
Expand All @@ -24,13 +24,6 @@ module.exports = function Raw(balanced, endTokenType1, endTokenType2) {
popType = stack.pop();
break;

case WHITESPACE:
if (stack.length !== 0) {
continue;
} else {
break scan;
}

case RIGHTPARENTHESIS:
case RIGHTCURLYBRACKET:
case RIGHTSQUAREBRACKET:
Expand Down Expand Up @@ -67,8 +60,8 @@ module.exports = function Raw(balanced, endTokenType1, endTokenType2) {
var type = this.scanner.tokenType;

if (type === WHITESPACE ||
type === LEFTPARENTHESIS ||
type === RIGHTPARENTHESIS) {
type === endTokenType1 ||
type === endTokenType2) {
break;
}
}
Expand Down
20 changes: 2 additions & 18 deletions lib/parser/nodes/Url.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
var TYPE = require('../../scanner').TYPE;

var WHITESPACE = TYPE.Whitespace;
var STRING = TYPE.String;
var LEFTPARENTHESIS = TYPE.LeftParenthesis;
var RIGHTPARENTHESIS = TYPE.RightParenthesis;
var NONBALANCED = false;

// url '(' ws* (string | raw) ws* ')'
module.exports = function Url(scope, start) {
Expand All @@ -15,23 +15,7 @@ module.exports = function Url(scope, start) {
if (this.scanner.tokenType === STRING) {
value = this.String();
} else {
var rawStart = this.scanner.tokenStart;

for (; !this.scanner.eof; this.scanner.next()) {
var type = this.scanner.tokenType;

if (type === WHITESPACE ||
type === LEFTPARENTHESIS ||
type === RIGHTPARENTHESIS) {
break;
}
}

value = {
type: 'Raw',
loc: this.getLocation(rawStart, this.scanner.tokenStart),
value: this.scanner.substrToCursor(rawStart)
};
value = this.Raw(NONBALANCED, LEFTPARENTHESIS, RIGHTPARENTHESIS);
}

this.readSC();
Expand Down

0 comments on commit 4660671

Please sign in to comment.