Skip to content

Commit

Permalink
Merge remote-tracking branches 'artem/vampir-new-constructors' and 'a…
Browse files Browse the repository at this point in the history
…rtem/vampir-special-division'
  • Loading branch information
mariari committed Aug 29, 2023
3 parents b5a6d8e + 36ed4ab + 49d204a commit 15d4927
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 9 deletions.
6 changes: 4 additions & 2 deletions src/vampir/package.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,12 @@
:wire :var
:constant :const
:tuple :wires
:curly :value
:brackets

;; Constructors
:make-alias :make-pub :make-infix :make-application :make-tuples
:make-bind :make-equality :make-wire :make-constant))
:make-alias :make-pub :make-infix :make-application :make-tuples :make-curly
:make-bind :make-equality :make-wire :make-constant :make-brackets))

(geb.utils:muffle-package-variance
(defpackage #:geb.vampir
Expand Down
10 changes: 8 additions & 2 deletions src/vampir/print.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ of ()'s for any non normal form"
(spc:application
(pprint-logical-block (stream nil :prefix "(" :suffix ")")
(print-object expr stream)))
((or spc:tuple spc:normal-form)
((or spc:tuple spc:normal-form spc:curly)
(print-object expr stream))
(geb.extension.spec:common-sub-expression
(extract-expression (geb.spec:obj expr) stream)))
Expand All @@ -118,5 +118,11 @@ of ()'s for any non normal form"
(pprint-logical-block (stream nil :prefix "(" :suffix ")")
(format stream "~{~(~a~)~^, ~}" (spc:wires tup))))

(defmethod print-object ((curly spc:curly) stream)
(format stream "{~A}" (spc:value curly)))

(defmethod print-object ((const spc:constant) stream)
(format stream "~A" (spc:const const)))
(format stream "~(~a~)" (spc:const const)))

(defmethod print-object ((brackets spc:brackets) stream)
(format stream "[]"))
33 changes: 28 additions & 5 deletions src/vampir/spec.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@
;; called base in the file
;; Values are called over a normal form!?!?!?
(deftype expression ()
`(or infix application normal-form tuple
`(or infix application normal-form tuple curly
geb.extension.spec:common-sub-expression))

(deftype normal-form ()
`(or wire constant))
`(or wire constant brackets))

(deftype primitive ()
`(or (eql :+) (eql :-) (eql :*) (eql :^) (eql :\\)
(eql :%) (eql :/) (eql :|:|) (eql :^)))
(eql :%) (eql :/) (eql :|:|) (eql :^) (eql :\|)))

(deftype constraint-list ()
`(satisfies constraint-list))
Expand Down Expand Up @@ -131,20 +131,29 @@
:type list
:accessor wires)))

(defclass curly (mixins)
((value :initarg :value
:accessor value
:type expression
:documentation "The wire argument inside the curly bracket")))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Normal Form Product Types
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(defclass wire (mixins)
((var :initarg :var
:accessor var
:type (or symbol keyword)))
:accessor var))
(:documentation "A reference in vamp-ir"))

(defclass constant (mixins)
((const :initarg :const
:accessor const)))

(defclass brackets (mixins)
()
(:documentation "Brackets designating 0-bit integer"))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Alias
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Expand Down Expand Up @@ -211,3 +220,17 @@

(defun make-tuples (&key wires)
(make-instance 'tuple :wires wires))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Curly Brackets
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(defun make-curly (&key value)
(make-instance 'curly :value value))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Brackets
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(defun make-brackets ()
(make-instance 'brackets))

0 comments on commit 15d4927

Please sign in to comment.