Skip to content
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

Curly and Brackets Constructors #145

Merged
merged 1 commit into from
Aug 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
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 "[]"))
31 changes: 27 additions & 4 deletions src/vampir/spec.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@
;; 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 :|:|)))
Expand Down Expand Up @@ -130,20 +130,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 @@ -210,3 +219,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))
Loading