转自
the #perl6 IRC channel,by jkramer,with permission
我正在玩语法并试图解析一个ini风格的文件,但不知何故,Grammar.parse似乎永远循环并使用100%的cpu.任何想法在这里有什么问题?
grammar Format { token TOP { [ <comment>* [ <section> [ <line> | <comment> ]* ]* ]* } rule section { '[' <identifier> <subsection>? ']' } rule subsection { '"' <identifier> '"' } rule identifier { <[A..Za..z]> <[A..Za..z0..9_-]>+ } rule comment { <[";]> .*? $$ } rule line { <key> '=' <value> } rule key { <identifier> } rule value { .*? $$ } } Format.parse('lol.conf'.IO.slurp)