Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/parser/src/grammar/expressions/atom.rs')
| -rw-r--r-- | crates/parser/src/grammar/expressions/atom.rs | 38 |
1 files changed, 17 insertions, 21 deletions
diff --git a/crates/parser/src/grammar/expressions/atom.rs b/crates/parser/src/grammar/expressions/atom.rs index 57f1e6e9f0..f98ca5f403 100644 --- a/crates/parser/src/grammar/expressions/atom.rs +++ b/crates/parser/src/grammar/expressions/atom.rs @@ -329,9 +329,11 @@ fn parse_asm_expr(p: &mut Parser<'_>, m: Marker) -> Option<CompletedMarker> { break; } + let op = p.start(); // Parse clobber_abi if p.eat_contextual_kw(T![clobber_abi]) { parse_clobber_abi(p); + op.complete(p, ASM_CLOBBER_ABI); allow_templates = false; continue; } @@ -339,6 +341,7 @@ fn parse_asm_expr(p: &mut Parser<'_>, m: Marker) -> Option<CompletedMarker> { // Parse options if p.eat_contextual_kw(T![options]) { parse_options(p); + op.complete(p, ASM_OPTIONS); allow_templates = false; continue; } @@ -353,27 +356,14 @@ fn parse_asm_expr(p: &mut Parser<'_>, m: Marker) -> Option<CompletedMarker> { false }; - let op = p.start(); - if p.eat(T![in]) { - parse_reg(p); - expr(p); - op.complete(p, ASM_REG_OPERAND); - } else if p.eat_contextual_kw(T![out]) { - parse_reg(p); - expr(p); - op.complete(p, ASM_REG_OPERAND); - } else if p.eat_contextual_kw(T![lateout]) { + let dir_spec = p.start(); + if p.eat(T![in]) || p.eat_contextual_kw(T![out]) || p.eat_contextual_kw(T![lateout]) { + dir_spec.complete(p, ASM_DIR_SPEC); parse_reg(p); expr(p); op.complete(p, ASM_REG_OPERAND); - } else if p.eat_contextual_kw(T![inout]) { - parse_reg(p); - expr(p); - if p.eat(T![=>]) { - expr(p); - } - op.complete(p, ASM_REG_OPERAND); - } else if p.eat_contextual_kw(T![inlateout]) { + } else if p.eat_contextual_kw(T![inout]) || p.eat_contextual_kw(T![inlateout]) { + dir_spec.complete(p, ASM_DIR_SPEC); parse_reg(p); expr(p); if p.eat(T![=>]) { @@ -381,21 +371,26 @@ fn parse_asm_expr(p: &mut Parser<'_>, m: Marker) -> Option<CompletedMarker> { } op.complete(p, ASM_REG_OPERAND); } else if p.eat_contextual_kw(T![label]) { + dir_spec.abandon(p); block_expr(p); op.complete(p, ASM_LABEL); } else if p.eat(T![const]) { + dir_spec.abandon(p); expr(p); op.complete(p, ASM_CONST); } else if p.eat_contextual_kw(T![sym]) { - expr(p); + dir_spec.abandon(p); + paths::type_path(p); op.complete(p, ASM_SYM); } else if allow_templates { + dir_spec.abandon(p); op.abandon(p); if expr(p).is_none() { p.err_and_bump("expected asm template"); } continue; } else { + dir_spec.abandon(p); op.abandon(p); p.err_and_bump("expected asm operand"); if p.at(T!['}']) { @@ -424,11 +419,12 @@ fn parse_options(p: &mut Parser<'_>) { T![att_syntax], T![raw], ]; - - if !OPTIONS.iter().any(|&syntax| p.eat(syntax)) { + let m = p.start(); + if !OPTIONS.iter().any(|&syntax| p.eat_contextual_kw(syntax)) { p.err_and_bump("expected asm option"); continue; } + m.complete(p, ASM_OPTION); // Allow trailing commas if p.eat(T![')']) { |