summaryrefslogtreecommitdiff
path: root/examples/stackish.py
diff options
context:
space:
mode:
authorJon Dufresne <jon.dufresne@gmail.com>2018-12-22 09:28:48 -0800
committerJon Dufresne <jon.dufresne@gmail.com>2018-12-22 13:46:56 -0800
commitde8326d00dffdb500c02839a98330b869c2457f3 (patch)
tree6c5fdae41cf8b335ff1c64f37856786523e4fd0d /examples/stackish.py
parent59dfd314c23fd653271bdad37631f0497e8ad748 (diff)
downloadpyparsing-git-de8326d00dffdb500c02839a98330b869c2457f3.tar.gz
Trim trailing white space throughout the project
Many editors clean up trailing white space on save. By removing it all in one go, it helps keep future diffs cleaner by avoiding spurious white space changes on unrelated lines.
Diffstat (limited to 'examples/stackish.py')
-rw-r--r--examples/stackish.py48
1 files changed, 24 insertions, 24 deletions
diff --git a/examples/stackish.py b/examples/stackish.py
index f80b4d6..3fa98f4 100644
--- a/examples/stackish.py
+++ b/examples/stackish.py
@@ -1,31 +1,31 @@
# stackish.py
#
-# Stackish is a data representation syntax, similar to JSON or YAML. For more info on
+# Stackish is a data representation syntax, similar to JSON or YAML. For more info on
# stackish, see http://www.savingtheinternetwithhate.com/stackish.html
#
# Copyright 2008, Paul McGuire
#
"""
-NUMBER A simple integer type that's just any series of digits.
-FLOAT A simple floating point type.
-STRING A string is double quotes with anything inside that's not a " or
- newline character. You can include \n and \" to include these
- characters.
-MARK Marks a point in the stack that demarcates the boundary for a nested
- group.
-WORD Marks the root node of a group, with the other end being the nearest
- MARK.
-GROUP Acts as the root node of an anonymous group.
-ATTRIBUTE Assigns an attribute name to the previously processed node.
- This means that just about anything can be an attribute, unlike in XML.
-BLOB A BLOB is unique to Stackish and allows you to record any content
+NUMBER A simple integer type that's just any series of digits.
+FLOAT A simple floating point type.
+STRING A string is double quotes with anything inside that's not a " or
+ newline character. You can include \n and \" to include these
+ characters.
+MARK Marks a point in the stack that demarcates the boundary for a nested
+ group.
+WORD Marks the root node of a group, with the other end being the nearest
+ MARK.
+GROUP Acts as the root node of an anonymous group.
+ATTRIBUTE Assigns an attribute name to the previously processed node.
+ This means that just about anything can be an attribute, unlike in XML.
+BLOB A BLOB is unique to Stackish and allows you to record any content
(even binary content) inside the structure. This is done by pre-
- sizing the data with the NUMBER similar to Dan Bernstein's netstrings
- setup.
-SPACE White space is basically ignored. This is interesting because since
- Stackish is serialized consistently this means you can use \n as the
- separation character and perform reasonable diffs on two structures.
+ sizing the data with the NUMBER similar to Dan Bernstein's netstrings
+ setup.
+SPACE White space is basically ignored. This is interesting because since
+ Stackish is serialized consistently this means you can use \n as the
+ separation character and perform reasonable diffs on two structures.
"""
from pyparsing import Suppress,Word,nums,alphas,alphanums,Combine,oneOf,\
@@ -45,7 +45,7 @@ strBody = Forward()
def setBodyLength(tokens):
strBody << Word(srange(r'[\0x00-\0xffff]'), exact=int(tokens[0]))
return ""
-BLOB = Combine(QUOTE + Word(nums).setParseAction(setBodyLength) +
+BLOB = Combine(QUOTE + Word(nums).setParseAction(setBodyLength) +
COLON + strBody + QUOTE)
item = Forward()
@@ -55,13 +55,13 @@ def assignUsing(s):
tokens[tokens[s]] = tokens[0]
del tokens[s]
return assignPA
-GROUP = (MARK +
- Group( ZeroOrMore(
- (item +
+GROUP = (MARK +
+ Group( ZeroOrMore(
+ (item +
Optional(ATTRIBUTE)("attr")
).setParseAction(assignUsing("attr"))
)
- ) +
+ ) +
( WORD("name") | UNMARK )
).setParseAction(assignUsing("name"))
item << (NUMBER | FLOAT | STRING | BLOB | GROUP )