Skip to content

Commit

Permalink
Remove unused stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
jlapeyre committed Jan 28, 2024
1 parent 1225424 commit 39a189d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 29 deletions.
28 changes: 8 additions & 20 deletions crates/oq3_parser/src/grammar/expressions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ pub(crate) fn expr_no_struct(p: &mut Parser<'_>) {

// GJL made public. remove visibility
pub(crate) fn stmt(p: &mut Parser<'_>, semicolon: Semicolon) {
// dbg!(p.current());
if p.eat(T![;]) {
return;
}
Expand Down Expand Up @@ -226,15 +225,8 @@ fn expr_bp(
return None;
}
let lhs_result = lhs(p, r);
// dbg!(&lhs_result);
let mut lhs = match lhs_result {
Some((lhs, blocklike, _got_call)) => {
// The following prevents making ExprStmt from fn or gate call.
// So the entire business of `got_call` can be abandoned, I think
// if got_call {
// m.abandon(p);
// return None;
// }
Some((lhs, blocklike)) => {
let lhs = lhs.extend_to(p, m);
if r.prefer_stmt && blocklike.is_block() {
return Some((lhs, BlockLike::Block));
Expand Down Expand Up @@ -284,7 +276,7 @@ const LHS_FIRST: TokenSet =
atom::ATOM_EXPR_FIRST.union(TokenSet::new(&[T![&], T![*], T![!], T![.], T![-], T![_]]));

// Handles only prefix and postfix expressions?? Not binary infix?
fn lhs(p: &mut Parser<'_>, r: Restrictions) -> Option<(CompletedMarker, BlockLike, bool)> {
fn lhs(p: &mut Parser<'_>, r: Restrictions) -> Option<(CompletedMarker, BlockLike)> {
let m;
// Unary operators. In OQ3 should be ~ ! -, In r-a this is * ! -
let kind = match p.current() {
Expand All @@ -295,15 +287,15 @@ fn lhs(p: &mut Parser<'_>, r: Restrictions) -> Option<(CompletedMarker, BlockLik
}
_ => {
let (lhs, blocklike) = atom::atom_expr(p, r)?;
let (cm, block_like, got_call) =
let (cm, block_like) =
postfix_expr(p, lhs, blocklike, !(r.prefer_stmt && blocklike.is_block()));
return Some((cm, block_like, got_call));
return Some((cm, block_like));
}
};
// parse the interior of the unary expression
expr_bp(p, None, r, 255);
let cm = m.complete(p, kind);
Some((cm, BlockLike::NotBlock, false))
Some((cm, BlockLike::NotBlock))
}

fn postfix_expr(
Expand All @@ -314,8 +306,7 @@ fn postfix_expr(
// `while true {break}; ();`
mut block_like: BlockLike,
mut allow_calls: bool,
) -> (CompletedMarker, BlockLike, bool) {
let mut got_call = false;
) -> (CompletedMarker, BlockLike) {
loop {
lhs = match p.current() {
// test stmt_postfix_expr_ambiguity
Expand All @@ -326,10 +317,7 @@ fn postfix_expr(
// [] => {}
// }
// }
T!['('] if allow_calls => {
got_call = true;
call_expr(p, lhs)
}
T!['('] if allow_calls => call_expr(p, lhs),
T!['['] if allow_calls => match lhs.kind() {
IDENTIFIER => indexed_identifer(p, lhs),
_ => index_expr(p, lhs),
Expand All @@ -339,7 +327,7 @@ fn postfix_expr(
allow_calls = true;
block_like = BlockLike::NotBlock;
}
(lhs, block_like, got_call)
(lhs, block_like)
}

// Consumes either a function (def) call, or a gate call.
Expand Down
10 changes: 1 addition & 9 deletions crates/oq3_semantics/src/asg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -621,16 +621,8 @@ pub struct GateCallExpr {
qubits: Vec<TExpr>,
}

// #[derive(Clone, Debug, PartialEq, Eq, Hash)]
// pub enum GateModifier {
// Inv,
// Pow(TExpr),
// Ctrl(Option<TExpr>),
// NegCtrl(Option<TExpr>),
// }

// Following naming in ref parser instead
// We ~~will~~ should try to use the distinction between "parameter", which appears in the signature,
// We ~~will~~ try to use the distinction between "parameter", which appears in the signature,
// and "argument", which appears in the call expression.
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
pub enum QubitArgument {
Expand Down

0 comments on commit 39a189d

Please sign in to comment.