Skip to content

Commit bc6c375

Browse files
committed
add docstrings to the dissambiguate functions
1 parent 14c5948 commit bc6c375

File tree

1 file changed

+11
-0
lines changed
  • compiler/qsc_qasm3/src/parser

1 file changed

+11
-0
lines changed

compiler/qsc_qasm3/src/parser/stmt.rs

+11
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ use crate::{
3434

3535
use super::{prim::token, ParserContext};
3636

37+
/// Our implementation differs slightly from the grammar in
38+
/// that we accumulate annotations and append them to the next
39+
/// consecutive statement.
40+
///
3741
/// Grammar:
3842
/// ```g4
3943
/// pragma
@@ -163,6 +167,9 @@ pub(super) fn parse(s: &mut ParserContext) -> Result<Box<Stmt>> {
163167
}))
164168
}
165169

170+
/// This helper function allows us to disambiguate between
171+
/// non-constant declarations and cast expressions when
172+
/// reading a `TypeDef`.
166173
fn disambiguate_type(s: &mut ParserContext, ty: TypeDef) -> Result<StmtKind> {
167174
let lo = ty.span().lo;
168175
if matches!(s.peek().kind, TokenKind::Identifier) {
@@ -186,6 +193,10 @@ fn disambiguate_type(s: &mut ParserContext, ty: TypeDef) -> Result<StmtKind> {
186193
}
187194
}
188195

196+
/// This helper function allows us to disambiguate between
197+
/// assignments, assignment operations, gate calls, and
198+
/// expr_stmts beginning with an ident or a function call
199+
/// when reading an `Ident`.
189200
fn disambiguate_ident(s: &mut ParserContext, indexed_ident: IndexedIdent) -> Result<StmtKind> {
190201
let lo = indexed_ident.span.lo;
191202
if s.peek().kind == TokenKind::Eq {

0 commit comments

Comments
 (0)