Skip to content

Reimplement Parser #2149

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

Merged
merged 108 commits into from
Apr 17, 2025
Merged
Changes from all commits
Commits
Show all changes
108 commits
Select commit Hold shift + click to select a range
bcf0f51
Implement OpenQASM 3 lexer (#2129)
orpuente-MS Feb 2, 2025
0408e2a
Add initial AST and parser infrastructure (#2148)
idavis Feb 4, 2025
1819c72
Add ability to parse quantum decls and lit exprs (#2160)
idavis Feb 5, 2025
0d049cd
Adding classical & io decls to the parser, stubbing out array decls (…
idavis Feb 7, 2025
a075818
Fix panic in qasm3 lexer found by the fuzzer (#2170)
orpuente-MS Feb 11, 2025
0803258
Add fuzzing for qasm3 (#2167)
idavis Feb 11, 2025
64bc5da
Implement Pratt Parsing for Qasm3 parser (#2166)
orpuente-MS Feb 11, 2025
ecb1623
Parse qasm3 switch statements (#2178)
orpuente-MS Feb 12, 2025
8a55956
Add subroutine, return, and gate defs, externs, and old style decls (…
idavis Feb 12, 2025
b49fc6d
Add array and measurement declaration statements (#2180)
orpuente-MS Feb 13, 2025
0ac5d26
parse if, for, and while statements
orpuente-MS Feb 19, 2025
5b13c80
fix range expression
orpuente-MS Feb 20, 2025
842d10f
update for loop unit tests
orpuente-MS Feb 20, 2025
1ad8e33
add continue statements
orpuente-MS Feb 20, 2025
9f247de
update completions unit tests
orpuente-MS Feb 20, 2025
9d24fae
add break statements
orpuente-MS Feb 20, 2025
dc8eae0
fix assignment expressions and add expression statements
orpuente-MS Feb 20, 2025
2162b11
add end stmt
orpuente-MS Feb 20, 2025
5afe7a1
add alias declarations
orpuente-MS Feb 20, 2025
a968393
format alias.rs file
orpuente-MS Feb 20, 2025
e85af01
fixes during PR review with swernli
orpuente-MS Feb 20, 2025
fce7907
gate calls
orpuente-MS Feb 24, 2025
6f8acf4
update expect tests
orpuente-MS Feb 25, 2025
459ff22
gate-call qubit args should be comma separated
orpuente-MS Feb 25, 2025
edf3f9d
add barrier, box, calgrammar, cal, defcal, delay, measure arrow, and …
orpuente-MS Feb 25, 2025
e3d1854
update completions tests
orpuente-MS Feb 25, 2025
5223d69
add unit tests
orpuente-MS Feb 25, 2025
82d2736
fix formatting
orpuente-MS Feb 25, 2025
77c0c47
update completions tests
orpuente-MS Feb 25, 2025
13975fa
update unit tests
orpuente-MS Feb 25, 2025
fa32afa
add support for timing literals
orpuente-MS Feb 26, 2025
4593e8f
improve TODO messages
orpuente-MS Feb 26, 2025
d6583c8
address comments in PR review
orpuente-MS Feb 26, 2025
cee7f39
add gphase
orpuente-MS Feb 27, 2025
044203f
add unit test for box with designator
orpuente-MS Feb 27, 2025
3f78884
require exactly one angle argument in `gphase`
orpuente-MS Feb 27, 2025
c758fce
fix parse_include and parse_cal_grammar
orpuente-MS Feb 27, 2025
7ec3dbe
PR review fixes
orpuente-MS Feb 27, 2025
7860075
fixes during PR review
orpuente-MS Feb 28, 2025
b370e92
fixes during PR review
orpuente-MS Feb 28, 2025
2ebcec2
add unit tests for gate_call
orpuente-MS Feb 28, 2025
e7d5da8
change unit tests names
orpuente-MS Feb 28, 2025
77ccb80
format file
orpuente-MS Feb 28, 2025
1ccd516
disambiguate between cast expr_stmts and classical decls
orpuente-MS Feb 28, 2025
cc55a3b
update cast unit tests
orpuente-MS Feb 28, 2025
abada59
make expr unit tests also run for expr_stmts by adding a semicolon at…
orpuente-MS Feb 28, 2025
746b2df
fix formatting
orpuente-MS Feb 28, 2025
b6116ac
fix lexer bug
orpuente-MS Mar 1, 2025
a6e1002
format code
orpuente-MS Mar 1, 2025
ed2252e
fix lexer bug and remove `second` from cooked lexer
orpuente-MS Mar 1, 2025
608fff0
update test
orpuente-MS Mar 1, 2025
6713fdb
remove extra scope
orpuente-MS Mar 3, 2025
5d42598
Tidy up Display functions in QASM3 parser (#2209)
orpuente-MS Mar 5, 2025
7860600
Add initial semantic analysis/transform (#2214)
idavis Mar 7, 2025
9d646be
Make Assign and AssignOp valid only in expression statements (#2215)
orpuente-MS Mar 8, 2025
09ff45e
Make assignment a StmtKind (#2216)
orpuente-MS Mar 11, 2025
687b467
Add grammar docstrings to QASM3 parser (#2222)
orpuente-MS Mar 12, 2025
982f84c
Implement base declarations and binary expression lowering (#2221)
idavis Mar 12, 2025
5ecebde
Make control flow stmts use Stmt instead of List<Stmt> for their bodi…
orpuente-MS Mar 13, 2025
98921aa
Update cross file spans, separate parse/semantic result blurring (#2227)
idavis Mar 13, 2025
0997121
Lower control flow stmts in QASM3 parser (#2232)
orpuente-MS Mar 17, 2025
97a6819
Adding new compiler, lowerer is now infallible (#2239)
idavis Mar 18, 2025
02681df
Unify compilation and error propagation. (#2247)
idavis Mar 21, 2025
fd43f81
Add gate calls and the AST items it depends on to the new QASM3 compi…
orpuente-MS Mar 24, 2025
dce297d
Removing old test
idavis Mar 24, 2025
2249c9c
Parsing now bundles IO source loading errors into parse errors. (#2252)
idavis Mar 25, 2025
475c559
Compile gphase, gatedef, and control flow statements (#2254)
orpuente-MS Mar 27, 2025
e182a8c
QASM3 - Add implicit casts to function and gate arguments (#2257)
orpuente-MS Mar 27, 2025
cf4e508
QASM3 - simple index expr (#2258)
orpuente-MS Mar 27, 2025
404dd4d
Add angle support to the new compiler (#2267)
orpuente-MS Mar 31, 2025
50216b3
Lower and compile complex binary ops (#2268)
orpuente-MS Apr 1, 2025
dec185a
Fixing angle input/output (#2269)
idavis Apr 1, 2025
483d384
Fix scoping resolution for defs
idavis Apr 1, 2025
a8022c8
functions and operations with const eval (#2270)
orpuente-MS Apr 1, 2025
d24e88b
Compile annotations into attributes (#2271)
orpuente-MS Apr 1, 2025
9b14f31
unignore tests
orpuente-MS Apr 1, 2025
6cda986
add simulatable intrinsic QIR unit tests
orpuente-MS Apr 1, 2025
8b77982
clippy lints
orpuente-MS Apr 2, 2025
91607e7
apply cargo fmt
orpuente-MS Apr 2, 2025
0b84fc9
make const measurement a parser error
orpuente-MS Apr 2, 2025
f241ed0
do not generate functors when `@SimulatableIntrinsic` is present
orpuente-MS Apr 2, 2025
ed32882
cargo fmt
orpuente-MS Apr 2, 2025
7ceed91
break and continue stmts
orpuente-MS Apr 2, 2025
681f3f7
lower duration literals
orpuente-MS Apr 3, 2025
5434022
use `Type::Void` instead of `Option::None` to represent no return
orpuente-MS Apr 3, 2025
0f97085
return stmt casts to the return type of the function
orpuente-MS Apr 3, 2025
ca9baf7
fix clippy warning
orpuente-MS Apr 3, 2025
21917ea
add assign_op complex tests
orpuente-MS Apr 3, 2025
c68748b
mark assigning_uint_to_negative_lit_results_in_semantic_error as ignore
orpuente-MS Apr 3, 2025
d0b1424
lower extern
orpuente-MS Apr 3, 2025
59f1650
extern unit tests
orpuente-MS Apr 3, 2025
c558bda
Better error messages for const evaluator (#2277)
orpuente-MS Apr 4, 2025
16ceb64
Cyclic and multiple include errors (#2278)
orpuente-MS Apr 7, 2025
83cc9a5
Remove external parser. Fix Qiskit's failure to emit gates. (#2284)
idavis Apr 9, 2025
b82e5a9
Cleanup TODO items (#2285)
orpuente-MS Apr 9, 2025
f9ccdf5
Review errors in lexer, parser, lowerer, and compiler (#2286)
orpuente-MS Apr 10, 2025
9a47fce
Qiskit stdgates workaround (#2289)
idavis Apr 10, 2025
a540d6b
Add benchmark to new parser (#2288)
orpuente-MS Apr 11, 2025
dc07b4b
Fix bug in const evaluator (#2296)
orpuente-MS Apr 11, 2025
686d408
Fix fuzz issues 2297 & 2298 (#2299)
idavis Apr 16, 2025
312cc2a
Remove dead parser code from old compilation (#2300)
idavis Apr 16, 2025
7f70408
Remove dead code (#2301)
orpuente-MS Apr 16, 2025
b73e6e3
Turn builtins into keywords (#2304)
orpuente-MS Apr 16, 2025
38fe479
Parser io feedback (#2303)
idavis Apr 16, 2025
6f6810d
Remove completion dead code (#2305)
orpuente-MS Apr 17, 2025
55ce258
Rename qsc_qasm3 to qsc_qasm (#2307)
orpuente-MS Apr 17, 2025
46e7d51
Rename error diagnostic codes (#2309)
orpuente-MS Apr 17, 2025
37f1b3b
Remove source resolver default impl (#2310)
orpuente-MS Apr 17, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 21 additions & 17 deletions .github/workflows/fuzz.yml
Original file line number Diff line number Diff line change
@@ -7,7 +7,6 @@ env:
TMIN_LOG_FNAME: fuzz.tmin.log # File name to redirect the fuzzing input minimization log to.
GH_ISSUE_TEMPLATE_RFPATH: .github/ISSUE_TEMPLATE/fuzz_bug_report.md
# GitHub issue template rel file path.
TARGET_NAME: compile # Fuzzing target name. Fuzzes the `compile` func of the Q# compiler.
ARTIFACTS_RDPATH: fuzz/artifacts # Fuzzing artifacts rel dir path.
SEEDS_RDPATH: fuzz/seed_inputs # Fuzzing seed inputs rel dir path.
SEEDS_FNAME: list.txt # Fuzzing seed inputs list file name.
@@ -31,11 +30,15 @@ jobs:
fuzz:
name: Fuzzing
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest] # Fuzzing is not supported on Win. The macos is temporarily removed
# because of low availability.
runs-on: ${{ matrix.os }}
target_name: [qsharp, qasm]

runs-on: ${{ matrix.os }}
permissions:
issues: write
steps:
- name: Install and Configure Tools
run: |
@@ -49,29 +52,30 @@ jobs:
submodules: "true"

- name: Gather the Seed Inputs
if: matrix.target_name == 'qsharp'
run: |
cd $OWNER_RDPATH # Enter the dir containing the fuzzing infra.

# Clone the submodules of QDK:
REPOS="Quantum Quantum-NC QuantumKatas QuantumLibraries iqsharp qdk-python qsharp-compiler qsharp-runtime"
for REPO in $REPOS ; do
git clone --depth 1 --single-branch --no-tags --recurse-submodules --shallow-submodules --jobs 4 \
https://github.com/microsoft/$REPO.git $SEEDS_RDPATH/$TARGET_NAME/$REPO
https://github.com/microsoft/$REPO.git $SEEDS_RDPATH/${{ matrix.target_name }}/$REPO
done

# Build a comma-separated list of all the .qs files in $SEEDS_FNAME file:
find $SEEDS_RDPATH/$TARGET_NAME -name "*.qs" | tr "\n" "," > \
$SEEDS_RDPATH/$TARGET_NAME/$SEEDS_FNAME
find $SEEDS_RDPATH/${{ matrix.target_name }} -name "*.qs" | tr "\n" "," > \
$SEEDS_RDPATH/${{ matrix.target_name }}/$SEEDS_FNAME

- name: Build and Run the Fuzz Target
run: |
cd $OWNER_RDPATH # Enter the dir containing the fuzzing infra.
cargo fuzz build --release --sanitizer=none --features do_fuzz $TARGET_NAME # Build the fuzz target.
cargo fuzz build --release --sanitizer=none --features do_fuzz ${{ matrix.target_name }} # Build the fuzz target.

# Run fuzzing for specified number of seconds and redirect the `stderr` to a file
# whose name is specified by the STDERR_LOG_FNAME env var:
RUST_BACKTRACE=1 cargo fuzz run --release --sanitizer=none --features do_fuzz $TARGET_NAME -- \
-seed_inputs=@$SEEDS_RDPATH/$TARGET_NAME/$SEEDS_FNAME \
RUST_BACKTRACE=1 cargo fuzz run --release --sanitizer=none --features do_fuzz ${{ matrix.target_name }} -- \
-seed_inputs=@$SEEDS_RDPATH/${{ matrix.target_name }}/$SEEDS_FNAME \
-max_total_time=$DURATION_SEC \
-rss_limit_mb=4096 \
-max_len=20000 \
@@ -116,33 +120,33 @@ jobs:
# the subsequent `run:` and `uses:` steps.

# Determine the name of a file containing the input of interest (that triggers the panic/crash):
if [ -e $ARTIFACTS_RDPATH/$TARGET_NAME/crash-* ]; then # Panic and Stack Overflow Cases.
if [ -e $ARTIFACTS_RDPATH/${{ matrix.target_name }}/crash-* ]; then # Panic and Stack Overflow Cases.
TO_MINIMIZE_FNAME=crash-*;
elif [ -e $ARTIFACTS_RDPATH/$TARGET_NAME/oom-* ]; then # Out-of-Memory Case.
elif [ -e $ARTIFACTS_RDPATH/${{ matrix.target_name }}/oom-* ]; then # Out-of-Memory Case.
TO_MINIMIZE_FNAME=oom-*;
else
echo -e "File to minimize not found.\nContents of artifacts dir \"$ARTIFACTS_RDPATH/$TARGET_NAME/\":"
ls $ARTIFACTS_RDPATH/$TARGET_NAME/
echo -e "File to minimize not found.\nContents of artifacts dir \"$ARTIFACTS_RDPATH/${{ matrix.target_name }}/\":"
ls $ARTIFACTS_RDPATH/${{ matrix.target_name }}/
fi

if [ "$TO_MINIMIZE_FNAME" != "" ]; then
echo "TO_MINIMIZE_FNAME: $TO_MINIMIZE_FNAME"

# Minimize the input:
( cargo fuzz tmin --release --sanitizer=none --features do_fuzz -r 10000 $TARGET_NAME $ARTIFACTS_RDPATH/$TARGET_NAME/$TO_MINIMIZE_FNAME 2>&1 ) > \
( cargo fuzz tmin --release --sanitizer=none --features do_fuzz -r 10000 ${{ matrix.target_name }} $ARTIFACTS_RDPATH/${{ matrix.target_name }}/$TO_MINIMIZE_FNAME 2>&1 ) > \
$TMIN_LOG_FNAME || MINIMIZATION_FAILED=1

# Get the minimized input relative faile path:
if [ "$MINIMIZATION_FAILED" == "1" ]; then
# Minimization failed, get the latest successful minimized input relative faile path:
MINIMIZED_INPUT_RFPATH=`
cat $TMIN_LOG_FNAME | grep "CRASH_MIN: minimizing crash input: " | tail -n 1 |
sed "s|^.*\($ARTIFACTS_RDPATH/$TARGET_NAME/[^\']*\).*|\1|"`
sed "s|^.*\($ARTIFACTS_RDPATH/${{ matrix.target_name }}/[^\']*\).*|\1|"`
else
# Minimization Succeeded, get the reported minimized input relative faile path::
MINIMIZED_INPUT_RFPATH=`
cat $TMIN_LOG_FNAME | grep "failed to minimize beyond" |
sed "s|.*\($ARTIFACTS_RDPATH/$TARGET_NAME/[^ ]*\).*|\1|" `
sed "s|.*\($ARTIFACTS_RDPATH/${{ matrix.target_name }}/[^ ]*\).*|\1|" `
fi
echo "MINIMIZED_INPUT_RFPATH: $MINIMIZED_INPUT_RFPATH"
echo "MINIMIZED_INPUT_RFPATH=$MINIMIZED_INPUT_RFPATH" >> "$GITHUB_ENV"
@@ -187,8 +191,8 @@ jobs:
path: |
${{ env.OWNER_RDPATH }}/${{ env.STDERR_LOG_FNAME }}
${{ env.OWNER_RDPATH }}/${{ env.TMIN_LOG_FNAME }}
${{ env.OWNER_RDPATH }}/${{ env.ARTIFACTS_RDPATH }}/${{ env.TARGET_NAME }}/*
${{ env.OWNER_RDPATH }}/${{ env.SEEDS_RDPATH }}/${{ env.TARGET_NAME }}/${{ env.SEEDS_FNAME }}
${{ env.OWNER_RDPATH }}/${{ env.ARTIFACTS_RDPATH }}/${{ matrix.target_name }}/*
${{ env.OWNER_RDPATH }}/${{ env.SEEDS_RDPATH }}/${{ matrix.target_name }}/${{ env.SEEDS_FNAME }}
if-no-files-found: error

- name: "If Fuzzing Failed: Report GutHub Issue"
Loading