diff --git a/Makefile b/Makefile
--- a/Makefile
+++ b/Makefile
@@ -1,18 +1,21 @@
-BIN = sugar-qsp
+BIN = txt2web
+PKG = $(BIN)
+DIST = txt2web.tar.xz
LISP = sbcl
all: $(BIN)
+dist: $(DIST)
+
graphs: diagrams.png
-$(BIN): src/*.lisp src/*.ps
+$(BIN): *.asd src/*.lisp src/*.ps strings/*.sexp
buildapp.$(LISP) --asdf-path .\
--asdf-tree .qlot/dists\
- --load-system sugar-qsp\
- --entry sugar-qsp:entry-point\
- --compress-core\
+ --load-system $(PKG)\
+ --entry $(PKG):entry-point\
--output $(BIN)
install-deps:
@@ -24,16 +27,20 @@ update-deps:
%.png: %.dot
dot $< -T png -o $@
-dist: $(BIN)
- tar cfvJ sugar-qsp.tar.xz $(BIN) extras
+$(DIST): $(BIN) extras/*
+ tar cfvJ $@ $< extras
+
+upload: $(DIST)
+ curl --upload-file $(DIST) https://transfer.sh/$(DIST)
+ @echo
distclean: clean clean-deps
clean:
- -rm sugar-qsp
+ rm -f $(BIN) $(DIST)
clean-deps:
- -rm qlfile.lock
- -rm -rf .qlot
+ rm qlfile.lock
+ rm -rf .qlot
-.PHONY: all graphs install-deps update-deps clean
+.PHONY: all graphs install-deps update-deps clean upload
diff --git a/README.md b/README.md
--- a/README.md
+++ b/README.md
@@ -1,6 +1,6 @@
(инструкции на Русском - внизу)
-# sugar-qsp
+# txt2web
Compiler for QSP games which creates monolithic HTML pages.
## Usage
@@ -8,21 +8,21 @@ Compiler for QSP games which creates mon
There are three mastery levels
1. Just build me the game:
-`sugar-qsp game.txt`
+`txt2web game.txt`
And it will create the game in game.html
2. I know what I'm doing:
-`sugar-qsp game.txt -o game.html --body body.html --js jquery.js my-js-library.js --css styles/*.css`
+`txt2web game.txt -o game.html --body body.html --js jquery.js my-js-library.js --css styles/*.css`
All options are self-explanatory. The result is a monolithic html specified
with the `-o` option. Default `body.html` (used by the first mastery level) can
be found in `extas` directory.
3. I'm a frontend developer!
-`sugar-qsp game.txt -c -o game.js`
+`txt2web game.txt -c -o game.js`
It just builds the game script into a js you can put on your website. To run
the game execute `SugarQSP.start()`
-# sugar-qsp
+# txt2web
Компилятор для игр на QSP создающий монолитные страницы на HTML.
## Инструкции
@@ -30,15 +30,15 @@ the game execute `SugarQSP.start()`
Есть три уровня мастерства.
1. **Просто собери мне игру**:
-`sugar-qsp game.txt`
+`txt2web game.txt`
Создаст игру в game.html
2. **Я знаю что делаю**:
-`sugar-qsp game.txt -o game.html --body body.html --js jquery.js my-js-library.js --css styles/*.css`
+`txt2web game.txt -o game.html --body body.html --js jquery.js my-js-library.js --css styles/*.css`
Если вы знаете что делаете, то для вас смысл опций очевиден. `body.html` и `default.css`
лежат в каталоге `extras`.
3. **Я - фронтендер!**
-`sugar-qsp game.txt -c -o game.js`
+`txt2web game.txt -c -o game.js`
Просто соберёт игру в Javascript файл который вы можете разместить на своём
сайте как вам угодно.
diff --git a/TODO b/TODO
--- a/TODO
+++ b/TODO
@@ -1,4 +1,5 @@
+* Localization
* Save-load game in slots
* CLI build for Windows
@@ -7,6 +8,7 @@
* Report duplicate label (in the parser)
* reporting error lines at runtime (by storing them in every form in the parser
* Report JUMP with missing label (in tagbody)
+* Localizing parser errors...
* Build Istreblenie
* Build Цветохимия
diff --git a/qlfile b/qlfile
--- a/qlfile
+++ b/qlfile
@@ -1,4 +1,5 @@
ql alexandria
+ql system-locale
ql esrap
ql parenscript
ql flute
@@ -8,3 +9,5 @@ ql anaphora
ql named-readtables
ql assoc-utils
ql let-over-lambda
+ql documentation-utils
+ql trivial-indent
diff --git a/qlfile.lock b/qlfile.lock
--- a/qlfile.lock
+++ b/qlfile.lock
@@ -6,6 +6,10 @@
(:class qlot/source/ql:source-ql
:initargs (:%version :latest)
:version "ql-2020-04-27"))
+("system-locale" .
+ (:class qlot/source/ql:source-ql
+ :initargs (:%version :latest)
+ :version "ql-2020-04-27"))
("esrap" .
(:class qlot/source/ql:source-ql
:initargs (:%version :latest)
@@ -38,3 +42,11 @@
(:class qlot/source/ql:source-ql
:initargs (:%version :latest)
:version "ql-2020-04-27"))
+("documentation-utils" .
+ (:class qlot/source/ql:source-ql
+ :initargs (:%version :latest)
+ :version "ql-2020-04-27"))
+("trivial-indent" .
+ (:class qlot/source/ql:source-ql
+ :initargs (:%version :latest)
+ :version "ql-2020-04-27"))
diff --git a/qsp-txt2web.asd b/qsp-txt2web.asd
new file mode 100644
--- /dev/null
+++ b/qsp-txt2web.asd
@@ -0,0 +1,24 @@
+
+(defsystem qsp-txt2web
+ :description "QSP compiler to monolithic HTML page"
+ :depends-on (:alexandria :system-locale ;; General
+ :esrap ;; Parsing
+ :parenscript :flute ;; Codegening
+ )
+ :pathname "src/"
+ :serial t
+ :components ((:file "package")
+ (:file "utils")
+ (:file "l10n")
+ (:file "walker")
+
+ (:file "patches")
+ (:file "js-syms")
+ (:file "main-macros")
+ (:file "ps-macros")
+ (:file "api-macros")
+ (:file "intrinsic-macros")
+
+ (:file "class")
+ (:file "main")
+ (:file "parser")))
diff --git a/src/class.lisp b/src/class.lisp
--- a/src/class.lisp
+++ b/src/class.lisp
@@ -1,32 +1,14 @@
(in-package sugar-qsp)
-(eval-when (:compile-toplevel :load-toplevel :execute)
- (defun src-file (filename)
- (uiop/pathname:merge-pathnames*
- filename
- (asdf:system-source-directory :sugar-qsp)))
- (defun read-code-from-string (string)
- (with-input-from-string (in string)
- (let ((*package* *package*))
- `(progn
- ,@(loop :for form := (read in nil :eof)
- :until (eq form :eof)
- :when (eq (first form) 'cl:in-package)
- :do (setf *package* (find-package (second form)))
- :else
- :collect form)))))
- (defun load-src (filename)
- (alexandria:read-file-into-string (src-file filename))))
-
(defclass compiler ()
((body :accessor body :initform #.(load-src "extras/body.html"))
(css :accessor css :initform (list #.(load-src "extras/default.css")))
(js :accessor js :initform (reverse
(list
- '#.(read-code-from-string (load-src "src/main.ps"))
- '#.(read-code-from-string (load-src "src/api.ps"))
- '#.(read-code-from-string (load-src "src/intrinsics.ps")))))
+ '#.(read-progn-from-string (load-src "src/main.ps"))
+ '#.(read-progn-from-string (load-src "src/api.ps"))
+ '#.(read-progn-from-string (load-src "src/intrinsics.ps")))))
(compile :accessor compile-only :initarg :compile)
(target :accessor target :initarg :target)
(beautify :accessor beautify :initarg :beautify)))
diff --git a/src/l10n.lisp b/src/l10n.lisp
new file mode 100644
--- /dev/null
+++ b/src/l10n.lisp
@@ -0,0 +1,19 @@
+
+(in-package txt2web)
+
+(defparameter *languages* (list "en" "ru"))
+
+(defparameter *l10n-strings*
+ (mapcan (lambda (lang)
+ (cons (intern (string-upcase lang) :keyword)
+ (read-code-from-string
+ (load-src
+ (concatenate 'string "strings/" lang ".sexp")))))
+ *languages*))
+
+(defun lformat (target key &rest args)
+ (let* ((lang (intern (string-upcase (first (system-locale:languages)))
+ :keyword))
+ (strings (or (getf *l10n-strings* lang)
+ (getf *l10n-strings* :en))))
+ (apply #'format target (getf strings key) args)))
diff --git a/src/main-macros.lisp b/src/main-macros.lisp
--- a/src/main-macros.lisp
+++ b/src/main-macros.lisp
@@ -1,8 +1,8 @@
-(in-package sugar-qsp.main)
+(in-package txt2web.main)
(defmacro+ps api-call (name &rest args)
- `(,(intern (string-upcase name) "SUGAR-QSP.API") ,@args))
+ `(,(intern (string-upcase name) "TXT2WEB.API") ,@args))
(defpsmacro has (key obj)
`(chain ,obj (has-own-property ,key)))
diff --git a/src/main.lisp b/src/main.lisp
--- a/src/main.lisp
+++ b/src/main.lisp
@@ -1,5 +1,5 @@
-(in-package sugar-qsp)
+(in-package txt2web)
(defvar *app-name* "")
@@ -8,7 +8,7 @@
(defun entry-point (args)
(setf *app-name* (first args))
- (let ((*package* (find-package :sugar-qsp)))
+ (let ((*package* (find-package :txt2web)))
(catch :terminate
(let ((compiler (apply #'make-instance 'compiler (parse-opts (rest args)))))
(write-compiled-file compiler))))
@@ -48,20 +48,10 @@
:beautify (getf data :beautify))))
(defun print-usage ()
- (format t "Usage: ~A