Qiitan-go

module
v0.0.0-beta2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 13, 2022 License: MIT

README

platform icon homebrew icon MIT license

Qiitan-goalpha

キーたん語(Qiitan-go)は、キーたん(Qiitan) ファンの、Qiitan ファンによる、Qiitan ファンのための「お遊び用スクリプト言語」です。


キーたん(Qiitan)は、Qiita™️ の SNS である「Qiitadonβ」のマスコット・キャラクターです。

  • キーたん(Qiitan) @ Qiitadon
  • Qiitan-go は Qiitan のファン・アプリであり、Qiita™️ とは一切関係がありません。

qiitan スクリプトの Hello World

スクリプトと実行例
  • スクリプト例(./helloworld.qiitan
    foo := import("fmt")
    foo.println("Hello World!")
    
    • この qiitan スクリプトは、標準モジュール(qiitan インタプリタに同梱されているライブラリ)から fmt モジュールを foo に代入し、その fmt モジュール内で定義されている println 関数(改行付き print 関数)を呼び出して標準出力に出力しています。
  • 実行例
    $ qiitan ./helloworld.qiitan
    Hello World!
    
対話モード(REPL)での実行例
$ # 対話モード(REPL)で実行
$ qiitan
Welcome to Qiitan Script Interactive Mode! (To exit just type `bye`)
> foo := import("fmt")
LOG: {__module_name__: "fmt", print: <user-function>, printf: <user-function>, println: <user-function>, sprintf: <user-function>}
> foo.println("Hello World!")
Hello World!
LOG: <undefined> object returned. Perhaps the statement has no return or nothing is assigned to it.
>
> bye
Nice chatting with you. Thank you! Bye-bye~.
$
上記の簡易説明

対話モードでは、出力した内容および代入した内容が適宜表示されます。

例えば、foo := import("fmt")foo 変数に fmt モジュールを代入した場合、続く LOG: の内容から、foo 変数には fmt モジュールの中身である print(), printf(), println(), sprintf() の関数が定義されていることが確認できます。

> foo := import("fmt")
LOG: {__module_name__: "fmt", print: <user-function>, printf: <user-function>, println: <user-function>, sprintf: <user-function>}

次に foo.println("Hello World!") で標準出力に "Hello World!" を出力していますが、続く LOG: <undefined> object returned は、fmt.println() に戻り値がなかった(型がない値が返ってきた)ことを表しています。

> foo.println("Hello World!")
Hello World!
LOG: <undefined> object returned. Perhaps the statement has no return or nothing is assigned to it.

これは、qiitan スクリプトでは return のない関数は <undefined> オブジェクト(型がないことを示すオブジェクト)が自動的に返されるためです。


プリ・コンパイルと実行

キーたん語は、なんちゃってプリ・コンパイル型の言語です。

qiitan スクリプトの実行だけでなく、その中間ファイル(バイトコード)を出力することができます。 この中間ファイルも qiitan インタプリタで実行することができ、プリ・コンパイルが不要なぶんだけ速く実行されます。

$ qiitan -compile ./helloworld.qiitan
compiled: ./helloworld.qtn

$ qiitan ./helloworld.qtn
Hello World!

リソース


Install

  • Homebrew (macOS: x86_64/Intel/AMD64, M1/ARM64, Linux & Windows WSL2: x86_64, ARM64, ARM v6)

    brew install qithub-bot/apps/qiitan
    
  • 単体バイナリ(Windows, macOS, Linux)


Statuses

このリポジトリでは、以下のような最低限のセキュリティ対策が施されています。

Platform Tests golangci-lint CodeQL codecov Go Report Card


言語拡張開発(コントリビュート)

Go Reference

  • qiitan コマンド(インタプリタ)自体は Go 言語で開発されています。
  • qiitan コマンド(インタプリタ)は、スタンドアロン(単体)のバイナリとして動作するように設計されています。
  • CONTRIBUTING

License

謝辞
  • qiitan スクリプトは Tengo 言語をベースに拡張した上位互換言語です。
  • qiitan インタプリタは、以下の Go モジュールにお世話になっています。

Directories

Path Synopsis
Package main は qiitan インタプリタの本体 Golang パッケージです。
Package main は qiitan インタプリタの本体 Golang パッケージです。
gen
qiitan
compiler
Package compiler はスクリプト・ファイルからバイトコード(中間ファイル)の生成 および tengo VM 上での実行を行うパッケージです。
Package compiler はスクリプト・ファイルからバイトコード(中間ファイル)の生成 および tengo VM 上での実行を行うパッケージです。
modules
Code generated using genscrmods.go; DO NOT EDIT.
Code generated using genscrmods.go; DO NOT EDIT.
modules/coremods
Package coremods は「Tengo 言語の標準モジュール」`stdlib.BuiltinModules` および `stdlib.SourceModules`を、キーたん語のコア・モジュールとして組み込みます。
Package coremods は「Tengo 言語の標準モジュール」`stdlib.BuiltinModules` および `stdlib.SourceModules`を、キーたん語のコア・モジュールとして組み込みます。
modules/gomods
Package gomods は Go 言語による、キーたん語の標準モジュールの実装です。
Package gomods は Go 言語による、キーたん語の標準モジュールの実装です。
repl
Package repl は対話モード(REPL)時に使われるパッケージです。
Package repl は対話モード(REPL)時に使われるパッケージです。

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL