##// END OF EJS Templates
Fix -o
Fix -o

File last commit:

r70:b03a5f77 tip default
r70:b03a5f77 tip default
Show More
main.lisp
164 lines | 5.7 KiB | text/x-common-lisp | CommonLispLexer
100% parser, 100% macros, 50% intrinsics, 10% api, 0% misc
r1
Localization. Renamed to txt2web
r46 (in-package txt2web)
100% parser, 100% macros, 50% intrinsics, 10% api, 0% misc
r1
Build with roswell
r55 (defvar *app-name* "txt2web")
Working Linux build, some CLI improvements
r44
A better UI
r9 (defun entry-point-no-args ()
Localized and neat error reports
r54 (setf *delivered* t)
A better UI
r9 (entry-point uiop:*command-line-arguments*))
(defun entry-point (args)
Localization. Renamed to txt2web
r46 (let ((*package* (find-package :txt2web)))
Working Linux build, some CLI improvements
r44 (catch :terminate
Remove buildapp
r50 (let ((compiler (apply #'make-instance 'compiler (parse-opts args))))
Apply some new changes to libqsp
r61 (if (parse-only compiler)
(let ((*package* (find-package :txt2web.lib)))
(format t "~{~S~^~%~%~}" (reverse (ast compiler))))
(write-compiled-file compiler)))))
A better UI
r9 (values))
Tutorial game works!
r6
(defun parse-opts (args)
Multiple sources, multiple games, openqst/addqst/killqst
r31 (let ((mode :sources)
Apply some new changes to libqsp
r61 (data (list :sources nil :target nil :js nil :css nil :body nil :compile nil :parse nil :beautify nil)))
Tutorial game works!
r6 (loop :for arg :in args
:do (alexandria:switch (arg :test #'string=)
("-o" (setf mode :target))
("--js" (setf mode :js))
("--css" (setf mode :css))
("--body" (setf mode :body))
("-c" (setf (getf data :compile) t))
Apply some new changes to libqsp
r61 ("-p" (setf (getf data :parse) t))
Uglify-js
r8 ("--beautify" (setf (getf data :beautify) t))
Tutorial game works!
r6 (t (push arg (getf data mode)))))
Multiple sources, multiple games, openqst/addqst/killqst
r31 (unless (< 0 (length (getf data :sources)))
(report-error "There should be at least one source"))
Fix -o
r70 (when (> 1 (length (getf data :target)))
Tutorial game works!
r6 (report-error "There should be no more than one target"))
(unless (> 1 (length (getf data :body)))
(report-error "There should be no more than one body"))
(unless (getf data :target)
(setf (getf data :target)
Multiple sources, multiple games, openqst/addqst/killqst
r31 (let* ((sources (first (getf data :sources)))
(tokens (uiop:split-string sources :separator "."))
Tutorial game works!
r6 (target (format nil "~{~A~^.~}.html"
(butlast tokens))))
(list target))))
Multiple sources, multiple games, openqst/addqst/killqst
r31 (list :sources (getf data :sources)
Tutorial game works!
r6 :target (first (getf data :target))
:js (getf data :js)
Apply some new changes to libqsp
r61 :parse (getf data :parse)
Tutorial game works!
r6 :css (getf data :css)
:body (first (getf data :body))
:compile (getf data :compile)
Uglify-js
r8 :beautify (getf data :beautify))))
Tutorial game works!
r6
(defun print-usage ()
Localization. Renamed to txt2web
r46 (lformat t :usage *app-name*))
100% parser, 100% macros, 50% intrinsics, 10% api, 0% misc
r1
(defun parse-file (filename)
Localized and neat error reports
r54 (handler-case
(p:parse 'txt2web-grammar
Change string handling, some debug stuff
r58 (alexandria:read-file-into-string filename :external-format :utf-8))
Localized and neat error reports
r54 (p:esrap-parse-error (e)
(format t "~A~%" e)
Bugfixes
r56 (throw :terminate nil))))
100% parser, 100% macros, 50% intrinsics, 10% api, 0% misc
r1
(defun report-error (fmt &rest args)
Working Linux build, some CLI improvements
r44 (format t "ERROR: ~A~%" (apply #'format nil fmt args))
(print-usage)
100% parser, 100% macros, 50% intrinsics, 10% api, 0% misc
r1 (throw :terminate nil))
Tutorial game works!
r6
;;; JS
Use Parenscript's minifier and obfuscator... and namespaces. SAVES CURRENTLY BROKEN
r25 (defun minify-package (package-designator minify prefix)
(setf (ps:ps-package-prefix package-designator) prefix)
(if minify
(ps:obfuscate-package package-designator)
(ps:unobfuscate-package package-designator)))
A better UI
r9 (defmethod js-sources ((compiler compiler))
Remove cl-uglify-js
r23 (let ((ps:*ps-print-pretty* (beautify compiler)))
Use Parenscript's minifier and obfuscator... and namespaces. SAVES CURRENTLY BROKEN
r25 (cond ((beautify compiler)
Localization. Renamed to txt2web
r46 (minify-package "TXT2WEB.MAIN" nil "qsp_")
(minify-package "TXT2WEB.API" nil "qsp_api_")
(minify-package "TXT2WEB.LIB" nil "qsp_lib_"))
Use Parenscript's minifier and obfuscator... and namespaces. SAVES CURRENTLY BROKEN
r25 (t
Localization. Renamed to txt2web
r46 (minify-package "TXT2WEB.MAIN" t "_")
(minify-package "TXT2WEB.API" t "a_")
(minify-package "TXT2WEB.LIB" t "l_")))
Remove cl-uglify-js
r23 (format nil "~{~A~^~%~%~}" (mapcar #'ps:ps* (reverse (js compiler))))))
Tutorial game works!
r6
;;; CSS
A better UI
r9 (defmethod css-sources ((compiler compiler))
(format nil "~{~A~^~%~%~}" (css compiler)))
Tutorial game works!
r6
;;; HTML
A better UI
r9 (defmethod html-sources ((compiler compiler))
(let ((flute:*escape-html* nil)
(body-template (body compiler))
(js (js-sources compiler))
(css (css-sources compiler)))
(with-output-to-string (out)
(write
Tutorial game works!
r6 (flute:h
(html
(head
txt->qsps, remove FOR and IMG, broken LOCAL and LOOP
r60 (meta :charset "utf-8")
Remove qlot
r52 (title "txt2web"))
Tutorial game works!
r6 (body
A better UI
r9 body-template
Tutorial game works!
r6 (style css)
Remove cl-uglify-js
r23 (script js))))
A better UI
r9 :stream out
:pretty nil))))
Multiple sources, multiple games, openqst/addqst/killqst
r31 (defun filename-game (filename)
(let ((filename (alexandria:lastcar (uiop:split-string filename :separator "/"))))
(format nil "~{~A~^.~}" (butlast (uiop:split-string filename :separator ".")))))
Apply some new changes to libqsp
r61 (defmethod initialize-instance ((compiler compiler) &key sources ((:js js-files)) ((:css css-files)) ((:body body-file)) compile parse &allow-other-keys)
A better UI
r9 (call-next-method)
Apply some new changes to libqsp
r61 (with-slots (ast body css js)
A better UI
r9 compiler
;; Compile the game's JS
Multiple sources, multiple games, openqst/addqst/killqst
r31 (dolist (source sources)
(let ((ps (parse-file source))
(game-name (filename-game source)))
(destructuring-bind (kw &rest locations)
ps
(unless (eq kw 'lib:game)
(report-error "Internal error!"))
(push
`(lib:game (,game-name) ,@locations)
Apply some new changes to libqsp
r61 ast))))
(setf js (append ast js))
A better UI
r9 ;; Does the user need us to do anything else
Apply some new changes to libqsp
r61 (unless (or parse compile)
A better UI
r9 ;; Read in body
(when body-file
(setf body
Change string handling, some debug stuff
r58 (alexandria:read-file-into-string body-file :external-format :utf-8)))
A better UI
r9 ;; Include js files
(dolist (js-file js-files)
(push (format nil "////// Included file ~A~%~A" js-file
Change string handling, some debug stuff
r58 (alexandria:read-file-into-string js-file :external-format :utf-8))
A better UI
r9 js))
;; Include css files
Working Linux build, some CLI improvements
r44 (when css-files
;; User option overrides the default css
(setf css nil)
(dolist (css-file css-files)
(push (format nil "////// Included file ~A~%~A" css-file
Change string handling, some debug stuff
r58 (alexandria:read-file-into-string css-file :external-format :utf-8))
Working Linux build, some CLI improvements
r44 css))))))
A better UI
r9
(defmethod write-compiled-file ((compiler compiler))
(alexandria:write-string-into-file
(if (compile-only compiler)
;; Just the JS
Multiple sources, multiple games, openqst/addqst/killqst
r31 (js-sources compiler)
A better UI
r9 ;; All of it
(html-sources compiler))
(target compiler) :if-exists :supersede))