seon2js v3.0.4
seon2js
A transpiler from seon to js
See https://github.com/ayamada/seon2js
Usage
cli-seon2js-evaldump.mjs
npx seon2js -e '(console.log 1 2)'To run seon2js code, like node -e '...'
npx seon2js -e '(console.log 1 2)' -dTo dump gcc(google-closure-compiler)-passed js code. Do not run.
npx seon2js -p '1 2 [3 4]'To run and print last value, like node -p '...'
(but this code be warned by gcc)
npx seon2js foo.s2mjsTo run this file, like node ...
But this is experimental!
Not yet supported command line arguments.
You may use this with -d or -t.
If you run certainly, you should transpile and run transpiled file.
See npx seon2js -h for more information.
cli-seon2js-build.mjs
npx seon2js-build --src-dir path/to/src --src-dir more/src --dst-dir path/to/html/mjsTo convert from all *.s2mjs and *.s2js files in --src-dir, to --dst-dir.
See npx seon2js-build -h for more information.
不具合情報
- 現在のところ、
#"..."による正規表現記法内に出現するbackslash文字\は、\\のように二個入力する必要があります- 具体的には
(.split "123\n456" #"\\n")のようにする事になります。これはclojureでの正規表現記法とは異なるので注意が必要です - これは正規表現記法の
#"..."の内部のparse処理が、通常の文字列のtokenizerと共有しているのが原因です - 将来には直す予定ですが、その為にはseonのparserの大幅な改善が必要な為、当面はこの仕様のまま開発を進めます
- 具体的には
分かりづらい用語&一時メモ
r0isr1isとはrevised N implementation of seon2jsの略。要はschemeのRnRS相当- 互換性を大きく捨てて改善する際にNの数値を上げる
- package.seon上のバージョンとの関係性についてはChangeLogを参照 (major versionが一対一でNに対応している訳ではない事に要注意)
seon2jsにおける
transpileとcompileの使い分け- 「seon2jsコードをseon2jsでjsに変換する」 →
transpile - 「(seon2jsの吐き出した)jsコードをgccで変換する」 →
compile
- 「seon2jsコードをseon2jsでjsに変換する」 →
spとはspecial-formの略。lispのそれとほぼ同じ。macroもこれに含まれる- seon2jsはトランスパイラであり、コードの置換以外は基本何も行わないが、このspecial-form関連についてはトランスパイルのタイミングで何かしらの処理を実行する事ができる。もちろんユーザは好きなspを自分で追加できる
spは*.s2spファイルで定義を行い、s2spファイルはsp/import-s2spによって読み込める- このsp定義は基本的にはtranspile時に全て解消し、transpile後のjsコードには残らない。なので通常の関数と大きく区別しやすい見た目の方がよい。
#()形式や名前を全て大文字にする等を色々試したがいまいちで、結局sp/のprefix(専用namespace)をつけて区別するのが一番マシという結論になった。なのでsp定義は基本的に専用namespaceをつけるルールとしている- ただし標準提供しているものについてはあまりに基本機能なもの(例えば
ifとか)が多く、それらについてはsp/ifを提供すると同時にspなしのifも提供している。混乱しない範囲でこれらを使ってもよい(もし混乱するようならnamespace付きで使った方がよい)
- ただし標準提供しているものについてはあまりに基本機能なもの(例えば
s2mjs/s2spで書いたライブラリの追加方法について
seon2js-buildには複数の--src-dir指定ができるので、追加ライブラリの各ファイルの入ったpathを--src-dirで指定すればok- それらは全部
--dst-dir内に出力されるので、importやsp/import-s2spでのpath指定は--dst-dir内での相対pathを指定する必要がある。ちょっとややっこしいが、基本的にはmjsでのモジュールと同じ感覚で扱える - 将来的には
sp/import-s2spでもjs同様に"foo/bar"のdot prefixなし指定の自動resolveをできるようにしたい(importの方はjsレイヤで動くので対応済)
ChangeLog
r1is
An experiment of namespaced special-forms
3.0.4: 20250225
- Bump up version of dependencies
3.0.3: 20241025
- Prevent to terminate watcher process by unhandled rejections
3.0.2: 20240619
- Hotfix a problem of 3.0.1
3.0.1: 20240619
- Fix problems caused by similar multiple
--src-dir - Fix noisy log by delete non- js/mjs/s2js/s2mjs file in watched dir
- Fix problems caused by similar multiple
3.0.0: 20240616
- BREAKING CHANGES: Remove
src/seon2js/gcc.mjsand related codes - Add more options to
npx seon2js-build--bundle-out-file--bundle-entry-point--bundle-extra-args
- Add js reserved words to seon2js.vim
- BREAKING CHANGES: Remove
2.2.1: 20240401
- Mark
sp/stras like a fn for seon2js.vim
- Mark
2.2.0: 20240401
- Refactor and compact special.mjs and sp.s2sp
- Many improvements for seon2js.vim
2.1.1: 20240330
- Fix destructuring-bind like
(const {(sp/??= a 123)} obj)to work
- Fix destructuring-bind like
2.1.0: 20240329
- Add
--srcoption tonpx seon2js-buildthat is alias of--src-dir - Support to target one source file directly
by
--src-diroption innpx seon2js-build - Update version of google-closure-compiler
- Improve
npm run test-builda bit
- Add
2.0.0: 20240315
- Provide
npx seon2jsfor tests and run one-liner - Provide
npx seon2js-buildfor build- Provide many transpile options
- Renew almost special-forms
- Provide tests for almost special-forms
- Renew mangling rules for symbols and keywords
- Provide
ftdetect/seon2js.vimfor vim/neovim- Please add plugin managers of vim/neovim to
"ayamada/seon2js"
- Please add plugin managers of vim/neovim to
- Bump up version of seon to 5.0.0
- Remove
example/game01/now, but may come new example games in future
- Provide
r0is
The initial prototype
0.1.2: 20231226
- Bump up version of seon
- Fix redundant error log
- Fix test by
npm run test-s2js-once
0.1.1: 20231223
- Move chokidar from devDependencies to dependencies for cli
0.1.0: 20231223
- Initial Release
9 months ago
1 year ago
1 year ago
1 year ago
1 year ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago