greetingInGreek.py 450 B

12345678910111213141516171819
  1. # vim:fileencoding=utf-8
  2. #
  3. # greetingInGreek.py
  4. #
  5. # Demonstration of the parsing module, on the prototypical "Hello, World!" example
  6. #
  7. # Copyright 2004-2016, by Paul McGuire
  8. #
  9. from pyparsing import Word, pyparsing_unicode as ppu
  10. # define grammar
  11. alphas = ppu.Greek.alphas
  12. greet = Word(alphas) + ',' + Word(alphas) + '!'
  13. # input string
  14. hello = "Καλημέρα, κόσμε!"
  15. # parse input string
  16. print(greet.parseString(hello))