From 25967d91cd3b02460b1e4e6f0a730a0185087780 Mon Sep 17 00:00:00 2001 From: "Paul A. Patience" Date: Sat, 9 Mar 2024 16:33:09 -0500 Subject: [PATCH] Add package-inferred nyala.asd --- clex.lisp => clex2.lisp | 5 +- .../compiler-warn.lisp => compiler-warn.lisp | 4 +- compiler-warn/compiler-warn.html | 175 ------------------ compiler-warn/compiler-warn.md | 50 ----- compiler-warn/de.bauhh.compiler-warn.asd | 6 - define-grammar.lisp | 15 +- lalr.lisp | 4 +- load.lisp | 34 ---- nyala.asd | 8 + parse2.lisp => nyala.lisp | 16 +- toy-lang.lisp | 2 +- 11 files changed, 31 insertions(+), 288 deletions(-) rename clex.lisp => clex2.lisp (99%) rename compiler-warn/compiler-warn.lisp => compiler-warn.lisp (97%) delete mode 100644 compiler-warn/compiler-warn.html delete mode 100644 compiler-warn/compiler-warn.md delete mode 100644 compiler-warn/de.bauhh.compiler-warn.asd delete mode 100644 load.lisp create mode 100644 nyala.asd rename parse2.lisp => nyala.lisp (95%) diff --git a/clex.lisp b/clex2.lisp similarity index 99% rename from clex.lisp rename to clex2.lisp index 4e88074..000ea47 100644 --- a/clex.lisp +++ b/clex2.lisp @@ -9,8 +9,7 @@ ;; *** NOT FOR REDISTRIBUTION *** -(defpackage :clex2 - (:nicknames :clex-deriv) +(defpackage :nyala/clex2 (:use :common-lisp) (:export #:lexer @@ -46,7 +45,7 @@ ) (:shadow #:step)) -(in-package :clex2) +(in-package :nyala/clex2) (locally (declaim (optimize (speed 3) (safety 1))) diff --git a/compiler-warn/compiler-warn.lisp b/compiler-warn.lisp similarity index 97% rename from compiler-warn/compiler-warn.lisp rename to compiler-warn.lisp index dbc39e1..82b7067 100644 --- a/compiler-warn/compiler-warn.lisp +++ b/compiler-warn.lisp @@ -26,13 +26,13 @@ ;; TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE ;; SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -(defpackage :de.bauhh.compiler-warn +(defpackage :nyala/compiler-warn (:use :common-lisp) (:export #:compiler-warn #:compiler-error #:compiler-descend)) -(in-package :de.bauhh.compiler-warn) +(in-package :nyala/compiler-warn) ;;;; -- Compiler Warnings ----------------------------------------------------- diff --git a/compiler-warn/compiler-warn.html b/compiler-warn/compiler-warn.html deleted file mode 100644 index c43cd71..0000000 --- a/compiler-warn/compiler-warn.html +++ /dev/null @@ -1,175 +0,0 @@ - - - - Compiler Warnings - - - - - - -

- -

Compiler Warnings

- -

In complex macros, that would for instance implement some -domain-specific language, it would be benefitical when the macro could -point to subform in question. The compiler-warn function does allow -you to do that.

- -

Files

- - - -

Dictionary

- -
-
- - - - -
- - - - - -
compiler-warn  form format-control &rest format-arguments
-
Function
- -
-
- - -

Issue a warning about the form form. When possible -implementation specific means are used to point the finger at the -form, so that eventually SLIME or whatever IDE could highlight the -context. When not available or not within the compiler, a normal -warning is issued.

- -

Obviously this does not work if form is an atom.

- -

To narrow down the context you could setup a next best context -with compiler-descend.

- -
-
- - -
-
- - - - -
- - - - - -
compiler-error  form format-control &rest format-arguments
-
Function
- -
-
- - -

Same as compiler-warn, but signals an error.

- -
-
- - -
-
- - - - -
- - - - - -
compiler-descend  form &body body
-
Macro
- -
-
- - -

The compiler-warn function could point the finger at the form -warned about, if it is an atom. A next best (outer) choice could -be given by compiler-descend.

- -
-
- - -
- -

Gilbert Baumann, 2021-02-15

- - - - diff --git a/compiler-warn/compiler-warn.md b/compiler-warn/compiler-warn.md deleted file mode 100644 index e899a1d..0000000 --- a/compiler-warn/compiler-warn.md +++ /dev/null @@ -1,50 +0,0 @@ - - -Compiler Warnings -================= - -In complex macros, that would for instance implement some -domain-specific language, it would be benefitical when the macro could -point to subform in question. The `compiler-warn` function does allow -you to do that. - -Files ------ - -- [`http://clim.rocks/systems/compiler-warn/compiler-warn.tar.gz`](http://clim.rocks/systems/compiler-warn/compiler-warn.tar.gz) -- [`compiler-warn.lisp`](compiler-warn.lisp) -- [`de.bauhh.compiler-warn.asd`](de.bauhh.compiler-warn.asd) - -Dictionary ----------- - --------------------------------------------------------------------------- -compiler-warn form format-control &rest format-arguments [Function] - - Issue a warning about the form _form_. When possible - implementation specific means are used to point the finger at the - form, so that eventually SLIME or whatever IDE could highlight the - context. When not available or not within the compiler, a normal - warning is issued. - - Obviously this does not work if _form_ is an atom. - - To narrow down the context you could setup a next best context - with `compiler-descend`. - --------------------------------------------------------------------------- -compiler-error form format-control &rest format-arguments [Function] - - Same as `compiler-warn`, but signals an error. - --------------------------------------------------------------------------- -compiler-descend form &body body [Macro] - - The `compiler-warn` function could point the finger at the form - warned about, if it is an atom. A next best (outer) choice could - be given by `compiler-descend`. - -------------------------------------------------------------------------------- -Gilbert Baumann, 2021-02-15 diff --git a/compiler-warn/de.bauhh.compiler-warn.asd b/compiler-warn/de.bauhh.compiler-warn.asd deleted file mode 100644 index 7ab5b87..0000000 --- a/compiler-warn/de.bauhh.compiler-warn.asd +++ /dev/null @@ -1,6 +0,0 @@ -(in-package :asdf) - -(defsystem :de.bauhh.compiler-warn - :depends-on () - :serial t - :components ((:file "compiler-warn"))) diff --git a/define-grammar.lisp b/define-grammar.lisp index 742f1aa..c2f4b4a 100644 --- a/define-grammar.lisp +++ b/define-grammar.lisp @@ -1,8 +1,9 @@ -(defpackage :de.bauhh.define-grammar - (:use :cl :de.bauhh.lalr) +(defpackage :nyala/define-grammar + (:use :cl :nyala/lalr) + (:import-from #:nyala/compiler-warn) (:shadow #:define-grammar)) -(in-package :de.bauhh.define-grammar) +(in-package :nyala/define-grammar) ;;;; Overview @@ -169,7 +170,7 @@ (warn "Undefined categories: ~<~@{~S~^, ~:_~}~:>" undefined)))))) (defun grammar-lalr-table (terminals rules) - (de.bauhh.lalr::grammar-lalr-table + (nyala/lalr::grammar-lalr-table terminals (mapcar (lambda (rule) (cond ((member (car rule) '(:precedence)) rule) @@ -225,7 +226,7 @@ (memo (make-hash-table :test #'equal)) (tokens nil)) ;A-list of token keywords (labels ((edit-rule (rule) - (de.bauhh.compiler-warn:compiler-descend rule + (nyala/compiler-warn:compiler-descend rule (loop for (lhs rhs . actions) in (reverse (parse-rule rule)) do (edit-rule-1 lhs rhs actions)))) ;; @@ -351,7 +352,7 @@ (edit-rhs-items rule-name (cons `(? (++ ,@(cdr item))) (cdr items)) body n map yet ps bs)) ;; (t - (de.bauhh.compiler-warn:compiler-warn item "Bad rhs item - ~S" item)))))))) + (nyala/compiler-warn:compiler-warn item "Bad rhs item - ~S" item)))))))) ;; (parse-item-macro (whole args) (when (or (> (count '=> args :test #'symbol=) 1) @@ -417,7 +418,7 @@ ;; a list of ( . ) (labels ((blame (p what) (declare (ignore p)) - (de.bauhh.compiler-warn:compiler-error + (nyala/compiler-warn:compiler-error rule "~@" rule what))) (let ((p (position '-> rule :test #'symbol=))) diff --git a/lalr.lisp b/lalr.lisp index 6090ad1..f473adf 100644 --- a/lalr.lisp +++ b/lalr.lisp @@ -73,7 +73,7 @@ ;; --Gilbert Baumann -(defpackage :de.bauhh.lalr +(defpackage :nyala/lalr (:use :cl) (:export #:make-parser ;This is there for olde PARSE macro --- which needs to go away #:define-grammar ;This should go away with time too. @@ -101,7 +101,7 @@ #:make-shift-action #:shift-action-p)) -(in-package :de.bauhh.lalr) +(in-package :nyala/lalr) (eval-when (:compile-toplevel) (declaim (optimize (speed 1) (safety 3)))) diff --git a/load.lisp b/load.lisp deleted file mode 100644 index e5eae27..0000000 --- a/load.lisp +++ /dev/null @@ -1,34 +0,0 @@ -(in-package :cl-user) - -;; (require :clex2) - -(setf (logical-pathname-translations "parse") - `(("**;*.*.*" ,(merge-pathnames (make-pathname - :directory '(:relative :wild-inferiors) - :name :wild - :type :wild - :version :wild) - *load-truename*)))) - -(eval-when (:load-toplevel :execute) - (require :de.bauhh.compiler-warn)) - -(defun load-parse () - (let ((*load-verbose* t) (*load-print* nil) - (*compile-verbose* t) (*compile-print* nil)) - (let ((compiling-p nil)) - (labels - ((compile-and-load (pathname) - (load (or (when (or compiling-p - (not (probe-file (compile-file-pathname pathname))) - (> (file-write-date pathname) - (file-write-date (compile-file-pathname pathname)))) - (setq compiling-p t) - (compile-file pathname)) - (compile-file-pathname pathname))))) - (mapc #'compile-and-load - '("parse:lalr.lisp" - "parse:define-grammar.lisp" - "parse:parse2.lisp"))))) ) - -(load-parse) diff --git a/nyala.asd b/nyala.asd new file mode 100644 index 0000000..2cc5f84 --- /dev/null +++ b/nyala.asd @@ -0,0 +1,8 @@ +(defsystem "nyala" + :version "0.1.0" + :description "Parsing framework" + :author "Gilbert Baumann" + :mailto "gilbert@bauhh.de" + :license "MIT (Expat)" + :class :package-inferred-system + :depends-on ("nyala/nyala")) diff --git a/parse2.lisp b/nyala.lisp similarity index 95% rename from parse2.lisp rename to nyala.lisp index 22146d2..5d60359 100644 --- a/parse2.lisp +++ b/nyala.lisp @@ -28,12 +28,12 @@ (in-package :cl-user) -(defpackage :parse2 - (:use :clex-deriv :de.bauhh.lalr :cl) - (:shadowing-import-from #:de.bauhh.define-grammar #:define-grammar +(defpackage :nyala + (:use :nyala/clex2 :nyala/lalr :cl) + (:shadowing-import-from #:nyala/define-grammar #:define-grammar #:FANCY-LALR-TABLE) - (:import-from #:de.bauhh.define-grammar #:compile-define-grammar-1) - (:import-from #:de.bauhh.lalr + (:import-from #:nyala/define-grammar #:compile-define-grammar-1) + (:import-from #:nyala/lalr #:shift-action #:shift-action-p #:shift-action-goto @@ -44,7 +44,7 @@ #:*TOPCAT*) ;Hmm (:export #:parse) ) -(in-package :parse2) +(in-package :nyala) ;;;; -- TODO ---------------------------------------------------------------------------------- @@ -124,7 +124,7 @@ (and (cdr token) (destructuring-bind (cat . text) token (cond ((and no-auto-token-pattern - (clex2:scan no-auto-token-pattern text :anchored t)) + (nyala/clex2:scan no-auto-token-pattern text :anchored t)) ;; (warn "No automatic rule for ~S" token) nil) (t @@ -179,7 +179,7 @@ (and (cdr token) (destructuring-bind (cat . text) token (cond ((and no-auto-token-pattern - (clex2:scan no-auto-token-pattern text :anchored t)) + (nyala/clex2:scan no-auto-token-pattern text :anchored t)) ;; (warn "No automatic rule for ~S" token) nil) (t diff --git a/toy-lang.lisp b/toy-lang.lisp index efcee5e..be47291 100644 --- a/toy-lang.lisp +++ b/toy-lang.lisp @@ -1,5 +1,5 @@ (defpackage :toy-lang - (:use :cl :clex2 :parse2)) + (:use :cl :nyala/clex2 :nyala)) (in-package :toy-lang) -- 2.41.0