Skip to content

Commit 999c4b4

Browse files
committed
fix parsing method call starting with 'crate'
1 parent f9cf71a commit 999c4b4

File tree

5 files changed

+666
-11
lines changed

5 files changed

+666
-11
lines changed

community-rust-frontend/src/main/java/org/sonar/rust/RustGrammar.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1994,7 +1994,7 @@ public static void lexicalpath(LexerlessGrammarBuilder b) {
19941994
b.rule(PATH_IDENT_SEGMENT).is(b.firstOf(
19951995
b.sequence(RustKeyword.KW_SUPER, b.nextNot(IDENTIFIER)),
19961996
b.regexp("^[sS]elf$"),
1997-
RustKeyword.KW_CRATE,
1997+
b.sequence(RustKeyword.KW_CRATE,b.nextNot(IDENTIFIER)),
19981998
b.regexp(DOLLAR_CRATE_REGEX),
19991999
IDENTIFIER
20002000
));

community-rust-frontend/src/test/java/org/sonar/rust/RustLexerTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public void testTokens() {
6868

6969
@Test
7070
public void testParsing() {
71-
String sexpr = "*bar == None { true };";
71+
String sexpr = "crate_root.call(me);";
7272

7373
//Print out Ast node content for debugging purpose
7474

community-rust-frontend/src/test/java/org/sonar/rust/parser/expressions/MethodCallExpressionTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public void testMethodCallExpression() {
5757
.matches("mystruct.myfield")
5858
.matches("other.major")
5959
.matches("foo().x")
60-
//FIXME.matches("(Struct {a: 10, b: 20}).a")
60+
.matches("(Struct {a: 10, b: 20}).a")
6161
.matches("t.get_error_class")
6262
.matches("state.borrow().get_error_class_fn")
6363
.matches("self.get_cache_filename(url)")
@@ -170,6 +170,7 @@ public void testMethodCallExpression() {
170170
.matches("a321.into()")
171171
.matches("321.await")
172172
.matches("321.into()")
173+
.matches("crate_root.call(me)")
173174

174175

175176
;

community-rust-frontend/src/test/java/org/sonar/rust/parser/lexer/IdentifierTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ public void testIdentifier() {
124124
.matches("r#true")
125125
.matches("Москва")
126126
.matches("東京")
127+
.matches("crate_root")
127128

128129
;
129130

0 commit comments

Comments
 (0)