diff options
Diffstat (limited to 'examples/greeting.py')
-rw-r--r-- | examples/greeting.py | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/examples/greeting.py b/examples/greeting.py new file mode 100644 index 0000000..2e6b241 --- /dev/null +++ b/examples/greeting.py @@ -0,0 +1,17 @@ +# greeting.py
+#
+# Demonstration of the pyparsing module, on the prototypical "Hello, World!"
+# example
+#
+# Copyright 2003, by Paul McGuire
+#
+from pyparsing import Word, alphas
+
+# define grammar
+greet = Word( alphas ) + "," + Word( alphas ) + "!"
+
+# input string
+hello = "Hello, World!"
+
+# parse input string
+print(hello, "->", greet.parseString( hello ))
|