Permalink
Browse files

throw on unexpected token

  • Loading branch information...
1 parent 7cb7ac3 commit 916724a088cef5af53c73a1e0d5d985fb4de5e78 @tj tj committed Mar 4, 2011
Showing with 17 additions and 1 deletion.
  1. +15 −1 lib/lexer.js
  2. +2 −0 lib/parser.js
View
@@ -151,6 +151,19 @@ Lexer.prototype = {
? this.tok('outdent')
: this.tok('eos');
},
+
+ /**
+ * Block comment
+ */
+
+ get blockComment() {
+ var captures;
+ if (captures = /^\//.exec(this.input)) {
+ this.consume(1);
+ var tok = this.tok('block-comment');
+ return tok;
+ }
+ },
/**
* Comment.
@@ -161,7 +174,7 @@ Lexer.prototype = {
if (captures = /^ *\/\/(-)?([^\n]+)/.exec(this.input)) {
this.consume(captures[0].length);
var tok = this.tok('comment', captures[2]);
- tok.buffer = captures[1] !== '-';
+ tok.buffer = '-' != captures[1];
return tok;
}
},
@@ -354,6 +367,7 @@ Lexer.prototype = {
|| this.attrs
|| this.indent
|| this.comment
+ || this.blockComment
|| this.text;
}
};
View
@@ -173,6 +173,8 @@ Parser.prototype = {
this.lexer.defer(this.lexer.tok('tag', 'div'));
this.lexer.defer(tok);
return this.parseExpr();
+ default:
+ throw new Error('unexpected token "' + this.peek.type + '"');
}
},

0 comments on commit 916724a

Please sign in to comment.