Well, the syntax is:
condition = and_condition ('or' and_condition)* and_condition = relation ('and' relation)* relation = is_relation | in_relation | within_relation | 'n' <EOL> is_relation = expr 'is' ('not')? value in_relation = expr ('not')? 'in' range_list
within_relation = expr ('not')? 'within' range_list expr = 'n' ('mod' value)? range_list = (range | value) (',' range_list)* value = digit+ digit = 0|1|2|3|4|5|6|7|8|9 range = value'..'value
Would this one work: http://pear.php.net/package/PHP_ParserGenerator
? Domas
On Jun 20, 2012, at 2:02 PM, Niklas Laxström wrote:
No, this is not about a wikitext parser. Rather something much simpler.
Have a look at [1] and you will see rules like: n in 0..1 n is 2 n mod 10 in 3..4,9 and n mod 100 not in 10..19,70..79,90..99
Long ago when I wanted to compare the plural rules of MediaWiki and CLDR I wrote a parser for the CLDR rule format. Unfortunately my implementation uses regular expression and eval, which makes it unsuitable for production. Now, writing parsers is not my area of expertise, so can you please point me how to do this properly with PHP. Bonus points if it is also easily adaptable to JavaScript.
[1] http://unicode.org/repos/cldr-tmp/trunk/diff/supplemental/language_plural_ru...
-Niklas
-- Niklas Laxström
Wikitech-l mailing list Wikitech-l@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/wikitech-l