Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -641,7 +641,7 @@ private static void functionsItem(LexerlessGrammarBuilder b) {


b.rule(FUNCTION_PARAM).is(
b.zeroOrMore(OUTER_ATTRIBUTE), SPC,
b.zeroOrMore(OUTER_ATTRIBUTE,SPC), SPC,
b.firstOf(FUNCTION_PARAM_PATTERN, RustPunctuator.DOTDOTDOT, TYPE));

b.rule(FUNCTION_PARAM_PATTERN).is(PATTERN_NO_TOP_ALT, SPC, RustPunctuator.COLON,
Expand Down Expand Up @@ -1131,7 +1131,7 @@ private static void functionpointer(LexerlessGrammarBuilder b) {
b.rule(MAYBE_NAMED_PARAM).is(
b.zeroOrMore(OUTER_ATTRIBUTE, SPC),
b.optional(b.sequence(
b.firstOf(IDENTIFIER, RustPunctuator.UNDERSCORE), SPC, RustPunctuator.COLON
b.firstOf(IDENTIFIER, RustPunctuator.UNDERSCORE), SPC, RustPunctuator.COLON, b.nextNot(RustPunctuator.COLON)
)), SPC, TYPE
);
b.rule(MAYBE_NAMED_FUNCTION_PARAMETERS_VARIADIC).is(
Expand Down Expand Up @@ -1732,7 +1732,7 @@ private static void operator(LexerlessGrammarBuilder b) {
}

private static void block(LexerlessGrammarBuilder b) {
b.rule(BLOCK_EXPRESSION).is("{", SPC, b.zeroOrMore(INNER_ATTRIBUTE),
b.rule(BLOCK_EXPRESSION).is("{", SPC, b.zeroOrMore(INNER_ATTRIBUTE,SPC),
SPC, b.optional(STATEMENTS), SPC, "}"
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,11 @@ public void testTokens() {

@Test
public void testParsing() {
String sexpr = "crate_root.call(me);";
String sexpr = "static INIT_ARRAY: unsafe extern \"C\" fn(c::c_int, *mut *mut u8, *mut *mut u8) = {\n" +
" unsafe extern \"C\" fn function(_argc: c::c_int, _argv: *mut *mut u8, envp: *mut *mut u8) {\n" +
" }\n" +
" function\n" +
"};";

//Print out Ast node content for debugging purpose

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ public void testFunctionParameters() {
.matches("x : i32")
.matches("x : i32, y:i64")
.matches("&self, n:u32")
.matches("*mut *mut u8, *mut *mut u8")
.matches("c::c_int, *mut *mut u8, *mut *mut u8")

;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ public void testStatic() {
assertThat(RustGrammar.create().build().rule(RustGrammar.STATIC_ITEM))
.matches("static mut LEVELS: u32 = 0;")
.matches("static mut LEVELS: u32;")
.matches("static INIT_ARRAY: unsafe extern \"C\" fn(c::c_int, *mut *mut u8, *mut *mut u8) = {\n" +
" unsafe extern \"C\" fn function(_argc: c::c_int, _argv: *mut *mut u8, envp: *mut *mut u8) {\n" +
" init_from_envp(envp);\n" +
" }\n" +
" function\n" +
"};")


;
Expand Down
Loading