File tree Expand file tree Collapse file tree 2 files changed +21
-1
lines changed Expand file tree Collapse file tree 2 files changed +21
-1
lines changed Original file line number Diff line number Diff line change @@ -1852,7 +1852,8 @@ public static void lexicalpath(LexerlessGrammarBuilder b) {
18521852 b .zeroOrMore (b .sequence (SPC , RustPunctuator .PATHSEP , SPC , SIMPLE_PATH_SEGMENT )));
18531853 b .rule (SIMPLE_PATH_SEGMENT ).is (b .firstOf (
18541854 b .sequence (RustKeyword .KW_SUPER , b .nextNot (IDENTIFIER )),
1855- RustKeyword .KW_SELF_VALUE , b .regexp ("^crate$" ), b .regexp (DOLLAR_CRATE_REGEX ), IDENTIFIER ));
1855+ b .sequence (RustKeyword .KW_SELF_VALUE , b .nextNot (b .regexp ("[a-zA-Z0-9_]" ))),
1856+ b .regexp ("^crate$" ), b .regexp (DOLLAR_CRATE_REGEX ), IDENTIFIER ));
18561857
18571858 b .rule (PATH_IN_EXPRESSION ).is (
18581859 b .optional (SPC , RustPunctuator .PATHSEP , SPC ),
Original file line number Diff line number Diff line change @@ -87,4 +87,23 @@ void testParsing() {
8787 System .out .println (AstXmlPrinter .print (astNode ));
8888
8989 }
90+
91+ @ Test
92+ void testSelfInsideImportTokens () {
93+ testImportParsing ("selfish" );
94+ testImportParsing ("self_api" );
95+ }
96+
97+ private void testImportParsing (String filename ) {
98+ String sexpr = "\n " +
99+ "use api::" + filename + "::MyService; \n " +
100+ " fn update_rates(){" +
101+ " todo!()\n " +
102+ " }" ;
103+
104+ ParserAdapter <LexerlessGrammar > parser = new ParserAdapter <>(
105+ StandardCharsets .UTF_8 , RustGrammar .create ().build ());
106+
107+ parser .parse (sexpr );
108+ }
90109}
You can’t perform that action at this time.
0 commit comments