diff --git a/src/ast.lisp b/src/ast.lisp index 59df4c15..8a84a531 100644 --- a/src/ast.lisp +++ b/src/ast.lisp @@ -439,7 +439,7 @@ compilation passes.")) ((name :reader extern-name :initarg :name :documentation "The name of the function.")) - (:documentation "A function that operates on classical memory and values, declared to + (:documentation "A procedure that operates on classical memory and values, declared to be available in the underlying system.")) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Definitions ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; @@ -1126,17 +1126,21 @@ Each addressing mode will be a vector of symbols: (defclass call (classical-instruction) ((extern :initarg :extern - :reader call-extern) + :reader call-extern + :type extern + :documentation "The extern to be called.") (arguments :initarg :arguments - :reader call-arguments))) + :reader call-arguments + :documentation "A list of memory refs and constant values")) + (:documentation "A call to an EXTERN function.")) (defmethod mnemonic ((call call)) (declare (ignore call)) (values "CALL" 'call)) (defmethod arguments ((call call)) - (map 'vector #'identity (cons (call-extern call) (call-arguments call)))) + (coerce (cons (call-extern call) (call-arguments call)) 'vector)) (defclass jump (instruction) ((label :initarg :label diff --git a/src/package.lisp b/src/package.lisp index 1b7a23a2..f08c19fc 100644 --- a/src/package.lisp +++ b/src/package.lisp @@ -150,102 +150,102 @@ ;; ast.lisp (:export - #:copy-instance ; GENERIC, METHOD - - #:qubit ; STRUCTURE - #:qubit-index ; ACCESSOR - #:qubit= ; FUNCTION - #:qubit-p ; FUNCTION - - #:constant ; STRUCTURE - #:constant-value ; READER - #:constant-value-type ; READER - #:constant= ; FUNCTION - #:is-constant ; FUNCTION (PREDICATE) - - #:label ; STRUCTURE - #:label-name ; ACCESSOR - - #:param ; STRUCTURE - #:param-name ; READER - #:is-param ; FUNCTION (PREDICATE) - #:param= ; FUNCTION - - #:formal ; STRUCTURE - #:formal-name ; READER - #:is-formal ; FUNCTION (PREDICATE) - #:formal= ; FUNCTION - - #:argument= ; FUNCTION - - #:delayed-expression ; TYPE (STRUCTURE) - #:delayed-expression-p ; FUNCTION - #:make-delayed-expression ; FUNCTION - #:delayed-expression-params ; READER - #:delayed-expression-lambda-params ; READER - #:delayed-expression-expression ; READER - #:evaluate-delayed-expression ; FUNCTION - - #:memory-ref ; TYPE (STRUCTURE) - #:mref ; FUNCTION (CONSTRUCTOR) - #:memory-ref-name ; READER - #:memory-ref-position ; READER - #:memory-ref-descriptor ; READER - #:memory-ref= ; FUNCTION - #:memory-ref-hash ; FUNCTION - #:is-mref ; FUNCTION (PREDICATE) - #:memory-name ; TYPE (STRUCTURE) - #:memory-name-descriptor ; READER - #:memory-name-region-name ; READER - #:memory-offset ; TYPE (STRUCTURE), FUNCTION - #:memory-offset-offset ; READER - - #:jump-target ; CLASS - #:jump-target-p ; FUNCTION - #:jump-target-label ; READER - - #:include ; CLASS - #:include-pathname ; READER - - #:instruction ; ABSTRACT CLASS - - #:no-operation ; CLASS - - #:pragma ; CLASS - #:pragma-words ; READER - #:pragma-freeform-string ; READER - #:make-pragma ; FUNCTION - - #:halt ; CLASS - #:haltp ; FUNCTION - #:reset ; CLASS - #:reset-qubit ; CLASS - #:reset-qubit-target ; READER - - #:wait ; CLASS - - #:unary-classical-instruction ; ABSTRACT CLASS - #:classical-target ; READER - - #:classical-negate ; CLASS - #:classical-not ; CLASS - - #:binary-classical-instruction ; ABSTRACT CLASS - #:classical-left-operand ; READER - #:classical-right-operand ; READER - - #:classical-and ; CLASS - #:classical-inclusive-or ; CLASS - #:classical-exclusive-or ; CLASS - #:classical-addition ; CLASS - #:classical-subtraction ; CLASS - #:classical-multiplication ; CLASS - #:classical-division ; CLASS - #:classical-move ; CLASS - #:classical-exchange ; CLASS - #:classical-convert ; CLASS - - #:trinary-classical-instruction ; ABSTRACT CLASS + #:copy-instance ; GENERIC, METHOD + + #:qubit ; STRUCTURE + #:qubit-index ; ACCESSOR + #:qubit= ; FUNCTION + #:qubit-p ; FUNCTION + + #:constant ; STRUCTURE + #:constant-value ; READER + #:constant-value-type ; READER + #:constant= ; FUNCTION + #:is-constant ; FUNCTION (PREDICATE) + + #:label ; STRUCTURE + #:label-name ; ACCESSOR + + #:param ; STRUCTURE + #:param-name ; READER + #:is-param ; FUNCTION (PREDICATE) + #:param= ; FUNCTION + + #:formal ; STRUCTURE + #:formal-name ; READER + #:is-formal ; FUNCTION (PREDICATE) + #:formal= ; FUNCTION + + #:argument= ; FUNCTION + + #:delayed-expression ; TYPE (STRUCTURE) + #:delayed-expression-p ; FUNCTION + #:make-delayed-expression ; FUNCTION + #:delayed-expression-params ; READER + #:delayed-expression-lambda-params ; READER + #:delayed-expression-expression ; READER + #:evaluate-delayed-expression ; FUNCTION + + #:memory-ref ; TYPE (STRUCTURE) + #:mref ; FUNCTION (CONSTRUCTOR) + #:memory-ref-name ; READER + #:memory-ref-position ; READER + #:memory-ref-descriptor ; READER + #:memory-ref= ; FUNCTION + #:memory-ref-hash ; FUNCTION + #:is-mref ; FUNCTION (PREDICATE) + #:memory-name ; TYPE (STRUCTURE) + #:memory-name-descriptor ; READER + #:memory-name-region-name ; READER + #:memory-offset ; TYPE (STRUCTURE), FUNCTION + #:memory-offset-offset ; READER + + #:jump-target ; CLASS + #:jump-target-p ; FUNCTION + #:jump-target-label ; READER + + #:include ; CLASS + #:include-pathname ; READER + + #:instruction ; ABSTRACT CLASS + + #:no-operation ; CLASS + + #:pragma ; CLASS + #:pragma-words ; READER + #:pragma-freeform-string ; READER + #:make-pragma ; FUNCTION + + #:halt ; CLASS + #:haltp ; FUNCTION + #:reset ; CLASS + #:reset-qubit ; CLASS + #:reset-qubit-target ; READER + + #:wait ; CLASS + + #:unary-classical-instruction ; ABSTRACT CLASS + #:classical-target ; READER + + #:classical-negate ; CLASS + #:classical-not ; CLASS + + #:binary-classical-instruction ; ABSTRACT CLASS + #:classical-left-operand ; READER + #:classical-right-operand ; READER + + #:classical-and ; CLASS + #:classical-inclusive-or ; CLASS + #:classical-exclusive-or ; CLASS + #:classical-addition ; CLASS + #:classical-subtraction ; CLASS + #:classical-multiplication ; CLASS + #:classical-division ; CLASS + #:classical-move ; CLASS + #:classical-exchange ; CLASS + #:classical-convert ; CLASS + + #:trinary-classical-instruction ; ABSTRACT CLASS #:classical-load ; CLASS #:classical-store ; CLASS @@ -364,298 +364,298 @@ #:classical-load-bit/bit*/integer ; TYPED-CLASS #:classical-greater-equal-bit/integer/integer ; TYPED-CLASS - #:jump ; ABSTRACT CLASS - #:jump-label ; READER - #:unconditional-jump ; CLASS - #:conditional-jump-address ; READER - #:jump-when ; CLASS - #:jump-unless ; CLASS - - #:measurement ; ABSTRACT CLASS - #:measurement-qubit ; READER - - #:measure ; CLASS - #:measure-address ; READER - - #:measure-discard ; CLASS - - #:operator-description ; ADT - #:named-operator ; ADT CONSTRUCTOR - #:controlled-operator ; ADT CONSTRUCTOR - #:dagger-operator ; ADT CONSTRUCTOR - #:forked-operator ; ADT CONSTRUCTOR - #:operator-description-root-name ; FUNCTION - #:operator-description= ; FUNCTION - #:operator-description-hash ; FUNCTION - #:operator-description-string ; FUNCTION - #:plain-operator-p ; FUNCTION - #:print-operator-description ; FUNCTION - - #:application ; ABSTRACT CLASS - #:application-operator ; ACCESSOR - #:application-parameters ; ACCESSOR - #:application-arguments ; ACCESSOR - #:application-operator-name ; FUNCTION - #:application-operator-root-name ; FUNCTION - - #:unresolved-application ; CLASS - - #:stub ; CLASS - #:stub-application ; CLASS - - #:call ; CLASS - #:extern ; CLASS - - #:register-classical-function ; FUNCTION - - #:gate-application ; CLASS - #:gate-application-gate ; GENERIC, READER - #:gate-application-resolution ; READER - #:anonymous-gate-application-p ; FUNCTION - #:swap-application-p ; FUNCTION - - #:circuit-application ; CLASS - #:circuit-application-definition ; ACCESSOR - - #:lexical-context ; GENERIC - - #:gate-definition ; ABSTRACT CLASS - #:gate-definition-name ; READER - #:gate-definition-entries ; READER - #:matrix-gate-definition ; CLASS - #:static-gate-definition ; CLASS - #:parameterized-gate-definition ; CLASS - #:gate-definition-parameters ; READER - #:permutation-gate-definition ; CLASS - #:permutation-gate-definition-permutation ; READER - #:exp-pauli-sum-gate-definition ; CLASS - #:exp-pauli-sum-gate-definition-terms ; READER - #:exp-pauli-sum-gate-definition-parameters ; READER - #:exp-pauli-sum-gate-definition-arguments ; READER - - #:circuit-definition ; CLASS - #:circuit-definition-name ; READER - #:circuit-definition-parameters ; READER - #:circuit-definition-arguments ; READER - #:circuit-definition-body ; READER - - #:parsed-program ; CLASS - #:parsed-program-gate-definitions ; READER - #:parsed-program-circuit-definitions ; READER - #:parsed-program-memory-definitions ; READER - #:parsed-program-executable-code ; ACCESSOR - - #:parsed-program-stub-operations ; ACCESSOR - #:print-parsed-program ; FUNCTION - - #:*print-parsed-program-text* ; PARAMETER - #:*print-fractional-radians* ; PARAMETER - #:print-instruction ; FUNCTION - #:print-instruction-to-string ; FUNCTION - #:instruction-fmt ; FUNCTION (format directive) - #:real-fmt ; FUNCTION (format directive) - #:complex-fmt ; FUNCTION (format directive) - - #:comment ; FUNCTION - - #:rewiring ; TYPE (STRUCTURE) - #:init-rewiring ; FUNCTION (CONSTRUCTOR) - #:rewiring-l2p ; ACCESSOR - #:rewiring-p2l ; ACCESSOR - #:make-rewiring-from-string ; FUNCTION - #:make-rewiring-pair-from-string ; FUNCTION - #:extract-final-exit-rewiring-vector ; FUNCTION + #:jump ; ABSTRACT CLASS + #:jump-label ; READER + #:unconditional-jump ; CLASS + #:conditional-jump-address ; READER + #:jump-when ; CLASS + #:jump-unless ; CLASS + + #:measurement ; ABSTRACT CLASS + #:measurement-qubit ; READER + + #:measure ; CLASS + #:measure-address ; READER + + #:measure-discard ; CLASS + + #:operator-description ; ADT + #:named-operator ; ADT CONSTRUCTOR + #:controlled-operator ; ADT CONSTRUCTOR + #:dagger-operator ; ADT CONSTRUCTOR + #:forked-operator ; ADT CONSTRUCTOR + #:operator-description-root-name ; FUNCTION + #:operator-description= ; FUNCTION + #:operator-description-hash ; FUNCTION + #:operator-description-string ; FUNCTION + #:plain-operator-p ; FUNCTION + #:print-operator-description ; FUNCTION + + #:application ; ABSTRACT CLASS + #:application-operator ; ACCESSOR + #:application-parameters ; ACCESSOR + #:application-arguments ; ACCESSOR + #:application-operator-name ; FUNCTION + #:application-operator-root-name ; FUNCTION + + #:unresolved-application ; CLASS + + #:stub ; CLASS + #:stub-application ; CLASS + + #:call ; CLASS + #:extern ; CLASS + + #:register-classical-function ; FUNCTION + + #:gate-application ; CLASS + #:gate-application-gate ; GENERIC, READER + #:gate-application-resolution ; READER + #:anonymous-gate-application-p ; FUNCTION + #:swap-application-p ; FUNCTION + + #:circuit-application ; CLASS + #:circuit-application-definition ; ACCESSOR + + #:lexical-context ; GENERIC + + #:gate-definition ; ABSTRACT CLASS + #:gate-definition-name ; READER + #:gate-definition-entries ; READER + #:matrix-gate-definition ; CLASS + #:static-gate-definition ; CLASS + #:parameterized-gate-definition ; CLASS + #:gate-definition-parameters ; READER + #:permutation-gate-definition ; CLASS + #:permutation-gate-definition-permutation ; READER + #:exp-pauli-sum-gate-definition ; CLASS + #:exp-pauli-sum-gate-definition-terms ; READER + #:exp-pauli-sum-gate-definition-parameters ; READER + #:exp-pauli-sum-gate-definition-arguments ; READER + + #:circuit-definition ; CLASS + #:circuit-definition-name ; READER + #:circuit-definition-parameters ; READER + #:circuit-definition-arguments ; READER + #:circuit-definition-body ; READER + + #:parsed-program ; CLASS + #:parsed-program-gate-definitions ; READER + #:parsed-program-circuit-definitions ; READER + #:parsed-program-memory-definitions ; READER + #:parsed-program-executable-code ; ACCESSOR + + #:parsed-program-stub-operations ; ACCESSOR + #:print-parsed-program ; FUNCTION + + #:*print-parsed-program-text* ; PARAMETER + #:*print-fractional-radians* ; PARAMETER + #:print-instruction ; FUNCTION + #:print-instruction-to-string ; FUNCTION + #:instruction-fmt ; FUNCTION (format directive) + #:real-fmt ; FUNCTION (format directive) + #:complex-fmt ; FUNCTION (format directive) + + #:comment ; FUNCTION + + #:rewiring ; TYPE (STRUCTURE) + #:init-rewiring ; FUNCTION (CONSTRUCTOR) + #:rewiring-l2p ; ACCESSOR + #:rewiring-p2l ; ACCESSOR + #:make-rewiring-from-string ; FUNCTION + #:make-rewiring-pair-from-string ; FUNCTION + #:extract-final-exit-rewiring-vector ; FUNCTION - #:make-rewiring-comment ; FUNCTION - #:rewiring-comment-type ; FUNCTION - #:instruction-rewirings ; FUNCTION + #:make-rewiring-comment ; FUNCTION + #:rewiring-comment-type ; FUNCTION + #:instruction-rewirings ; FUNCTION - #:nth-instr ; FUNCTION + #:nth-instr ; FUNCTION ) - ;; define-pragma.lisp + ;; define-pragma.lisp (:export - #:global-pragma-instruction-p ; FUNCTION + #:global-pragma-instruction-p ; FUNCTION ) - ;; pragmas.lisp + ;; pragmas.lisp (:export - #:pragma-qubit-index ; READER - #:pragma-matrix-entries ; READER - #:pragma-qubit-arguments ; READER - #:pragma-operator-name ; READER - #:parsed-program-has-pragma-p ; FUNCTION - #:parsed-program-has-preserve-blocks-p ; FUNCTION - - #:pragma-preserve-block ; CLASS - #:pragma-end-preserve-block ; CLASS + #:pragma-qubit-index ; READER + #:pragma-matrix-entries ; READER + #:pragma-qubit-arguments ; READER + #:pragma-operator-name ; READER + #:parsed-program-has-pragma-p ; FUNCTION + #:parsed-program-has-preserve-blocks-p ; FUNCTION + + #:pragma-preserve-block ; CLASS + #:pragma-end-preserve-block ; CLASS - #:pragma-commuting-blocks ; CLASS - #:pragma-end-commuting-blocks ; CLASS + #:pragma-commuting-blocks ; CLASS + #:pragma-end-commuting-blocks ; CLASS - #:pragma-block ; CLASS - #:pragma-end-block ; CLASS + #:pragma-block ; CLASS + #:pragma-end-block ; CLASS - #:pragma-add-kraus ; CLASS - #:pragma-add-kraus-operator-name ; ACCESSOR - #:pragma-add-kraus-qubit-arguments ; ACCESSOR - #:pragma-add-kraus-matrix-entries ; ACCESSOR + #:pragma-add-kraus ; CLASS + #:pragma-add-kraus-operator-name ; ACCESSOR + #:pragma-add-kraus-qubit-arguments ; ACCESSOR + #:pragma-add-kraus-matrix-entries ; ACCESSOR - #:pragma-readout-povm ; CLASS - #:pragma-readout-povm-qubit-index ; ACCESSOR - #:pragma-readout-povm-matrix-entries ; ACCESSOR + #:pragma-readout-povm ; CLASS + #:pragma-readout-povm-qubit-index ; ACCESSOR + #:pragma-readout-povm-matrix-entries ; ACCESSOR - #:pragma-expected-rewiring ; CLASS - #:pragma-expected-rewiring-rewiring ; ACCESSOR + #:pragma-expected-rewiring ; CLASS + #:pragma-expected-rewiring-rewiring ; ACCESSOR - #:pragma-current-rewiring ; CLASS - #:pragma-current-rewiring-rewiring ; ACCESSOR + #:pragma-current-rewiring ; CLASS + #:pragma-current-rewiring-rewiring ; ACCESSOR - #:pragma-initial-rewiring ; CLASS - #:pragma-initial-rewiring-rewiring ; ACCESSOR + #:pragma-initial-rewiring ; CLASS + #:pragma-initial-rewiring-rewiring ; ACCESSOR - #:pragma-rewiring-search ; CLASS - #:pragma-swap-search-type ; ACCESSOR + #:pragma-rewiring-search ; CLASS + #:pragma-swap-search-type ; ACCESSOR #:pragma-rewiring - #:pragma-rewiring-type ; FUNCTION + #:pragma-rewiring-type ; FUNCTION ) - ;; parser.lisp + ;; parser.lisp (:export - #:token ; TYPE (STRUCTURE) - #:tok ; FUNCTION (CONSTRUCTOR) - #:token-line ; ACCESSOR - #:token-pathname ; ACCESSOR - #:token-type ; ACCESSOR - #:token-payload ; ACCESSOR - #:tokenize ; FUNCTION - #:disappointing-token-error ; CONDITION - - #:*parse-context* ; VARIABLE - #:quil-parse-error ; CONDITION - #:parse-program-lines ; FUNCTION - #:parse-quil-into-raw-program ; FUNCTION - #:resolve-safely ; FUNCTION - #:safely-read-quil ; FUNCTION - #:safely-parse-quil ; FUNCTION + #:token ; TYPE (STRUCTURE) + #:tok ; FUNCTION (CONSTRUCTOR) + #:token-line ; ACCESSOR + #:token-pathname ; ACCESSOR + #:token-type ; ACCESSOR + #:token-payload ; ACCESSOR + #:tokenize ; FUNCTION + #:disappointing-token-error ; CONDITION + + #:*parse-context* ; VARIABLE + #:quil-parse-error ; CONDITION + #:parse-program-lines ; FUNCTION + #:parse-quil-into-raw-program ; FUNCTION + #:resolve-safely ; FUNCTION + #:safely-read-quil ; FUNCTION + #:safely-parse-quil ; FUNCTION ) - ;; cl-quil.lisp + ;; cl-quil.lisp (:export #:parse - #:parse-quil ; FUNCTION - #:read-quil-file ; FUNCTION + #:parse-quil ; FUNCTION + #:read-quil-file ; FUNCTION - #:*safe-include-directory* ; VARIABLE + #:*safe-include-directory* ; VARIABLE - #:ambiguous-definition-condition ; CONDITION + #:ambiguous-definition-condition ; CONDITION ) - ;; initialize-standard-gates.lisp + ;; initialize-standard-gates.lisp (:export - #:initialize-standard-gates ; FUNCTION + #:initialize-standard-gates ; FUNCTION ) - ;; gates.lisp + ;; gates.lisp (:export - #:gate-matrix ; GENERIC, METHOD - #:gate-dimension ; GENERIC, METHOD + #:gate-matrix ; GENERIC, METHOD + #:gate-dimension ; GENERIC, METHOD - #:gate ; ABSTRACT CLASS - #:gate-name ; READER + #:gate ; ABSTRACT CLASS + #:gate-name ; READER - #:static-gate ; ABSTRACT CLASS - #:dynamic-gate ; ABSTRACT CLASS - #:dynamic-gate-arity ; READER + #:static-gate ; ABSTRACT CLASS + #:dynamic-gate ; ABSTRACT CLASS + #:dynamic-gate-arity ; READER - #:simple-gate ; CLASS - #:simple-gate-matrix ; READER + #:simple-gate ; CLASS + #:simple-gate-matrix ; READER - #:permutation-gate ; CLASS - #:permutation-gate-permutation ; READER - #:make-permutation-gate ; FUNCTION + #:permutation-gate ; CLASS + #:permutation-gate-permutation ; READER + #:make-permutation-gate ; FUNCTION - #:parameterized-gate ; CLASS - #:parameterized-gate-matrix-function ; READER - #:unknown-gate-parameter ; CONDITION + #:parameterized-gate ; CLASS + #:parameterized-gate-matrix-function ; READER + #:unknown-gate-parameter ; CONDITION - #:exp-pauli-sum-gate ; CLASS - #:exp-pauli-sum-gate-parameters ; READER - #:exp-pauli-sum-gate-arguments ; READER - #:exp-pauli-sum-gate-terms ; READER + #:exp-pauli-sum-gate ; CLASS + #:exp-pauli-sum-gate-parameters ; READER + #:exp-pauli-sum-gate-arguments ; READER + #:exp-pauli-sum-gate-terms ; READER - #:sequence-gate ; CLASS - #:sequence-gate-gate-definition ; READER + #:sequence-gate ; CLASS + #:sequence-gate-gate-definition ; READER - #:pauli-term ; STRUCT - #:make-pauli-term ; FUNCTION - #:pauli-term-pauli-word ; FUNCTION - #:pauli-term-prefactor ; FUNCTION - #:pauli-term-arguments ; FUNCTION + #:pauli-term ; STRUCT + #:make-pauli-term ; FUNCTION + #:pauli-term-pauli-word ; FUNCTION + #:pauli-term-prefactor ; FUNCTION + #:pauli-term-arguments ; FUNCTION - #:controlled-gate ; CLASS - #:control-gate ; FUNCTION - #:forked-gate ; CLASS - #:fork-gate ; FUNCTION - #:dagger-gate ; CLASS, FUNCTION - #:target ; READER + #:controlled-gate ; CLASS + #:control-gate ; FUNCTION + #:forked-gate ; CLASS + #:fork-gate ; FUNCTION + #:dagger-gate ; CLASS, FUNCTION + #:target ; READER - #:standard-gate-names ; FUNCTION - #:lookup-standard-gate ; FUNCTION + #:standard-gate-names ; FUNCTION + #:lookup-standard-gate ; FUNCTION - #:gate-definition-to-gate ; GENERIC, METHOD + #:gate-definition-to-gate ; GENERIC, METHOD - #:operator-description-gate-lifter ; FUNCTION + #:operator-description-gate-lifter ; FUNCTION ) - ;; build-gate.lisp + ;; build-gate.lisp (:export - #:%capture-arg ; FUNCTION - #:%capture-param ; FUNCTION - #:build-gate ; FUNCTION - #:anon-gate ; FUNCTION - #:kq-gate-on-lines ; FUNCTION - #:repeatedly-fork ; FUNCTION - #:build-UCR ; FUNCTION - #:repeatedly-control ; FUNCTION - #:build-multiple-controlled-gate ; FUNCTION - #:param-binary-op ; FUNCTION - #:param-+ ; FUNCTION - #:param-* ; FUNCTION - #:param-mod ; FUNCTION + #:%capture-arg ; FUNCTION + #:%capture-param ; FUNCTION + #:build-gate ; FUNCTION + #:anon-gate ; FUNCTION + #:kq-gate-on-lines ; FUNCTION + #:repeatedly-fork ; FUNCTION + #:build-UCR ; FUNCTION + #:repeatedly-control ; FUNCTION + #:build-multiple-controlled-gate ; FUNCTION + #:param-binary-op ; FUNCTION + #:param-+ ; FUNCTION + #:param-* ; FUNCTION + #:param-mod ; FUNCTION ) - ;; with-inst.lisp + ;; with-inst.lisp (:export #:with-inst #:finish-compiler #:inst #:inst*) - ;; transformable-mixin.lisp + ;; transformable-mixin.lisp (:export - #:unsatisfied-transform-dependency ; CONDITION + #:unsatisfied-transform-dependency ; CONDITION #:unsatisfied-transform-dependency-object - ; READER + ; READER #:unsatisfied-transform-dependency-needed-transform - ; READER + ; READER #:unsatisfied-transform-dependency-attempted-transform - ; READER - #:transformable ; CLASS - #:transformedp ; GENERIC, METHOD - #:transform ; GENERIC, METHOD - #:transform-if ; FUNCTION - #:define-transform ; MACRO - #:find-transform ; FUNCTION - #:transforms-performed ; FUNCTION - - #:transform-description ; STRUCT - #:make-transform-description ; FUNCTION (CONSTRUCTOR) - #:transform-description-name ; ACCESSOR - #:transform-description-documentation ; ACCESSOR - #:transform-description-predecessors ; ACCESSOR - #:transform-description-function ; ACCESSOR + ; READER + #:transformable ; CLASS + #:transformedp ; GENERIC, METHOD + #:transform ; GENERIC, METHOD + #:transform-if ; FUNCTION + #:define-transform ; MACRO + #:find-transform ; FUNCTION + #:transforms-performed ; FUNCTION + + #:transform-description ; STRUCT + #:make-transform-description ; FUNCTION (CONSTRUCTOR) + #:transform-description-name ; ACCESSOR + #:transform-description-documentation ; ACCESSOR + #:transform-description-predecessors ; ACCESSOR + #:transform-description-function ; ACCESSOR ) ;; analysis/process-includes.lisp diff --git a/src/parser.lisp b/src/parser.lisp index 9adcfc58..3efe9725 100644 --- a/src/parser.lisp +++ b/src/parser.lisp @@ -431,11 +431,11 @@ If the parser does not match, then it should return NIL.") (let ((*formal-arguments-allowed* t)) (parse-memory-descriptor tok-lines))) - ;; STUB DECLARATION + ;; Stub Declaration ((:STUB) (parse-stub tok-lines)) - ;; CALL INSTRUCTION + ;; Call Instruction ((:CALL) (parse-call tok-lines)) @@ -443,7 +443,7 @@ If the parser does not match, then it should return NIL.") ((:PRAGMA) (parse-pragma tok-lines)) - ;; EXTERN DECLARATION + ;; Extern Declaration ((:EXTERN) (parse-extern tok-lines)) diff --git a/src/pragmas.lisp b/src/pragmas.lisp index e5708822..be7b9b68 100644 --- a/src/pragmas.lisp +++ b/src/pragmas.lisp @@ -180,11 +180,15 @@ Expected syntax: PRAGMA NON_VOLATILE identifier") :do (princ c token) :finally (when c (decf pos)))))) (cond ((equal "mut" token) - :MUT) - ((every (a:conjoin (complement #'alpha-char-p) #'alphanumericp) token) - (values :INT (parse-integer token))) + ':MUT) + ((every + (load-time-value + (a:conjoin (complement #'alpha-char-p) #'alphanumericp) + t) + token) + (values ':INT (parse-integer token))) (t - (values :WORD token)))))) + (values ':WORD token)))))) nil))) #'next-token))) @@ -208,7 +212,7 @@ Expected syntax: PRAGMA NON_VOLATILE identifier") (param (:WORD :COLON :MUT type - (lambda (var i0 mut type) (declare (ignore i0 mut)) (list* var :mut type))) + (lambda (var i0 mut type) (declare (ignore i0 mut)) (list* var ':mut type))) (:WORD :COLON type (lambda (var i0 type) (declare (ignore i0)) (cons var type)))) @@ -228,12 +232,16 @@ Expected syntax: PRAGMA EXTERN extern-name \"TYPE? \( (var : mut? TYPE)+ \)") (:words name) (:freeform-string function-signature-string) (:initialization - (let ((parsed (yacc:parse-with-lexer - (tokenize-extern-signature function-signature-string) - *extern-signature-grammar*))) - (setf extern-name name) - (setf value-type (getf parsed :value-type)) - (setf param-types (getf parsed :param-types))))) + (handler-case (let ((parsed (yacc:parse-with-lexer + (tokenize-extern-signature function-signature-string) + *extern-signature-grammar*))) + (setf extern-name name) + (setf value-type (getf parsed :value-type)) + (setf param-types (getf parsed :param-types))) + (yacc:yacc-parse-error (err) + (warn "Syntax error while parsing PRAGMA EXTERN: ~s~% Error: ~a" + function-signature-string + (princ-to-string err)))))) (defun parsed-program-has-pragma-p (parsed-program &optional (pragma-type 'pragma)) diff --git a/tests/bad-test-files/bad-empty-extern.quil b/tests/bad-test-files/bad-empty-extern.quil index e810faf2..7a447dfe 100644 --- a/tests/bad-test-files/bad-empty-extern.quil +++ b/tests/bad-test-files/bad-empty-extern.quil @@ -1,4 +1,4 @@ -# "Empty" extern declarations ar bad +# "Empty" extern declarations are bad EXTERN