<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html>
<head>
  <meta name="Generator" content="Zarafa WebAccess v7.0.7-34256">
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  <title>RE: simplified Python parsing question</title>
  <style type="text/css">
      body
      {
        font-family: Arial, Verdana, Sans-Serif ! important;
        font-size: 12px;
        padding: 5px 5px 5px 5px;
        margin: 0px;
        border-style: none;
        background-color: #ffffff;
      }

      p, ul, li
      {
        margin-top: 0px;
        margin-bottom: 0px;
      }
  </style>
</head>
<body>
<p>Another possibility is to use the ast module of python: http://docs.python.org/library/ast.html</p><p>The only problem with that module, is that everything you parse must be correct, otherwise it throws an exception, I don't know if that's a problem for your project?<br /> </p><blockquote style="border-left: 2px solid #325FBA; padding-left: 5px;margin-left:5px;">-----Original message-----<br /><strong>From:</strong>     Eric S. Johansson <esj@harvee.org><br /><strong>Sent:</strong>  Mon 30-07-2012 12:00<br /><strong>Subject:</strong>   Re: simplified Python parsing question<br /><strong>To:</strong>      python-list@python.org; <br />On 7/30/2012 5:25 AM, Laszlo Nagy wrote:<br />><br />> Did you try to use pygments?<br />><br />> http://pygments.org/docs/api/<br />><br /><br />thanks, I'll take a look.<br /><br />><br />> I would first tokenize the code, then divide it by statement keywords. <br />> Finally, you just need to find expression/assignment statements in the <br />> remaining sections. (Maybe there is a better way to do it.)<br />><br />><br />><br /><br />yeah the problem is also little more complicated than simple parsing of Python <br />code. For example, one example (from the white paper)<br /><br />*meat space blowback = Friends and family [well-meaning attempt]<br /><br />*could that be parsed by the tools you mention? I suspect not but this is what I <br />need to generate using speech recognition because it's easily spoken. A more <br />complex example might be something like<br /><br />new base = OS path-base name (old path)<br /><br />or<br /><br />if OS base exists (current path): new base name = OS path base name(current path)<br /><br />What's particularly cute here is that using the translation technique I can <br />actually describe the full object method path with a minimum of speaking <br />overhead. Python is great. :-)<br /><br />But the questions remain, will these tools are stuff like this?<br /><br /><br />-- <br />http://mail.python.org/mailman/listinfo/python-list<br /></blockquote>
</body>
</html>