Skip to content

Commit

Permalink
Fix wrong gep tokenization
Browse files Browse the repository at this point in the history
  • Loading branch information
Y-Nak committed Sep 11, 2023
1 parent 117024e commit 067f42b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion crates/parser/src/lexer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,7 @@ impl<'a> Lexer<'a> {
fn try_eat_opcode(&mut self) -> Option<Code> {
try_eat_variant! {
self,
(b"gep", Code::Gep),
(b"not", Code::Not),
(b"neg", Code::Neg),
(b"add", Code::Add),
Expand Down Expand Up @@ -254,7 +255,6 @@ impl<'a> Lexer<'a> {
(b"fallthrough", Code::FallThrough),
(b"br_table", Code::BrTable),
(b"br", Code::Br),
(b"gep", Code::Gep),
(b"alloca", Code::Alloca),
(b"return", Code::Return),
(b"phi", Code::Phi),
Expand Down
10 changes: 10 additions & 0 deletions crates/parser/src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -930,6 +930,16 @@ mod tests {
));
}

#[test]
fn test_gep() {
assert!(test_func_parser(
"func public %test(v0.**i32) -> **i32:
block0:
v1.*i32 = gep v0 10.i32;
return v1;"
));
}

#[test]
fn parser_with_phi() {
assert!(test_func_parser(
Expand Down

0 comments on commit 067f42b

Please sign in to comment.