-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #15 from itsubaki/antlr
ANTLR v4
- Loading branch information
Showing
68 changed files
with
24,009 additions
and
7,305 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,19 @@ | ||
SHELL := /bin/bash | ||
|
||
test: | ||
go test -v -cover $(shell go list ./... | grep -v /cmd | grep -v /repl | grep -v -E "qasm$$") -v -coverprofile=coverage.txt -covermode=atomic | ||
antlr: | ||
# https://github.com/openqasm/openqasm/blob/main/source/grammar | ||
pip install antlr4-tools | ||
antlr4 -Dlanguage=Go -visitor -o ./gen/parser -package parser qasm3Lexer.g4 qasm3Parser.g4 | ||
|
||
.PHONY: repl | ||
repl: | ||
go run main.go repl | ||
update: | ||
go get -u ./... | ||
go mod tidy | ||
|
||
lex: | ||
go run main.go lex -f testdata/bell.qasm | ||
go run main.go lex -f testdata/shor_def.qasm | ||
go run cmd/lex/main.go < _testdata/bell.qasm | ||
|
||
parse: | ||
go run main.go parse -f testdata/bell.qasm | ||
go run main.go parse -f testdata/shor_def.qasm | ||
|
||
.PHONY: testdata | ||
testdata: | ||
go run main.go -verbose -f testdata/bell.qasm | ||
go run main.go -verbose -f testdata/shor.qasm | ||
|
||
install: | ||
-rm ${GOPATH}/bin/qasm | ||
go get -u | ||
go mod tidy | ||
go install | ||
|
||
vet: | ||
go vet ./... | ||
go run cmd/parse/main.go < _testdata/bell.qasm | ||
|
||
bench: | ||
go test -bench . ./... --benchmem | ||
|
||
doc: | ||
godoc -http=:6060 | ||
test: | ||
go test -v -cover $(shell go list ./... | grep -v /cmd | grep -v /gen) -v -coverprofile=coverage.txt -covermode=atomic |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,7 @@ | ||
OPENQASM 3.0; | ||
include "testdata/stdgates.qasm"; | ||
include "_testdata/stdgates.qasm"; | ||
|
||
qubit[2] q; | ||
reset q; | ||
|
||
h q[0]; | ||
cx q[0], q[1]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
gate i q { U(0, 0, 0) q; } | ||
gate h q { U(pi/2.0, 0, pi) q; } | ||
gate x q { U(pi, 0, pi) q; } | ||
gate y q { U(pi, pi/2.0, pi/2.0) q; } | ||
gate z q { U(0, pi, 0) q; } | ||
gate cx q0, q1 { ctrl @ U(pi, 0, pi) q0, q1;} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.