Skip to content

Commit

Permalink
[tokenizer] simplified logic
Browse files Browse the repository at this point in the history
  • Loading branch information
fb55 committed Mar 31, 2013
1 parent db95f00 commit e4982e1
Showing 1 changed file with 12 additions and 23 deletions.
35 changes: 12 additions & 23 deletions lib/Tokenizer.js
Expand Up @@ -166,14 +166,14 @@ Parser.prototype.write = function(chunk){
* attributes
*/
else if(this._state === BEFORE_ATTRIBUTE_NAME){
if(c === "/"){
this._cbs.onopentagend();
this._cbs.onselfclosingtag();
this._state = AFTER_CLOSING_TAG_NAME;
} else if(c === ">"){
if(c === ">"){
this._state = TEXT;
this._cbs.onopentagend();
this._sectionStart = this._index + 1;
} else if(c === "/"){
this._cbs.onopentagend();
this._cbs.onselfclosingtag();
this._state = AFTER_CLOSING_TAG_NAME;
} else if(!whitespace(c)){
this._state = IN_ATTRIBUTE_NAME;
this._sectionStart = this._index;
Expand All @@ -182,31 +182,20 @@ Parser.prototype.write = function(chunk){
if(c === "="){
this._emitIfToken("attribname");
this._state = BEFORE_ATTRIBUTE_VALUE;
} else if(c === "/"){
this._emitIfToken("attribname");
this._cbs.onopentagend();
this._cbs.onselfclosingtag();
this._state = AFTER_CLOSING_TAG_NAME;
} else if(c === ">"){
this._emitIfToken("attribname");
this._state = TEXT;
this._cbs.onopentagend();
this._sectionStart = this._index + 1;
} else if(whitespace(c)){
this._emitIfToken("attribname");
this._state = AFTER_ATTRIBUTE_NAME;
} else if(c === "/" || c === ">"){
this._emitIfToken("attribname");
this._state = BEFORE_ATTRIBUTE_NAME;
this._index--;
}
} else if(this._state === AFTER_ATTRIBUTE_NAME){
if(c === "="){
this._state = BEFORE_ATTRIBUTE_VALUE;
} else if(c === "/"){
this._cbs.onopentagend();
this._cbs.onselfclosingtag();
this._state = AFTER_CLOSING_TAG_NAME;
} else if(c === ">"){
this._state = TEXT;
this._cbs.onopentagend();
this._sectionStart = this._index + 1;
} else if(c === "/" || c === ">"){
this._state = BEFORE_ATTRIBUTE_NAME;
this._index--;
} else if(!whitespace(c)){
this._state = IN_ATTRIBUTE_NAME;
this._sectionStart = this._index;
Expand Down

0 comments on commit e4982e1

Please sign in to comment.