Fix lexer issue where select/plural/other/underscores cannot be in identifier names. (#119190)

This commit is contained in:
Tae Hyung Kim
2023-01-25 15:31:38 -08:00
committed by GitHub
parent a45727d813
commit 02a9c151f6
2 changed files with 32 additions and 9 deletions

View File

@@ -226,6 +226,22 @@ void main() {
expect(tokens[5].type, equals(ST.identifier));
});
testWithoutContext('lexer identifier names can contain underscores', () {
final List<Node> tokens = Parser('keywords', 'app_en.arb', '{ test_placeholder } { test_select, select, singular{test} other{hmm} }').lexIntoTokens();
expect(tokens[1].value, equals('test_placeholder'));
expect(tokens[1].type, equals(ST.identifier));
expect(tokens[5].value, equals('test_select'));
expect(tokens[5].type, equals(ST.identifier));
});
testWithoutContext('lexer identifier names can contain the strings select or plural', () {
final List<Node> tokens = Parser('keywords', 'app_en.arb', '{ selectTest } { pluralTest, select, singular{test} other{hmm} }').lexIntoTokens();
expect(tokens[1].value, equals('selectTest'));
expect(tokens[1].type, equals(ST.identifier));
expect(tokens[5].value, equals('pluralTest'));
expect(tokens[5].type, equals(ST.identifier));
});
testWithoutContext('lexer: lexically correct but syntactically incorrect', () {
final List<Node> tokens = Parser(
'syntax',