forked from mruby/mruby
-
Notifications
You must be signed in to change notification settings - Fork 4
Regexp
kouki-o-iij edited this page Mar 22, 2013
·
37 revisions
- Regexp#match の pos のサポート
- named capture
- String メソッドの実装
- $~ の類のローカル変数化
- Regexp Engines: 正規表現エンジンを比較する。バイナリサイズ、実行時サイズ、オブジェクトの生成に伴うメモリ消費の増加、速度。
- Regexp Specification: mruby Regexp 実装と CRuby / ISO Ruby との仕様の違いを調べる。メソッド数レベルの違いと、挙動の違い。
- テストファーストで実装する。
Regexp:
#new(string, option, code) -> Regexp : 保存しておく。
.last_match : $~
.last_match(n) : $&
.try_convert : (いらない)
.union : (いらない)
#== : かんたんで後回し
#hash : ...? てきとうにでっちあげれば良い?
#inspect : なんとでもなるだろう
#named_captures : REエンジンによっては書けるか? Posixでは無理。
#names : Posix では無理
#to_s : うーん...? 変化しないことの保証は厳しそう
$& : Regexp.last_match[0] 実は「ローカルスコープ」。それ以外は難しくない。
$'' : Regexp.last_match.post_match
$+ : Regexp.last_match の最後のもの。
$` : Regexp.last_match.pre_match
$~ : Regexp.last_match
parse.y は "Regexp.compile(restr, optstr)" 相当のバイトコードにコンパイルする。optstr は常に付く。
- 正規表現リテラル入り .rb の .mrb へのコンパイル
- $1... はいくつまでサポートするか?
- pcre_malloc / pcre_free の置き換え
- mruby 本家へ escape 処理の pull-req(Done)
- regexp のテスト
- mrbgem 化