1. Volker Birk
  2. pyPEG

Commits

Volker Birk  committed 02698c7

default grammar for flag()

  • Participants
  • Parent commits 99175f0
  • Branches default

Comments (0)

Files changed (3)

File docs/grammar_elements.en.yhtml2

View file
  • Ignore whitespace
     h3 id=flag > Function flag()
 
     h4 > Synopsis
-    p > «flag(name, thing)»
+    p > «flag(name, thing=None
 
     p   >>
         Generate an «Attribute» with that «name» which is valued «True» or
-        «False».
+        «False». If no «thing» is given, «Keyword(name)» is assumed.
         >>
 
     h4 > Parsing

File docs/parser_engine.en.yhtml2

View file
  • Ignore whitespace
     }
 
     h4 > Returns
-    p > Instance of «SyntaxError»
+    p > Instance of «SyntaxError» with error text
 
     h2 id=convenience > Convenience functions
 

File pypeg2/__init__.py

View file
  • Ignore whitespace
 attr.Class = namedtuple("Attribute", ("name", "thing", "subtype"))
 
 
-def flag(name, thing):
+def flag(name, thing=None):
     """Generate an Attribute with that name which is valued True or False."""
+    if thing is None:
+        thing = Keyword(name)
     return attr(name, thing, "Flag")