aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArun Isaac2022-01-12 14:56:37 +0530
committerArun Isaac2022-01-16 00:55:06 +0530
commit9da6d01e36b6cfa6e171dd4c778ab3687d766ed3 (patch)
treeb518b2c8d001a7ce27ff224f7ee72550038635c5
parentfa8fad2f03c3c16b67d2c44da0ff8eed10b9b926 (diff)
downloadccwl-9da6d01e36b6cfa6e171dd4c778ab3687d766ed3.tar.gz
ccwl-9da6d01e36b6cfa6e171dd4c778ab3687d766ed3.tar.lz
ccwl-9da6d01e36b6cfa6e171dd4c778ab3687d766ed3.zip
ccwl: Add conditions.
We introduce the &ccwl-violation condition. In later commits, it will be used to indicate ccwl syntax violations and to print out useful compiler errors. * ccwl/conditions.scm: New file.
-rw-r--r--ccwl/conditions.scm39
1 files changed, 39 insertions, 0 deletions
diff --git a/ccwl/conditions.scm b/ccwl/conditions.scm
new file mode 100644
index 0000000..756b46b
--- /dev/null
+++ b/ccwl/conditions.scm
@@ -0,0 +1,39 @@
+;;; ccwl --- Concise Common Workflow Language
+;;; Copyright © 2022 Arun Isaac <arunisaac@systemreboot.net>
+;;;
+;;; This file is part of ccwl.
+;;;
+;;; ccwl is free software: you can redistribute it and/or modify it
+;;; under the terms of the GNU General Public License as published by
+;;; the Free Software Foundation, either version 3 of the License, or
+;;; (at your option) any later version.
+;;;
+;;; ccwl is distributed in the hope that it will be useful, but
+;;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+;;; General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU General Public License
+;;; along with ccwl. If not, see <https://www.gnu.org/licenses/>.
+
+(define-module (ccwl conditions)
+ #:use-module (rnrs conditions)
+ #:use-module (srfi srfi-28)
+ #:export (ccwl-violation
+ ccwl-violation?
+ ccwl-violation-file
+ ccwl-violation-line
+ ccwl-violation-column))
+
+(define-condition-type &ccwl-violation &violation
+ make-ccwl-violation ccwl-violation?
+ (file ccwl-violation-file)
+ (line ccwl-violation-line)
+ (column ccwl-violation-column))
+
+(define (ccwl-violation x)
+ "Return &ccwl-violation condition for syntax X."
+ (let ((properties (syntax-source x)))
+ (make-ccwl-violation (assq-ref properties 'filename)
+ (assq-ref properties 'line)
+ (assq-ref properties 'column))))