[[
bol
]]
Xtal Unofficial Wiki
現在位置:
Xtal Unofficial Wiki
»
Xtal Reference
»
xpeg
»
bol
文書の表示
以前のリビジョン
最近の変更
サイトマップ
ログイン
この文書は読取専用です。文書のソースを閲覧することは可能ですが、変更はできません。もし変更したい場合は管理者に連絡してください。
====== bol ====== <code cpp> xpeg::bol : Element(Element:TYPE_BOL); </code> Begin of Line の略です。 ===== Example1 ===== ファイルを読み込み、先頭が"#"の行のみイテレートします。 ==== C++ ==== ==== Xtal ==== <code cpp> inherit(xpeg); if (fs : FileStream("text.txt", "r")){ fs.scan(bol >> "#" >> cap(comment: any/0) >> eol){ it["comment"].p; } fs.close; } </code> ==== Input ==== <code> # comment a b c def # not comment #comment2 adc </code> ==== Output ==== <code> comment comment2 </code> ===== Example2 ===== ファイルを読み込み、先頭が%%"//"%%の時はコメントとして、それ以外のときはそれ以外として、出力します。 Xtal側のバグなのかそもそもこういう書き方できないのかしらないけど割とうまくいかない。 ==== C++ ==== ==== Xtal ==== <code cpp> inherit(xpeg); if (fs : FileStream("text.txt", "r")){ fs.scan((bol >> "//" >> cap(com: any/0) >> eol)|(bol >> cap(lin: any/0) >> eol)){ if (it["com"]){ ("comment : "~it["com"]).p; } else { // else if (it["lin"]) ("line : "~it["lin"]).p; } } fs.close; } </code> ==== Input ==== <code> // comment this is not comment comment janai! // hoge </code> ==== Output ==== <code> comment : comment line : this is not comment line : comment janai! // hoge </code>
reference/xpeg/bol.txt · 最終更新: 2011/07/13 05:55 by sukai
文書の表示
以前のリビジョン
文書の先頭へ