mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 19:54:57 +08:00
Fix bug with ignoring whitespaces at end of expression
--HG-- branch : dev
This commit is contained in:
@@ -15,6 +15,14 @@ namespace Orchard.Tests.Modules.Scripting {
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ParserShouldIgnoreWhitespaces() {
|
||||
var tree = new Parser(" true \n ").Parse();
|
||||
CheckTree(tree, new object[] {
|
||||
"const", true,
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ParserShouldUnderstandBinaryExpressions() {
|
||||
var tree = new Parser("true+true").Parse();
|
||||
|
@@ -14,10 +14,10 @@ namespace Orchard.Scripting.Compiler {
|
||||
}
|
||||
|
||||
public Token NextToken() {
|
||||
while (true) {
|
||||
if (Eof())
|
||||
return CreateToken(TokenKind.Eof);
|
||||
|
||||
LexAgain:
|
||||
_startTokenIndex = _index;
|
||||
char ch = Character();
|
||||
switch (ch) {
|
||||
@@ -56,11 +56,12 @@ namespace Orchard.Scripting.Compiler {
|
||||
}
|
||||
else if (IsWhitespaceCharacter(ch)) {
|
||||
NextCharacter();
|
||||
goto LexAgain;
|
||||
continue;
|
||||
}
|
||||
|
||||
return CreateToken(TokenKind.Invalid, "Unrecognized character");
|
||||
}
|
||||
}
|
||||
|
||||
private Token LexIdentifierOrKeyword() {
|
||||
_stringBuilder.Clear();
|
||||
|
Reference in New Issue
Block a user