Skip to content
Browse files

Be a touch more paranoid with our CharSequence/String comparisons

  • Loading branch information...
1 parent 0f4c602 commit 88a6e9733efd043556af207abe89f95575d33831 Daniel Marcotte committed May 7, 2012
View
75 src/com/dmarcotte/handlebars/parsing/_HbLexer.java
@@ -1,4 +1,4 @@
-/* The following code was generated by JFlex 1.4.3 on 4/22/12 3:38 PM */
+/* The following code was generated by JFlex 1.4.3 on 5/7/12 4:53 PM */
// This is the official Handlebars lexer definition:
// (taken from the following revision: https://github.com/wycats/handlebars.js/blob/932e2970ad29b16d6d6874ad0bfb44b07b4cd765/src/handlebars.l)
@@ -45,13 +45,12 @@
import com.intellij.lexer.FlexLexer;
import com.intellij.psi.tree.IElementType;
import com.intellij.util.containers.Stack;
-import com.dmarcotte.handlebars.parsing.HbTokenTypes;
/**
* This class is a scanner generated by
* <a href="http://www.jflex.de/">JFlex</a> 1.4.3
- * on 4/22/12 3:38 PM from the specification file
+ * on 5/7/12 4:53 PM from the specification file
* <tt>handlebars.flex</tt>
*/
final class _HbLexer implements FlexLexer {
@@ -554,108 +553,108 @@ else if (zzAtEOF) {
zzMarkedPos = zzMarkedPosL;
switch (zzAction < 0 ? zzAction : ZZ_ACTION[zzAction]) {
+ case 19:
+ { // backtrack over any extra stache characters at the end of this string
+ while (yylength() > 2 && yytext().subSequence(yylength() - 3, yylength()).toString().equals("}}}")) {
+ yypushback(1);
+ }
+ yypopState();
+ return HbTokenTypes.COMMENT;
+ }
+ case 22: break;
case 2:
{ return HbTokenTypes.WHITE_SPACE;
}
- case 22: break;
+ case 23: break;
case 21:
// lookahead expression with fixed base length
zzMarkedPos = zzStartRead + 5;
{ return HbTokenTypes.BOOLEAN;
}
- case 23: break;
+ case 24: break;
case 20:
// lookahead expression with fixed base length
zzMarkedPos = zzStartRead + 4;
{ return HbTokenTypes.BOOLEAN;
}
- case 24: break;
+ case 25: break;
case 15:
{ return HbTokenTypes.OPEN_PARTIAL;
}
- case 25: break;
+ case 26: break;
case 4:
{ return HbTokenTypes.SEP;
}
- case 26: break;
+ case 27: break;
case 8:
// lookahead expression with fixed lookahead length
yypushback(1);
{ return HbTokenTypes.ID;
}
- case 27: break;
+ case 28: break;
case 10:
// lookahead expression with fixed base length
zzMarkedPos = zzStartRead + 1;
{ return HbTokenTypes.ID;
}
- case 28: break;
+ case 29: break;
case 11:
{ return HbTokenTypes.ID;
}
- case 29: break;
+ case 30: break;
case 7:
{ return HbTokenTypes.OPEN;
}
- case 30: break;
+ case 31: break;
case 17:
{ return HbTokenTypes.OPEN_ENDBLOCK;
}
- case 31: break;
+ case 32: break;
case 18:
{ return HbTokenTypes.OPEN_INVERSE;
}
- case 32: break;
+ case 33: break;
+ case 6:
+ { // backtrack over any stache characters at the end of this string
+ while (yylength() > 0 && yytext().subSequence(yylength() - 1, yylength()).toString().equals("{")) {
+ yypushback(1);
+ }
+ yypushState(mu); if (!yytext().toString().equals("")) return HbTokenTypes.CONTENT;
+ }
+ case 34: break;
case 12:
{ return HbTokenTypes.STRING;
}
- case 33: break;
+ case 35: break;
case 16:
{ return HbTokenTypes.OPEN_BLOCK;
}
- case 34: break;
- case 19:
- { // backtrack over any extra stache characters at the end of this string
- while (yylength() > 2 && yytext().subSequence(yylength() - 3, yylength()).equals("}}}")) {
- yypushback(1);
- }
- yypopState();
- return HbTokenTypes.COMMENT;
- }
- case 35: break;
+ case 36: break;
case 1:
{ return HbTokenTypes.CONTENT;
}
- case 36: break;
+ case 37: break;
case 5:
{ return HbTokenTypes.EQUALS;
}
- case 37: break;
+ case 38: break;
case 14:
{ return HbTokenTypes.OPEN_UNESCAPED;
}
- case 38: break;
+ case 39: break;
case 9:
{ yypopState(); return HbTokenTypes.CLOSE;
}
- case 39: break;
+ case 40: break;
case 3:
{ return HbTokenTypes.INVALID;
}
- case 40: break;
+ case 41: break;
case 13:
// lookahead expression with fixed lookahead length
yypushback(1);
{ return HbTokenTypes.INTEGER;
}
- case 41: break;
- case 6:
- { // backtrack over any stache characters at the end of this string
- while (yylength() > 0 && yytext().subSequence(yylength() - 1, yylength()).equals("{")) {
- yypushback(1);
- }
- yypushState(mu); if (!yytext().toString().equals("")) return HbTokenTypes.CONTENT;
- }
case 42: break;
default:
if (zzInput == YYEOF && zzStartRead == zzCurrentPos) {
View
4 src/com/dmarcotte/handlebars/parsing/handlebars.flex
@@ -87,7 +87,7 @@ WhiteSpace = {LineTerminator} | [ \t\f]
// any trailing "{" characters we've picked up
~"{{" {
// backtrack over any stache characters at the end of this string
- while (yylength() > 0 && yytext().subSequence(yylength() - 1, yylength()).equals("{")) {
+ while (yylength() > 0 && yytext().subSequence(yylength() - 1, yylength()).toString().equals("{")) {
yypushback(1);
}
yypushState(mu); if (!yytext().toString().equals("")) return HbTokenTypes.CONTENT;
@@ -109,7 +109,7 @@ WhiteSpace = {LineTerminator} | [ \t\f]
// TODO handlebars.l monkeys with the buffer and changes state to INITAL. Why? This seems to capture the comments...
"{{!"~"}}" {
// backtrack over any extra stache characters at the end of this string
- while (yylength() > 2 && yytext().subSequence(yylength() - 3, yylength()).equals("}}}")) {
+ while (yylength() > 2 && yytext().subSequence(yylength() - 3, yylength()).toString().equals("}}}")) {
yypushback(1);
}
yypopState();

0 comments on commit 88a6e97

Please sign in to comment.
Something went wrong with that request. Please try again.