我想解析一个有序列表,类似于:
I - Something
II - Something else...
IX - Something weird
XIII - etc
到目前为止,我的树顶语法是:
rule text
roman_numeral separator text newline
end
rule roman_numeral
&. ('MMM' / 'MM' / 'M')? (('C' [DM]) /
('D'? ('CCC' / 'CC' / 'C')?))? (('X' [LC]) /
('L'? ('XXX' / 'XX' / 'X')?))? (('I' [VX]) /
('V'? ('III' / 'II' / 'I')?))?
end
rule separator
[\s] "-" [\s]
end
rule text
(!"\n" .)*
end
rule newline
["\n"]
end
但是,相应的解析器无法解析文本。什么坏了?