Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

parser: allow lock prefix instructions and numbered reg in asm inline #21022

Merged
merged 14 commits into from Mar 16, 2024
11 changes: 10 additions & 1 deletion vlib/v/parser/parser.v
Expand Up @@ -1253,6 +1253,11 @@ fn (mut p Parser) asm_stmt(is_top_level bool) ast.AsmStmt {
}
if p.tok.kind in [.key_in, .key_lock, .key_orelse, .key_select, .key_return] { // `in`, `lock`, `or`, `select`, `return` are v keywords that are also x86/arm/riscv/wasm instructions.
name += p.tok.kind.str()
if p.tok.kind == .key_lock && arch in [.i386, .amd64] {
p.next()
name += ' '
name += p.tok.lit
}
spytheman marked this conversation as resolved.
Show resolved Hide resolved
p.next()
} else if p.tok.kind == .number {
name += p.tok.lit
Expand Down Expand Up @@ -1764,7 +1769,11 @@ fn (mut p Parser) asm_ios(output bool) []ast.AsmIO {
if p.tok.kind == .at {
p.next()
} else {
p.check(.name)
if p.tok.kind == .number {
felipensp marked this conversation as resolved.
Show resolved Hide resolved
p.check(.number)
} else {
p.check(.name)
}
Copy link
Member

@spytheman spytheman Mar 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why? What syntax will trigger the number check?

Copy link
Member

@spytheman spytheman Mar 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add either a test, or an inline code comment here in the parser source, with the concrete syntax that it allows, or both.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is about the constraint part.

image

}
}
mut expr := p.expr(0)
Expand Down