Show More
@@ -0,0 +1,24 b'' | |||||
|
1 | ||||
|
2 | (defsystem qsp-txt2web | |||
|
3 | :description "QSP compiler to monolithic HTML page" | |||
|
4 | :depends-on (:alexandria :system-locale ;; General | |||
|
5 | :esrap ;; Parsing | |||
|
6 | :parenscript :flute ;; Codegening | |||
|
7 | ) | |||
|
8 | :pathname "src/" | |||
|
9 | :serial t | |||
|
10 | :components ((:file "package") | |||
|
11 | (:file "utils") | |||
|
12 | (:file "l10n") | |||
|
13 | (:file "walker") | |||
|
14 | ||||
|
15 | (:file "patches") | |||
|
16 | (:file "js-syms") | |||
|
17 | (:file "main-macros") | |||
|
18 | (:file "ps-macros") | |||
|
19 | (:file "api-macros") | |||
|
20 | (:file "intrinsic-macros") | |||
|
21 | ||||
|
22 | (:file "class") | |||
|
23 | (:file "main") | |||
|
24 | (:file "parser"))) |
@@ -0,0 +1,19 b'' | |||||
|
1 | ||||
|
2 | (in-package txt2web) | |||
|
3 | ||||
|
4 | (defparameter *languages* (list "en" "ru")) | |||
|
5 | ||||
|
6 | (defparameter *l10n-strings* | |||
|
7 | (mapcan (lambda (lang) | |||
|
8 | (cons (intern (string-upcase lang) :keyword) | |||
|
9 | (read-code-from-string | |||
|
10 | (load-src | |||
|
11 | (concatenate 'string "strings/" lang ".sexp"))))) | |||
|
12 | *languages*)) | |||
|
13 | ||||
|
14 | (defun lformat (target key &rest args) | |||
|
15 | (let* ((lang (intern (string-upcase (first (system-locale:languages))) | |||
|
16 | :keyword)) | |||
|
17 | (strings (or (getf *l10n-strings* lang) | |||
|
18 | (getf *l10n-strings* :en)))) | |||
|
19 | (apply #'format target (getf strings key) args))) |
@@ -0,0 +1,24 b'' | |||||
|
1 | ||||
|
2 | (in-package txt2web) | |||
|
3 | ||||
|
4 | (defun src-file (filename) | |||
|
5 | (uiop/pathname:merge-pathnames* | |||
|
6 | filename | |||
|
7 | (asdf:system-source-directory :txt2web))) | |||
|
8 | ||||
|
9 | (defun read-progn-from-string (string) | |||
|
10 | `(progn | |||
|
11 | ,@(read-code-from-string string))) | |||
|
12 | ||||
|
13 | (defun read-code-from-string (string) | |||
|
14 | (with-input-from-string (in string) | |||
|
15 | (let ((*package* *package*)) | |||
|
16 | (loop :for form := (read in nil :eof) | |||
|
17 | :until (eq form :eof) | |||
|
18 | :when (eq (first form) 'cl:in-package) | |||
|
19 | :do (setf *package* (find-package (second form))) | |||
|
20 | :else | |||
|
21 | :collect form)))) | |||
|
22 | ||||
|
23 | (defun load-src (filename) | |||
|
24 | (alexandria:read-file-into-string (src-file filename))) |
@@ -0,0 +1,12 b'' | |||||
|
1 | (:usage "Usage: ~A <source> [options] | |||
|
2 | Options: | |||
|
3 | -o <filename> - Output filename | |||
|
4 | --js <filenames...> - List of extra .js files to include in the game | |||
|
5 | --css <filenames...> - List of .css files to include in the game. Default is in extras/default.css | |||
|
6 | --body <filename> - Alternative page body. Default is in extras/body.html | |||
|
7 | ||||
|
8 | -c - Just compile the game to a .js file without making it a full web page | |||
|
9 | --beautify - Make the JS content pretty. By default it gets minified. | |||
|
10 | ||||
|
11 | Note that the files in extras/ are not actually used. They're just there for the reference~%") | |||
|
12 |
@@ -0,0 +1,12 b'' | |||||
|
1 | (:usage "Использование: ~A <source> [options] | |||
|
2 | Опции: | |||
|
3 | -o <имя файла> - Имя .html файла для записи скомпилированной игры | |||
|
4 | --js <имена файлов...> - Список дополнительных .js файлов | |||
|
5 | --css <имена файлов...> - Список .css файлов. Стиль по-умолчанию - в файле extras/default.css | |||
|
6 | --body <имя файла> - Альтернативное тело страницы. Тело по-умолчанию - в файле extras/body.html | |||
|
7 | ||||
|
8 | -c - Просто скомпилировать игру в .js файл, не компонуя полную .html страницу | |||
|
9 | --beautify - Не минифицировать .js скрипты | |||
|
10 | ||||
|
11 | Файлы в extras на самом деле компилятором не используются. Используйте только как образец.~%") | |||
|
12 |
@@ -1,18 +1,21 b'' | |||||
1 |
|
1 | |||
2 | BIN = sugar-qsp |
|
2 | BIN = txt2web | |
|
3 | PKG = $(BIN) | |||
|
4 | DIST = txt2web.tar.xz | |||
3 |
|
5 | |||
4 | LISP = sbcl |
|
6 | LISP = sbcl | |
5 |
|
7 | |||
6 | all: $(BIN) |
|
8 | all: $(BIN) | |
7 |
|
9 | |||
|
10 | dist: $(DIST) | |||
|
11 | ||||
8 | graphs: diagrams.png |
|
12 | graphs: diagrams.png | |
9 |
|
13 | |||
10 | $(BIN): src/*.lisp src/*.ps |
|
14 | $(BIN): *.asd src/*.lisp src/*.ps strings/*.sexp | |
11 | buildapp.$(LISP) --asdf-path .\ |
|
15 | buildapp.$(LISP) --asdf-path .\ | |
12 | --asdf-tree .qlot/dists\ |
|
16 | --asdf-tree .qlot/dists\ | |
13 |
--load-system |
|
17 | --load-system $(PKG)\ | |
14 |
--entry |
|
18 | --entry $(PKG):entry-point\ | |
15 | --compress-core\ |
|
|||
16 | --output $(BIN) |
|
19 | --output $(BIN) | |
17 |
|
20 | |||
18 | install-deps: |
|
21 | install-deps: | |
@@ -24,16 +27,20 b' update-deps:' | |||||
24 | %.png: %.dot |
|
27 | %.png: %.dot | |
25 | dot $< -T png -o $@ |
|
28 | dot $< -T png -o $@ | |
26 |
|
29 | |||
27 | dist: $(BIN) |
|
30 | $(DIST): $(BIN) extras/* | |
28 |
tar cfvJ |
|
31 | tar cfvJ $@ $< extras | |
|
32 | ||||
|
33 | upload: $(DIST) | |||
|
34 | curl --upload-file $(DIST) https://transfer.sh/$(DIST) | |||
|
35 | @echo | |||
29 |
|
36 | |||
30 | distclean: clean clean-deps |
|
37 | distclean: clean clean-deps | |
31 |
|
38 | |||
32 | clean: |
|
39 | clean: | |
33 | -rm sugar-qsp |
|
40 | rm -f $(BIN) $(DIST) | |
34 |
|
41 | |||
35 | clean-deps: |
|
42 | clean-deps: | |
36 |
|
|
43 | rm qlfile.lock | |
37 |
|
|
44 | rm -rf .qlot | |
38 |
|
45 | |||
39 | .PHONY: all graphs install-deps update-deps clean |
|
46 | .PHONY: all graphs install-deps update-deps clean upload |
@@ -1,6 +1,6 b'' | |||||
1 | (инструкции на Русском - внизу) |
|
1 | (инструкции на Русском - внизу) | |
2 |
|
2 | |||
3 | # sugar-qsp |
|
3 | # txt2web | |
4 | Compiler for QSP games which creates monolithic HTML pages. |
|
4 | Compiler for QSP games which creates monolithic HTML pages. | |
5 |
|
5 | |||
6 | ## Usage |
|
6 | ## Usage | |
@@ -8,21 +8,21 b' Compiler for QSP games which creates mon' | |||||
8 | There are three mastery levels |
|
8 | There are three mastery levels | |
9 |
|
9 | |||
10 | 1. Just build me the game:<br/> |
|
10 | 1. Just build me the game:<br/> | |
11 |
` |
|
11 | `txt2web game.txt`<br/> | |
12 | And it will create the game in game.html |
|
12 | And it will create the game in game.html | |
13 |
|
13 | |||
14 | 2. I know what I'm doing:<br/> |
|
14 | 2. I know what I'm doing:<br/> | |
15 |
` |
|
15 | `txt2web game.txt -o game.html --body body.html --js jquery.js my-js-library.js --css styles/*.css`<br/> | |
16 | All options are self-explanatory. The result is a monolithic html specified |
|
16 | All options are self-explanatory. The result is a monolithic html specified | |
17 | with the `-o` option. Default `body.html` (used by the first mastery level) can |
|
17 | with the `-o` option. Default `body.html` (used by the first mastery level) can | |
18 | be found in `extas` directory. |
|
18 | be found in `extas` directory. | |
19 |
|
19 | |||
20 | 3. I'm a frontend developer!<br/> |
|
20 | 3. I'm a frontend developer!<br/> | |
21 |
` |
|
21 | `txt2web game.txt -c -o game.js`<br/> | |
22 | It just builds the game script into a js you can put on your website. To run |
|
22 | It just builds the game script into a js you can put on your website. To run | |
23 | the game execute `SugarQSP.start()` |
|
23 | the game execute `SugarQSP.start()` | |
24 |
|
24 | |||
25 | # sugar-qsp |
|
25 | # txt2web | |
26 | Компилятор для игр на QSP создающий монолитные страницы на HTML. |
|
26 | Компилятор для игр на QSP создающий монолитные страницы на HTML. | |
27 |
|
27 | |||
28 | ## Инструкции |
|
28 | ## Инструкции | |
@@ -30,15 +30,15 b' the game execute `SugarQSP.start()`' | |||||
30 | Есть три уровня мастерства. |
|
30 | Есть три уровня мастерства. | |
31 |
|
31 | |||
32 | 1. **Просто собери мне игру**:<br/> |
|
32 | 1. **Просто собери мне игру**:<br/> | |
33 |
` |
|
33 | `txt2web game.txt`<br/> | |
34 | Создаст игру в game.html |
|
34 | Создаст игру в game.html | |
35 |
|
35 | |||
36 | 2. **Я знаю что делаю**:<br/> |
|
36 | 2. **Я знаю что делаю**:<br/> | |
37 |
` |
|
37 | `txt2web game.txt -o game.html --body body.html --js jquery.js my-js-library.js --css styles/*.css`<br/> | |
38 | Если вы знаете что делаете, то для вас смысл опций очевиден. `body.html` и `default.css` |
|
38 | Если вы знаете что делаете, то для вас смысл опций очевиден. `body.html` и `default.css` | |
39 | лежат в каталоге `extras`. |
|
39 | лежат в каталоге `extras`. | |
40 |
|
40 | |||
41 | 3. **Я - фронтендер!**<br/> |
|
41 | 3. **Я - фронтендер!**<br/> | |
42 |
` |
|
42 | `txt2web game.txt -c -o game.js`<br/> | |
43 | Просто соберёт игру в Javascript файл который вы можете разместить на своём |
|
43 | Просто соберёт игру в Javascript файл который вы можете разместить на своём | |
44 | сайте как вам угодно. |
|
44 | сайте как вам угодно. |
@@ -1,4 +1,5 b'' | |||||
1 |
|
1 | |||
|
2 | * Localization | |||
2 | * Save-load game in slots |
|
3 | * Save-load game in slots | |
3 |
|
4 | |||
4 | * CLI build for Windows |
|
5 | * CLI build for Windows | |
@@ -7,6 +8,7 b'' | |||||
7 | * Report duplicate label (in the parser) |
|
8 | * Report duplicate label (in the parser) | |
8 | * reporting error lines at runtime (by storing them in every form in the parser |
|
9 | * reporting error lines at runtime (by storing them in every form in the parser | |
9 | * Report JUMP with missing label (in tagbody) |
|
10 | * Report JUMP with missing label (in tagbody) | |
|
11 | * Localizing parser errors... | |||
10 |
|
12 | |||
11 | * Build Istreblenie |
|
13 | * Build Istreblenie | |
12 | * Build Цветохимия |
|
14 | * Build Цветохимия |
@@ -1,4 +1,5 b'' | |||||
1 | ql alexandria |
|
1 | ql alexandria | |
|
2 | ql system-locale | |||
2 | ql esrap |
|
3 | ql esrap | |
3 | ql parenscript |
|
4 | ql parenscript | |
4 | ql flute |
|
5 | ql flute | |
@@ -8,3 +9,5 b' ql anaphora' | |||||
8 | ql named-readtables |
|
9 | ql named-readtables | |
9 | ql assoc-utils |
|
10 | ql assoc-utils | |
10 | ql let-over-lambda |
|
11 | ql let-over-lambda | |
|
12 | ql documentation-utils | |||
|
13 | ql trivial-indent |
@@ -6,6 +6,10 b'' | |||||
6 | (:class qlot/source/ql:source-ql |
|
6 | (:class qlot/source/ql:source-ql | |
7 | :initargs (:%version :latest) |
|
7 | :initargs (:%version :latest) | |
8 | :version "ql-2020-04-27")) |
|
8 | :version "ql-2020-04-27")) | |
|
9 | ("system-locale" . | |||
|
10 | (:class qlot/source/ql:source-ql | |||
|
11 | :initargs (:%version :latest) | |||
|
12 | :version "ql-2020-04-27")) | |||
9 | ("esrap" . |
|
13 | ("esrap" . | |
10 | (:class qlot/source/ql:source-ql |
|
14 | (:class qlot/source/ql:source-ql | |
11 | :initargs (:%version :latest) |
|
15 | :initargs (:%version :latest) | |
@@ -38,3 +42,11 b'' | |||||
38 | (:class qlot/source/ql:source-ql |
|
42 | (:class qlot/source/ql:source-ql | |
39 | :initargs (:%version :latest) |
|
43 | :initargs (:%version :latest) | |
40 | :version "ql-2020-04-27")) |
|
44 | :version "ql-2020-04-27")) | |
|
45 | ("documentation-utils" . | |||
|
46 | (:class qlot/source/ql:source-ql | |||
|
47 | :initargs (:%version :latest) | |||
|
48 | :version "ql-2020-04-27")) | |||
|
49 | ("trivial-indent" . | |||
|
50 | (:class qlot/source/ql:source-ql | |||
|
51 | :initargs (:%version :latest) | |||
|
52 | :version "ql-2020-04-27")) |
@@ -1,32 +1,14 b'' | |||||
1 |
|
1 | |||
2 | (in-package sugar-qsp) |
|
2 | (in-package sugar-qsp) | |
3 |
|
3 | |||
4 | (eval-when (:compile-toplevel :load-toplevel :execute) |
|
|||
5 | (defun src-file (filename) |
|
|||
6 | (uiop/pathname:merge-pathnames* |
|
|||
7 | filename |
|
|||
8 | (asdf:system-source-directory :sugar-qsp))) |
|
|||
9 | (defun read-code-from-string (string) |
|
|||
10 | (with-input-from-string (in string) |
|
|||
11 | (let ((*package* *package*)) |
|
|||
12 | `(progn |
|
|||
13 | ,@(loop :for form := (read in nil :eof) |
|
|||
14 | :until (eq form :eof) |
|
|||
15 | :when (eq (first form) 'cl:in-package) |
|
|||
16 | :do (setf *package* (find-package (second form))) |
|
|||
17 | :else |
|
|||
18 | :collect form))))) |
|
|||
19 | (defun load-src (filename) |
|
|||
20 | (alexandria:read-file-into-string (src-file filename)))) |
|
|||
21 |
|
||||
22 | (defclass compiler () |
|
4 | (defclass compiler () | |
23 | ((body :accessor body :initform #.(load-src "extras/body.html")) |
|
5 | ((body :accessor body :initform #.(load-src "extras/body.html")) | |
24 | (css :accessor css :initform (list #.(load-src "extras/default.css"))) |
|
6 | (css :accessor css :initform (list #.(load-src "extras/default.css"))) | |
25 | (js :accessor js :initform (reverse |
|
7 | (js :accessor js :initform (reverse | |
26 | (list |
|
8 | (list | |
27 |
'#.(read- |
|
9 | '#.(read-progn-from-string (load-src "src/main.ps")) | |
28 |
'#.(read- |
|
10 | '#.(read-progn-from-string (load-src "src/api.ps")) | |
29 |
'#.(read- |
|
11 | '#.(read-progn-from-string (load-src "src/intrinsics.ps"))))) | |
30 | (compile :accessor compile-only :initarg :compile) |
|
12 | (compile :accessor compile-only :initarg :compile) | |
31 | (target :accessor target :initarg :target) |
|
13 | (target :accessor target :initarg :target) | |
32 | (beautify :accessor beautify :initarg :beautify))) |
|
14 | (beautify :accessor beautify :initarg :beautify))) |
@@ -1,8 +1,8 b'' | |||||
1 |
|
1 | |||
2 |
(in-package |
|
2 | (in-package txt2web.main) | |
3 |
|
3 | |||
4 | (defmacro+ps api-call (name &rest args) |
|
4 | (defmacro+ps api-call (name &rest args) | |
5 |
`(,(intern (string-upcase name) " |
|
5 | `(,(intern (string-upcase name) "TXT2WEB.API") ,@args)) | |
6 |
|
6 | |||
7 | (defpsmacro has (key obj) |
|
7 | (defpsmacro has (key obj) | |
8 | `(chain ,obj (has-own-property ,key))) |
|
8 | `(chain ,obj (has-own-property ,key))) |
@@ -1,5 +1,5 b'' | |||||
1 |
|
1 | |||
2 |
(in-package |
|
2 | (in-package txt2web) | |
3 |
|
3 | |||
4 | (defvar *app-name* "") |
|
4 | (defvar *app-name* "") | |
5 |
|
5 | |||
@@ -8,7 +8,7 b'' | |||||
8 |
|
8 | |||
9 | (defun entry-point (args) |
|
9 | (defun entry-point (args) | |
10 | (setf *app-name* (first args)) |
|
10 | (setf *app-name* (first args)) | |
11 |
(let ((*package* (find-package : |
|
11 | (let ((*package* (find-package :txt2web))) | |
12 | (catch :terminate |
|
12 | (catch :terminate | |
13 | (let ((compiler (apply #'make-instance 'compiler (parse-opts (rest args))))) |
|
13 | (let ((compiler (apply #'make-instance 'compiler (parse-opts (rest args))))) | |
14 | (write-compiled-file compiler)))) |
|
14 | (write-compiled-file compiler)))) | |
@@ -48,20 +48,10 b'' | |||||
48 | :beautify (getf data :beautify)))) |
|
48 | :beautify (getf data :beautify)))) | |
49 |
|
49 | |||
50 | (defun print-usage () |
|
50 | (defun print-usage () | |
51 |
(format t |
|
51 | (lformat t :usage *app-name*)) | |
52 | (format t "Options:~%") |
|
|||
53 | (format t " -o <filename> - Output filename~%") |
|
|||
54 | (format t " --js <filenames...> - List of extra .js files to include in the game~%") |
|
|||
55 | (format t " --css <filenames...> - List of .css files to include in the game. Default is in extras/default.css~%") |
|
|||
56 | (format t " --body <filename> - Alternative page body. Default is in extras/body.html~%") |
|
|||
57 | (format t "~%") |
|
|||
58 | (format t " -c - Just compile the game to a .js file without making it a full web page~%") |
|
|||
59 | (format t " --beautify - Make the JS content pretty. By default it gets minified.~%") |
|
|||
60 | (format t "~%") |
|
|||
61 | (format t "Note that the files in extras/ are not actually used. They're just there for the reference")) |
|
|||
62 |
|
52 | |||
63 | (defun parse-file (filename) |
|
53 | (defun parse-file (filename) | |
64 |
(p:parse ' |
|
54 | (p:parse 'txt2web-grammar | |
65 | (alexandria:read-file-into-string filename))) |
|
55 | (alexandria:read-file-into-string filename))) | |
66 |
|
56 | |||
67 | (defun report-error (fmt &rest args) |
|
57 | (defun report-error (fmt &rest args) | |
@@ -80,13 +70,13 b'' | |||||
80 | (defmethod js-sources ((compiler compiler)) |
|
70 | (defmethod js-sources ((compiler compiler)) | |
81 | (let ((ps:*ps-print-pretty* (beautify compiler))) |
|
71 | (let ((ps:*ps-print-pretty* (beautify compiler))) | |
82 | (cond ((beautify compiler) |
|
72 | (cond ((beautify compiler) | |
83 |
(minify-package " |
|
73 | (minify-package "TXT2WEB.MAIN" nil "qsp_") | |
84 |
(minify-package " |
|
74 | (minify-package "TXT2WEB.API" nil "qsp_api_") | |
85 |
(minify-package " |
|
75 | (minify-package "TXT2WEB.LIB" nil "qsp_lib_")) | |
86 | (t |
|
76 | (t | |
87 |
(minify-package " |
|
77 | (minify-package "TXT2WEB.MAIN" t "_") | |
88 |
(minify-package " |
|
78 | (minify-package "TXT2WEB.API" t "a_") | |
89 |
(minify-package " |
|
79 | (minify-package "TXT2WEB.LIB" t "l_"))) | |
90 | (format nil "~{~A~^~%~%~}" (mapcar #'ps:ps* (reverse (js compiler)))))) |
|
80 | (format nil "~{~A~^~%~%~}" (mapcar #'ps:ps* (reverse (js compiler)))))) | |
91 |
|
81 | |||
92 | ;;; CSS |
|
82 | ;;; CSS |
@@ -1,5 +1,5 b'' | |||||
1 |
|
1 | |||
2 |
(in-package |
|
2 | (in-package txt2web.main) | |
3 |
|
3 | |||
4 | ;;; Game session state (saved in savegames) |
|
4 | ;;; Game session state (saved in savegames) | |
5 | ;; Variables |
|
5 | ;; Variables | |
@@ -37,14 +37,14 b'' | |||||
37 |
|
37 | |||
38 | (setf (@ window onload) |
|
38 | (setf (@ window onload) | |
39 | (lambda () |
|
39 | (lambda () | |
40 |
(#.(intern "INIT-DOM" " |
|
40 | (#.(intern "INIT-DOM" "TXT2WEB.API")) | |
41 | ;; For MSECCOUNT |
|
41 | ;; For MSECCOUNT | |
42 | (setf *started-at (chain *date (now))) |
|
42 | (setf *started-at (chain *date (now))) | |
43 | ;; For $COUNTER and SETTIMER |
|
43 | ;; For $COUNTER and SETTIMER | |
44 |
(#.(intern "SET-TIMER" " |
|
44 | (#.(intern "SET-TIMER" "TXT2WEB.API") | |
45 | *timer-interval) |
|
45 | *timer-interval) | |
46 | ;; Start the first game |
|
46 | ;; Start the first game | |
47 |
(#.(intern "RUN-GAME" " |
|
47 | (#.(intern "RUN-GAME" "TXT2WEB.API") | |
48 | (chain *object (keys *games) 0)) |
|
48 | (chain *object (keys *games) 0)) | |
49 | (values))) |
|
49 | (values))) | |
50 |
|
50 |
@@ -1,10 +1,10 b'' | |||||
1 |
|
1 | |||
2 | (in-package cl-user) |
|
2 | (in-package cl-user) | |
3 |
|
3 | |||
4 |
(defpackage : |
|
4 | (defpackage :txt2web.js) | |
5 |
|
5 | |||
6 |
(defpackage : |
|
6 | (defpackage :txt2web.main | |
7 |
(:use :cl :ps : |
|
7 | (:use :cl :ps :txt2web.js) | |
8 | (:export #:api-call #:by-id |
|
8 | (:export #:api-call #:by-id | |
9 | #:has |
|
9 | #:has | |
10 |
|
10 | |||
@@ -25,8 +25,8 b'' | |||||
25 | #:walk-continue)) |
|
25 | #:walk-continue)) | |
26 |
|
26 | |||
27 | ;;; API functions |
|
27 | ;;; API functions | |
28 |
(defpackage : |
|
28 | (defpackage :txt2web.api | |
29 |
(:use :cl :ps : |
|
29 | (:use :cl :ps :txt2web.main :txt2web.js) | |
30 | (:export #:with-frame #:with-call-args |
|
30 | (:export #:with-frame #:with-call-args | |
31 | #:stash-state |
|
31 | #:stash-state | |
32 |
|
32 | |||
@@ -48,9 +48,9 b'' | |||||
48 | )) |
|
48 | )) | |
49 |
|
49 | |||
50 | ;;; QSP library functions and macros |
|
50 | ;;; QSP library functions and macros | |
51 |
(defpackage : |
|
51 | (defpackage :txt2web.lib | |
52 |
(:use :cl :ps : |
|
52 | (:use :cl :ps :txt2web.main :txt2web.js) | |
53 |
(:local-nicknames (#:api : |
|
53 | (:local-nicknames (#:api :txt2web.api) | |
54 | (#:walker :code-walker)) |
|
54 | (#:walker :code-walker)) | |
55 | (:export #:str #:exec #:qspblock #:qspfor #:game #:location |
|
55 | (:export #:str #:exec #:qspblock #:qspfor #:game #:location | |
56 | #:qspcond #:qspvar #:set #:local #:jump |
|
56 | #:qspcond #:qspvar #:set #:local #:jump | |
@@ -92,17 +92,17 b'' | |||||
92 | #:openqst #:addqst #:killqst |
|
92 | #:openqst #:addqst #:killqst | |
93 | )) |
|
93 | )) | |
94 |
|
94 | |||
95 |
(setf (ps:ps-package-prefix " |
|
95 | (setf (ps:ps-package-prefix "TXT2WEB.MAIN") "qsp_") | |
96 |
(setf (ps:ps-package-prefix " |
|
96 | (setf (ps:ps-package-prefix "TXT2WEB.API") "qsp_api_") | |
97 |
(setf (ps:ps-package-prefix " |
|
97 | (setf (ps:ps-package-prefix "TXT2WEB.LIB") "qsp_lib_") | |
98 |
|
98 | |||
99 | ;;; The compiler |
|
99 | ;;; The compiler | |
100 |
(defpackage : |
|
100 | (defpackage :txt2web | |
101 | (:use :cl) |
|
101 | (:use :cl) | |
102 | (:local-nicknames (#:p #:esrap) |
|
102 | (:local-nicknames (#:p #:esrap) | |
103 |
(#:lib : |
|
103 | (#:lib :txt2web.lib) | |
104 |
(#:api : |
|
104 | (#:api :txt2web.api) | |
105 |
(#:main : |
|
105 | (#:main :txt2web.main) | |
106 | (#:walker :code-walker)) |
|
106 | (#:walker :code-walker)) | |
107 | (:export #:parse-file #:entry-point)) |
|
107 | (:export #:parse-file #:entry-point)) | |
108 |
|
108 |
@@ -1,5 +1,5 b'' | |||||
1 |
|
1 | |||
2 |
(in-package |
|
2 | (in-package txt2web) | |
3 |
|
3 | |||
4 | ;;;; Parses TXT source to an intermediate representation |
|
4 | ;;;; Parses TXT source to an intermediate representation | |
5 |
|
5 | |||
@@ -35,7 +35,7 b'' | |||||
35 | (not (find char " !:&=<>+-*/,'\"()[]{}")))) |
|
35 | (not (find char " !:&=<>+-*/,'\"()[]{}")))) | |
36 |
|
36 | |||
37 | (defun intern-first (list) |
|
37 | (defun intern-first (list) | |
38 |
(list* (intern (string-upcase (first list)) " |
|
38 | (list* (intern (string-upcase (first list)) "TXT2WEB.LIB") | |
39 | (rest list))) |
|
39 | (rest list))) | |
40 |
|
40 | |||
41 | (eval-when (:compile-toplevel :load-toplevel :execute) |
|
41 | (eval-when (:compile-toplevel :load-toplevel :execute) | |
@@ -46,7 +46,7 b'' | |||||
46 | (destructuring-bind (ws1 operator ws2 operand2) |
|
46 | (destructuring-bind (ws1 operator ws2 operand2) | |
47 | list |
|
47 | list | |
48 | (declare (ignore ws1 ws2)) |
|
48 | (declare (ignore ws1 ws2)) | |
49 |
(list (intern (string-upcase operator) " |
|
49 | (list (intern (string-upcase operator) "TXT2WEB.LIB") operand2))) | |
50 |
|
50 | |||
51 | (defun do-binop% (left-op other-ops) |
|
51 | (defun do-binop% (left-op other-ops) | |
52 | (if (null other-ops) |
|
52 | (if (null other-ops) | |
@@ -129,7 +129,7 b'' | |||||
129 | (digit-char-p character))) |
|
129 | (digit-char-p character))) | |
130 | (p:defrule identifier-raw (and id-first (* id-next)) |
|
130 | (p:defrule identifier-raw (and id-first (* id-next)) | |
131 | (:lambda (list) |
|
131 | (:lambda (list) | |
132 |
(intern (string-upcase (p:text list)) " |
|
132 | (intern (string-upcase (p:text list)) "TXT2WEB.LIB"))) | |
133 |
|
133 | |||
134 | (p:defrule identifier (not-qsp-keyword-p identifier-raw)) |
|
134 | (p:defrule identifier (not-qsp-keyword-p identifier-raw)) | |
135 |
|
135 | |||
@@ -176,7 +176,7 b'' | |||||
176 |
|
176 | |||
177 | ;;; Location |
|
177 | ;;; Location | |
178 |
|
178 | |||
179 |
(p:defrule |
|
179 | (p:defrule txt2web-grammar (and (* (or spaces #\newline)) | |
180 | (* location)) |
|
180 | (* location)) | |
181 | (:lambda (list) |
|
181 | (:lambda (list) | |
182 | `(lib:game ,@(second list)))) |
|
182 | `(lib:game ,@(second list)))) | |
@@ -431,7 +431,7 b'' | |||||
431 | (unless (<= ,min-arity (length arguments) ,max-arity) |
|
431 | (unless (<= ,min-arity (length arguments) ,max-arity) | |
432 | (error "Intrinsic ~A expects between ~A and ~A arguments but ~A were provided:~%~S" |
|
432 | (error "Intrinsic ~A expects between ~A and ~A arguments but ~A were provided:~%~S" | |
433 | name ,min-arity ,max-arity (length arguments) arguments)) |
|
433 | name ,min-arity ,max-arity (length arguments) arguments)) | |
434 |
(list* ',(intern (string sym) " |
|
434 | (list* ',(intern (string sym) "TXT2WEB.LIB") arguments)))) | |
435 |
|
435 | |||
436 | (defintrinsics (intrinsic returning-intrinsic non-returning-intrinsic) |
|
436 | (defintrinsics (intrinsic returning-intrinsic non-returning-intrinsic) | |
437 | ;; Transitions |
|
437 | ;; Transitions |
@@ -1,5 +1,5 b'' | |||||
1 |
|
1 | |||
2 |
(in-package |
|
2 | (in-package txt2web.lib) | |
3 |
|
3 | |||
4 | ;;;; Parenscript macros which make the parser's intermediate |
|
4 | ;;;; Parenscript macros which make the parser's intermediate | |
5 | ;;;; representation directly compilable by Parenscript |
|
5 | ;;;; representation directly compilable by Parenscript |
@@ -1,5 +1,5 b'' | |||||
1 |
|
1 | |||
2 |
(in-package |
|
2 | (in-package txt2web) | |
3 |
|
3 | |||
4 | ;;; 1. Generates parenscript source to write to js |
|
4 | ;;; 1. Generates parenscript source to write to js | |
5 | ;;; 2. Collects everything into complete file, leaving a neatly marked |
|
5 | ;;; 2. Collects everything into complete file, leaving a neatly marked |
1 | NO CONTENT: file was removed |
|
NO CONTENT: file was removed |
1 | NO CONTENT: file was removed |
|
NO CONTENT: file was removed |
General Comments 0
You need to be logged in to leave comments.
Login now