Plaster
New
List
Login
text
default
anonymous
2024.03.09 21:36:53
From 25967d91cd3b02460b1e4e6f0a730a0185087780 Mon Sep 17 00:00:00 2001 From: "Paul A. Patience" <paul@apatience.com> 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 @@ -<!DOCTYPE HTML> -<html lang=en> - <head> - <title>Compiler Warnings</title> - <META HTTP-EQUIV='Content-Type' CONTENT='text/html; charset=utf-8' /> -<link href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:400,400i,700" rel="stylesheet"> -<script type="text/javascript" async - src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML"> -</script> -<style> -H1, H2, H3, H4, H5, H6 { font-family: sans-serif; color: #622; } -BODY { margin: 2em 4em 2em 6em; line-height: 1.5; } -PRE { margin-left: 2em; } -.kind { float: right; font-style: italic; font-weight: normal; } -.kind:before { content: '['; font-style: normal; display: inline; } -.kind:after { content: ']'; font-style: normal; display: inline; } -.change { - border-left: 1px solid black; - padding-left: 2em; - margin-left: -2em; -} -.change:before { float: left; content: 'GB'; margin-left: -4em; } -TT, CODE, PRE { - xfont-size: 110%; -} -DT TT:first-child { font-weight: bold; } -P { text-align: justify; } -.lispcomment { font-style: italic; color: #800; } -.lispdefined { font-weight: bold; } -.lispstring { color: #080; } -.body { margin-left: 2em; } -.defun { border-top: 1px solid #622; padding-top: 1ex; margin-top: 2em; margin-bottom: 2em; } -/* PRE {font-size: smaller; } */ -@media print { - BODY, TABLE { font-size: 10pt; font-family: Georgia, sans-serif; } -} - -PRE { padding: 1em 2em; background: #eee;} - -BODY.dark { color: white; background: black; background: rgb(26, 49, 41); } -.dark A:link, .dark A:visited { color: orange; text-decoration: none; } -.dark H1, .dark H2, .dark H3, .dark H4, .dark H5, .dark H6 { color: #619b73; } -.lispcomment { color: #d07813; } -.dark .lispstring { color: orange; } -.dark PRE { background: rgb(26, 49, 41); color: white; } - -.dark .defun { border-top: 1px solid white; } - -.defun { padding-top: 0.5ex; margin-top: 2em; margin-bottom: 2em; } - -.overline { text-decoration: overline; } - -SUB { font-size: 66%; } - -BODY { font-family: 'Source Sans Pro', sans-serif; } - -BODY { margin: 2em 3em 2em 3em; line-height: 1.33; } - -</style> - </head> - <body> - <p><style> -BODY,TABLE {font-size:11pt;} -</style></p> - -<h1>Compiler Warnings</h1> - -<p>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 <code>compiler-warn</code> function does allow -you to do that.</p> - -<h2>Files</h2> - -<ul> -<li><a href="http://clim.rocks/systems/compiler-warn/compiler-warn.tar.gz"><code>http://clim.rocks/systems/compiler-warn/compiler-warn.tar.gz</code></a></li> -<li><a href="compiler-warn.lisp"><code>compiler-warn.lisp</code></a></li> -<li><a href="de.bauhh.compiler-warn.asd"><code>de.bauhh.compiler-warn.asd</code></a></li> -</ul> - -<h2>Dictionary</h2> - -<div class='defun'> -<div class='signature'> -<table border=0 width='100%' cellpadding=0 cellspacing=0> -<tr> -<td valign=baseline> -<table border=0 cellpadding=0 cellspacing=0> - <tr> - <td valign=baseline nowrap><code>compiler-warn</code> </td> - <td valign=baseline nowrap colspan=1><i> form format-control </i><code>&rest</code><i> format-arguments</i></td> - </tr> -</table> -<td align=right valign=baseline><i>Function</i></td> -</tr> -</table> - -</div> -<div class=body> - - -<p>Issue a warning about the form <em>form</em>. 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.</p> - -<p>Obviously this does not work if <em>form</em> is an atom.</p> - -<p>To narrow down the context you could setup a next best context -with <code>compiler-descend</code>.</p> - -</div> -</div> - - -<div class='defun'> -<div class='signature'> -<table border=0 width='100%' cellpadding=0 cellspacing=0> -<tr> -<td valign=baseline> -<table border=0 cellpadding=0 cellspacing=0> - <tr> - <td valign=baseline nowrap><code>compiler-error</code> </td> - <td valign=baseline nowrap colspan=1><i> form format-control </i><code>&rest</code><i> format-arguments</i></td> - </tr> -</table> -<td align=right valign=baseline><i>Function</i></td> -</tr> -</table> - -</div> -<div class=body> - - -<p>Same as <code>compiler-warn</code>, but signals an error.</p> - -</div> -</div> - - -<div class='defun'> -<div class='signature'> -<table border=0 width='100%' cellpadding=0 cellspacing=0> -<tr> -<td valign=baseline> -<table border=0 cellpadding=0 cellspacing=0> - <tr> - <td valign=baseline nowrap><code>compiler-descend</code> </td> - <td valign=baseline nowrap colspan=1><i> form </i><code>&body</code><i> body</i></td> - </tr> -</table> -<td align=right valign=baseline><i>Macro</i></td> -</tr> -</table> - -</div> -<div class=body> - - -<p>The <code>compiler-warn</code> function could point the finger at the form -warned about, if it is an atom. A next best (outer) choice could -be given by <code>compiler-descend</code>.</p> - -</div> -</div> - - -<hr /> - -<p>Gilbert Baumann, 2021-02-15</p> - - </body> -</html> - 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 @@ -<style> -BODY,TABLE {font-size:11pt;} -</style> - -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 (<lhs> <rhs> . <body>) (labels ((blame (p what) (declare (ignore p)) - (de.bauhh.compiler-warn:compiler-error + (nyala/compiler-warn:compiler-error rule "~@<Bad rule: ~S; ~_~A~:>" 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
Raw
Annotate
Repaste
Edit