Skip to content

Instantly share code, notes, and snippets.

@Tatakinov
Last active July 4, 2022 13:52
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Tatakinov/acc4120d9ab603715c0a22eeac7386f4 to your computer and use it in GitHub Desktop.
Save Tatakinov/acc4120d9ab603715c0a22eeac7386f4 to your computer and use it in GitHub Desktop.
2021AdventCalendar 12/13

YAYAのlintを作りたかった

伺かAdventCalendar2021の13日の記事です。

lintとはなんぞや

デバッガーが動的なデバッグツールならこちらは静的なもの。

実行するまでもなく怪しい部分を見つけ出してくれます。便利。

出来上がったもの

構文解析は結構うまくいくようになりました。 でもバグはある。

名前

yayalint(ややりんと)。里々の方がまんまでつけたのでそちらに倣って。

機能

構文エラー、未定義の変数の使用、未使用の変数の存在などを見つけられます。 他の機能は気が向いたらちまちま作っていきます。

使い方

Usage: yayalint.exe [-f] [-s] [-u] [-d] [-l] [-g] [-h] <path>

Arguments:
   path                  yaya.dllが置いてあるフォルダのパス

Options:
   -f, --nofile          ファイルが見つからないことを出力しない
   -s, --nosyntaxerror   構文エラーに関する情報を出力しない
   -u, --nounused        未使用の変数に関する情報を出力しない
   -d, --noundefined     未定義の変数に関する情報を出力しない
   -l, --nolocal         ローカル変数に関する情報を出力しない
   -g, --noglobal        グローバル変数/関数に関する情報を出力しない
   -h, --help            ヘルプの表示

各オプションについて出力する、ではなく出力しない、であることに留意されたし。

読み込む辞書の文字コードはUTF-8とShift_JISのみ対応しています。

出力はUTF-8なので、非ASCII文字を変数/関数/ファイル名に使う場合は注意。 コマンドプロンプトで実行すると多分文字化けします。

なので、文字化けしないようにするbatファイルを用意したのでそちらを使ってください。 batファイルにyaya.dllのあるフォルダ(一般的にはmasterフォルダ)をD&Dするだけ!便利!

batファイルにyaya.txt(or aya.txt)をD&Dするだけ!

使用例

//yaya_example.txt

Example
{
  _string = "Hello,"
  _result = _striing + "World!"
  _result
}

こんな辞書があったとします。

なんということでしょう、Example関数の2行目で_stringをうっかり_striingと書いてしまいました。 これに対してyayalintを使うと…

read undefined variable:	_striing	at	yaya_example.txt	Example
unused variable:	_string	at	yaya_example.txt	Example

のように警告してくれます。

yayalintとの付き合い方

例によって手元にある紺野ややめに使うと…と思いましたがメッセージが長くなったので-gオプションをつけて実行したものをペタリ。

unused variable:	_result	at	system/yaya_shiori3.dic	OnRequest
read undefined variable:	_value	at	system/yaya_shiori3.dic	SHIORI3FW.AssembleReferenceHeader
unused variable:	_trash	at	system/yaya_shiori3.dic	SHIORI3FW.RaiseIDEvent
unused variable:	_dmy	at	system/yaya_shiori3.dic	SHIORI3FW.ExecuteDl2ToDll

-gをつけないとグローバル変数や関数に関するものがズラーっと出力される訳ですが、特に関数、OnFirstBootに代表する様にベースウェアから呼ばれるイベントが unusedだよ、という警告が沢山でるので実際に使うときは-gオプションを付けて使うことが多くなりそうです。

動かないことがあるのはundefinedな変数や関数があるときなので、-uオプションを使う方のが実用的です。

終わりに

例のごとくこのプログラムは自己責任で使ってください

使ってみようかな…?と思われる方は こちらからダウンロードをお願いします。

@steve02081504
Copy link

steve02081504 commented Dec 14, 2021

pic
hi
I would like to know if this program supports operations such as include and dicdir, and can it be open sourced on github?
The problematic ghost is here
sorry to bother you

@Tatakinov
Copy link
Author

Added support for include and dicdir.
The source code is now available here.

@steve02081504
Copy link

thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment