Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fbc: respect whitespace between operators
- don't join operators separated by whitespace. - Previously, '<' + '=', '<' + '>', '=' + '>', and '-' + '>' were joined together in to one token even if separated by whitespace. - don't skip whitespace between decimal point and digit. Previously, '.' + '0..9' floating point literals were allowed to be separated by whitespace. fbc: refactor lexCurrentChar() - add lexEatWhitespace() specifically for testing for whitespace and skipping over over whitespace. It's only used in a couple of places - remove the skipwhitespc parameter and whitespace skipping checks from lexCurrentChar() and lexGetLookAheadChar() procedures. - instead, call lexEatWhitespace() explicitly when needed to skip whitepspace. Most lexer/parser loops already handle whitespace characters and tokens.
- Loading branch information
Showing
6 changed files
with
91 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#include "fbcunit.bi" | ||
|
||
SUITE( fbc_tests.pp.quote_operators ) | ||
|
||
TEST( direct ) | ||
|
||
'' previously, these operators where joined together | ||
'' because the lexer was skipping the whitespace in | ||
'' between the operators. | ||
|
||
'' do a test for common operators and check | ||
'' that whitespace is preserved for certain cases | ||
|
||
#macro check( arg, compare ) | ||
scope | ||
dim s as string | ||
s = __fb_quote__( arg ) | ||
CU_ASSERT_EQUAL( s, compare ) | ||
end scope | ||
#endmacro | ||
|
||
check(1 = 2, "1 = 2" ) | ||
check(1 + 2, "1 + 2" ) | ||
check(1 - 2, "1 - 2" ) | ||
check(1 / 2, "1 / 2" ) | ||
check(1 \ 2, "1 \ 2" ) | ||
check(1 * 2, "1 * 2" ) | ||
check(1 ^ 2, "1 ^ 2" ) | ||
|
||
check(1 < 2, "1 < 2" ) | ||
check(1 > 2, "1 > 2" ) | ||
|
||
check(1 <> 2, "1 <> 2" ) | ||
check(1 <= 2, "1 <= 2" ) | ||
check(1 >= 2, "1 >= 2" ) | ||
check(1 -> 2, "1 -> 2" ) | ||
|
||
check(1 < > 2, "1 < > 2" ) | ||
check(1 < = 2, "1 < = 2" ) | ||
check(1 > = 2, "1 > = 2" ) | ||
check(1 - > 2, "1 - > 2" ) | ||
|
||
END_TEST | ||
|
||
END_SUITE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters