summaryrefslogtreecommitdiff
path: root/src/examples/greeting.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/examples/greeting.py')
-rw-r--r--src/examples/greeting.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/examples/greeting.py b/src/examples/greeting.py
new file mode 100644
index 0000000..46108b8
--- /dev/null
+++ b/src/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 )