pofiles_grammar 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. Gettext PO file grammar in BNF notation: © 2012 cage
  2. This work is licensed under the Creative Commons
  3. Attribution-ShareAlike 3.0 Unported License. To view a copy of this
  4. license, visit http://creativecommons.org/licenses/by-sa/3.0/ or send
  5. a letter to Creative Commons, 444 Castro Street, Suite 900, Mountain
  6. View, California, 94041, USA.
  7. pofile := header msg*
  8. header := msgid '""' newline msgstr_header newline
  9. msgstr_header := msgstr escaped_string* plurar_string escaped_string* newline
  10. plural_string := '"Plural-Forms:' plurar_number_expr plural_expression_string
  11. plural_expression_string := 'plural=' plural_expression
  12. plural_number_expr := 'nplural=' number end_expression
  13. msg := comments* flag_comment? comments* msgid escaped_string* newline
  14. (msgid_plural escaped_string newline (msg_str_plural)+ ) |
  15. (msg_str escaped_string*)
  16. flag_comment := '#,' string newline
  17. msg_str_plural:= 'msgstr[' number ']' escaped_string* newline
  18. comments := '#' newline | '^#[^,].*' newline
  19. msgstr := 'msgstr'
  20. msgid := 'msgid'
  21. msgid_plural := 'msgid_plural'
  22. newline = ascii code 10
  23. plural_expression := (number | boolean_expression | ternary_expression) end_expression
  24. ternary_expression := boolean_expression '?' expression ':' expression
  25. expression := ternary_expression | number
  26. boolean_expression := arithmetic_expression |
  27. '(' boolean_expression ')' |
  28. boolean_expression boolean_op boolean_expression |
  29. boolean_expression boolean_op arithmetic_expression |
  30. arithmetic_expression boolean_op boolean_expression |
  31. arithmetic_expression boolean_op arithmetic_expression |
  32. arithmetic_expression := 'n' comparision_op number |
  33. 'n' arithmetic_op number comparision_op number
  34. boolean_op := '&&' | '||'
  35. arithmetic_op := '%'
  36. comparision_op := '<' | '>' | '<=' | '>=' | '!=' | '=='
  37. number := 0|[1-9][0-9]+|[1-9]
  38. end_expression := ';'