homunculus
Advanced tools
Comparing version 0.9.2 to 0.9.3
{ | ||
"name": "homunculus", | ||
"version": "0.9.2", | ||
"version": "0.9.3", | ||
"description": "A lexer&parser by Javascript", | ||
@@ -5,0 +5,0 @@ "maintainers": [ |
@@ -337,3 +337,2 @@ var Lexer = require('./Lexer'); | ||
} | ||
this.sel = false; | ||
break; | ||
@@ -346,3 +345,2 @@ case ')': | ||
this.parenthese = false; | ||
this.sel = false; | ||
this.var = false; | ||
@@ -349,0 +347,0 @@ //)之后可能跟单位,比如margin:(1+2)px |
@@ -72,3 +72,3 @@ var Rule = require('./Rule'); | ||
self.addMatch(new RegMatch(Token.HACK, /^![a-z]+/i)); | ||
self.addMatch(new RegMatch(Token.PSEUDO, /^::?(?:-(?:moz|webkit|ms|o)-)?[a-z]+(?:-[a-z]+)*(?:\(:?[\[\]+*\w\-]+\))?/i)); | ||
self.addMatch(new RegMatch(Token.PSEUDO, /^::?(?:-(?:moz|webkit|ms|o)-)?[a-z]+(?:-[a-z]+)*/i)); | ||
['$=', '|=', '*=', '~=', '^=', '>=', '<=', '!=', '==', '++', '--'].forEach(function(o) { | ||
@@ -75,0 +75,0 @@ self.addMatch(new CompleteEqual(Token.SIGN, o)); |
@@ -592,7 +592,3 @@ var IParser = require('../Parser'); | ||
if(s == '[' && this.look.type() != Token.HACK) { | ||
node.add(this.match()); | ||
while(this.look && this.look.content() != ']') { | ||
node.add(this.match([Token.ATTR, Token.SIGN, Token.VARS, Token.NUMBER, Token.UNITS, Token.STRING])); | ||
} | ||
node.add(this.match(']')); | ||
this.bracket1(node); | ||
} | ||
@@ -604,8 +600,7 @@ else { | ||
if(this.look.content() == '[' && this.look.type() != Token.HACK) { | ||
node.add(this.match()); | ||
while(this.look && this.look.content() != ']') { | ||
node.add(this.match([Token.ATTR, Token.SIGN, Token.VARS, Token.NUMBER, Token.UNITS, Token.STRING])); | ||
} | ||
node.add(this.match(']')); | ||
this.bracket1(node); | ||
} | ||
else if(this.look.content() == '(') { | ||
this.bracket2(node); | ||
} | ||
else { | ||
@@ -618,2 +613,21 @@ node.add(this.match([Token.SELECTOR, Token.PSEUDO, Token.SIGN, Token.HACK, Token.VARS])); | ||
}, | ||
bracket1: function(node) { | ||
node.add(this.match()); | ||
while(this.look && [']', '(', ')'].indexOf(this.look.content()) == -1) { | ||
node.add(this.match([Token.ATTR, Token.SIGN, Token.VARS, Token.NUMBER, Token.UNITS, Token.STRING])); | ||
} | ||
node.add(this.match(']')); | ||
}, | ||
bracket2: function(node) { | ||
node.add(this.match()); | ||
while(this.look && this.look.content() != ')') { | ||
if(this.look.content() == '[') { | ||
this.bracket1(node); | ||
} | ||
if(this.look && this.look.content() == ')') { | ||
break; | ||
} | ||
node.add(this.match([Token.SELECTOR, Token.PSEUDO, Token.VARS, Token.NUMBER, Token.UNITS])); | ||
} | ||
}, | ||
block: function(kf) { | ||
@@ -620,0 +634,0 @@ var node = new Node(Node.BLOCK); |
@@ -337,3 +337,2 @@ define(function(require, exports, module) {var Lexer = require('./Lexer'); | ||
} | ||
this.sel = false; | ||
break; | ||
@@ -346,3 +345,2 @@ case ')': | ||
this.parenthese = false; | ||
this.sel = false; | ||
this.var = false; | ||
@@ -349,0 +347,0 @@ //)之后可能跟单位,比如margin:(1+2)px |
@@ -72,3 +72,3 @@ define(function(require, exports, module) {var Rule = require('./Rule'); | ||
self.addMatch(new RegMatch(Token.HACK, /^![a-z]+/i)); | ||
self.addMatch(new RegMatch(Token.PSEUDO, /^::?(?:-(?:moz|webkit|ms|o)-)?[a-z]+(?:-[a-z]+)*(?:\(:?[\[\]+*\w\-]+\))?/i)); | ||
self.addMatch(new RegMatch(Token.PSEUDO, /^::?(?:-(?:moz|webkit|ms|o)-)?[a-z]+(?:-[a-z]+)*/i)); | ||
['$=', '|=', '*=', '~=', '^=', '>=', '<=', '!=', '==', '++', '--'].forEach(function(o) { | ||
@@ -75,0 +75,0 @@ self.addMatch(new CompleteEqual(Token.SIGN, o)); |
@@ -592,7 +592,3 @@ define(function(require, exports, module) {var IParser = require('../Parser'); | ||
if(s == '[' && this.look.type() != Token.HACK) { | ||
node.add(this.match()); | ||
while(this.look && this.look.content() != ']') { | ||
node.add(this.match([Token.ATTR, Token.SIGN, Token.VARS, Token.NUMBER, Token.UNITS, Token.STRING])); | ||
} | ||
node.add(this.match(']')); | ||
this.bracket1(node); | ||
} | ||
@@ -604,8 +600,7 @@ else { | ||
if(this.look.content() == '[' && this.look.type() != Token.HACK) { | ||
node.add(this.match()); | ||
while(this.look && this.look.content() != ']') { | ||
node.add(this.match([Token.ATTR, Token.SIGN, Token.VARS, Token.NUMBER, Token.UNITS, Token.STRING])); | ||
} | ||
node.add(this.match(']')); | ||
this.bracket1(node); | ||
} | ||
else if(this.look.content() == '(') { | ||
this.bracket2(node); | ||
} | ||
else { | ||
@@ -618,2 +613,21 @@ node.add(this.match([Token.SELECTOR, Token.PSEUDO, Token.SIGN, Token.HACK, Token.VARS])); | ||
}, | ||
bracket1: function(node) { | ||
node.add(this.match()); | ||
while(this.look && [']', '(', ')'].indexOf(this.look.content()) == -1) { | ||
node.add(this.match([Token.ATTR, Token.SIGN, Token.VARS, Token.NUMBER, Token.UNITS, Token.STRING])); | ||
} | ||
node.add(this.match(']')); | ||
}, | ||
bracket2: function(node) { | ||
node.add(this.match()); | ||
while(this.look && this.look.content() != ')') { | ||
if(this.look.content() == '[') { | ||
this.bracket1(node); | ||
} | ||
if(this.look && this.look.content() == ')') { | ||
break; | ||
} | ||
node.add(this.match([Token.SELECTOR, Token.PSEUDO, Token.VARS, Token.NUMBER, Token.UNITS])); | ||
} | ||
}, | ||
block: function(kf) { | ||
@@ -620,0 +634,0 @@ var node = new Node(Node.BLOCK); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
1283195
107
19175