Guest User

Untitled

a guest
Feb 19th, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.44 KB | None | 0 0
  1. from pyparsing import *
  2.  
  3. indentStack = [1]
  4. stmt = Forward()
  5. suite = indentedBlock(stmt, indentStack)
  6.  
  7. funcDecl = "def" + Word(printables)
  8. funcDef = Group( funcDecl + suite )
  9.  
  10. stmt << ( funcDef | "open" | "close")
  11. module_body = OneOrMore(stmt)
  12.  
  13. code="""
  14. def process
  15. open
  16. close"""
  17.  
  18. funcDef.parseString(code) ### works fine
  19. funcDef.parseString(code) ### throws excepotion
  20.  
  21. pyparsing.ParseException: not a subentry (at char 16), (line:2, col:5)
Add Comment
Please, Sign In to add comment