<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns:p="urn:schemas-microsoft-com:office:powerpoint" xmlns:a="urn:schemas-microsoft-com:office:access" xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882" xmlns:s="uuid:BDC6E3F0-6DA3-11d1-A2A3-00AA00C14882" xmlns:rs="urn:schemas-microsoft-com:rowset" xmlns:z="#RowsetSchema" xmlns:b="urn:schemas-microsoft-com:office:publisher" xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet" xmlns:c="urn:schemas-microsoft-com:office:component:spreadsheet" xmlns:odc="urn:schemas-microsoft-com:office:odc" xmlns:oa="urn:schemas-microsoft-com:office:activation" xmlns:html="http://www.w3.org/TR/REC-html40" xmlns:q="http://schemas.xmlsoap.org/soap/envelope/" xmlns:rtc="http://microsoft.com/officenet/conferencing" xmlns:D="DAV:" xmlns:Repl="http://schemas.microsoft.com/repl/" xmlns:mt="http://schemas.microsoft.com/sharepoint/soap/meetings/" xmlns:x2="http://schemas.microsoft.com/office/excel/2003/xml" xmlns:ppda="http://www.passport.com/NameSpace.xsd" xmlns:ois="http://schemas.microsoft.com/sharepoint/soap/ois/" xmlns:dir="http://schemas.microsoft.com/sharepoint/soap/directory/" xmlns:ds="http://www.w3.org/2000/09/xmldsig#" xmlns:dsp="http://schemas.microsoft.com/sharepoint/dsp" xmlns:udc="http://schemas.microsoft.com/data/udc" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:sub="http://schemas.microsoft.com/sharepoint/soap/2002/1/alerts/" xmlns:ec="http://www.w3.org/2001/04/xmlenc#" xmlns:sp="http://schemas.microsoft.com/sharepoint/" xmlns:sps="http://schemas.microsoft.com/sharepoint/soap/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:udcs="http://schemas.microsoft.com/data/udc/soap" xmlns:udcxf="http://schemas.microsoft.com/data/udc/xmlfile" xmlns:udcp2p="http://schemas.microsoft.com/data/udc/parttopart" xmlns:wf="http://schemas.microsoft.com/sharepoint/soap/workflow/" xmlns:dsss="http://schemas.microsoft.com/office/2006/digsig-setup" xmlns:dssi="http://schemas.microsoft.com/office/2006/digsig" xmlns:mdssi="http://schemas.openxmlformats.org/package/2006/digital-signature" xmlns:mver="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns:mrels="http://schemas.openxmlformats.org/package/2006/relationships" xmlns:spwp="http://microsoft.com/sharepoint/webpartpages" xmlns:ex12t="http://schemas.microsoft.com/exchange/services/2006/types" xmlns:ex12m="http://schemas.microsoft.com/exchange/services/2006/messages" xmlns:pptsl="http://schemas.microsoft.com/sharepoint/soap/SlideLibrary/" xmlns:spsl="http://microsoft.com/webservices/SharePointPortalServer/PublishedLinksService" xmlns:Z="urn:schemas-microsoft-com:" xmlns:st="&#1;" xmlns="http://www.w3.org/TR/REC-html40">

<head>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=us-ascii">
<meta name=Generator content="Microsoft Word 12 (filtered medium)">
<style>
<!--
 /* Font Definitions */
 @font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Consolas;
        panose-1:2 11 6 9 2 2 4 3 2 4;}
 /* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri","sans-serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
p.MsoPlainText, li.MsoPlainText, div.MsoPlainText
        {mso-style-priority:99;
        mso-style-link:"Plain Text Char";
        margin:0in;
        margin-bottom:.0001pt;
        font-size:10.5pt;
        font-family:Consolas;}
span.PlainTextChar
        {mso-style-name:"Plain Text Char";
        mso-style-priority:99;
        mso-style-link:"Plain Text";
        font-family:Consolas;}
.MsoChpDefault
        {mso-style-type:export-only;}
@page Section1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.Section1
        {page:Section1;}
-->
</style>
<!--[if gte mso 9]><xml>
 <o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
 <o:shapelayout v:ext="edit">
  <o:idmap v:ext="edit" data="1" />
 </o:shapelayout></xml><![endif]-->
</head>

<body lang=EN-US link=blue vlink=purple>

<div class=Section1>

<p class=MsoNormal>Thanks Dino.&nbsp; This (very) rough draft worked perfectly:<o:p></o:p></p>

<p class=MsoNormal><o:p>&nbsp;</o:p></p>

<p class=MsoNormal style='margin-left:.5in;text-autospace:none'><span
style='font-size:8.0pt;font-family:Consolas;color:blue'>class</span><span
style='font-size:8.0pt;font-family:Consolas'> <span style='color:#2B91AF'>Program<o:p></o:p></span></span></p>

<p class=MsoNormal style='margin-left:.5in;text-autospace:none'><span
style='font-size:8.0pt;font-family:Consolas'>{<o:p></o:p></span></p>

<p class=MsoNormal style='margin-left:.5in;text-autospace:none'><span
style='font-size:8.0pt;font-family:Consolas'>&nbsp;&nbsp;&nbsp; <span style='color:blue'>static</span>
<span style='color:blue'>void</span> Main(<span style='color:blue'>string</span>[]
args)<o:p></o:p></span></p>

<p class=MsoNormal style='margin-left:.5in;text-autospace:none'><span
style='font-size:8.0pt;font-family:Consolas'>&nbsp;&nbsp;&nbsp; {<o:p></o:p></span></p>

<p class=MsoNormal style='margin-left:.5in;text-autospace:none'><span
style='font-size:8.0pt;font-family:Consolas'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style='color:blue'>string</span>
cmd = <span style='color:#A31515'>&quot;if one.two.three.four.&quot;</span>;<o:p></o:p></span></p>

<p class=MsoNormal style='margin-left:.5in;text-autospace:none'><span
style='font-size:8.0pt;font-family:Consolas'><o:p>&nbsp;</o:p></span></p>

<p class=MsoNormal style='margin-left:.5in;text-autospace:none'><span
style='font-size:8.0pt;font-family:Consolas'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style='color:#2B91AF'>ScriptEngine</span>
engine = <span style='color:#2B91AF'>Python</span>.CreateEngine();<o:p></o:p></span></p>

<p class=MsoNormal style='margin-left:.5in;text-autospace:none'><span
style='font-size:8.0pt;font-family:Consolas'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style='color:#2B91AF'>ScriptScope</span>
scope = engine.CreateScope();<o:p></o:p></span></p>

<p class=MsoNormal style='margin-left:.5in;text-autospace:none'><span
style='font-size:8.0pt;font-family:Consolas'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style='color:#2B91AF'>ScriptSource</span>
source = engine.CreateScriptSourceFromString(cmd,<span style='color:#2B91AF'> SourceCodeKind</span>.InteractiveCode);<o:p></o:p></span></p>

<p class=MsoNormal style='margin-left:.5in;text-autospace:none'><span
style='font-size:8.0pt;font-family:Consolas'><o:p>&nbsp;</o:p></span></p>

<p class=MsoNormal style='margin-left:.5in;text-autospace:none'><span
style='font-size:8.0pt;font-family:Consolas'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style='color:#2B91AF'>SourceUnit</span>
unit = <span style='color:#2B91AF'>HostingHelpers</span>.GetSourceUnit(source);<o:p></o:p></span></p>

<p class=MsoNormal style='margin-left:.5in;text-autospace:none'><span
style='font-size:8.0pt;font-family:Consolas'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style='color:#2B91AF'>Parser</span>
p = <span style='color:#2B91AF'>Parser</span>.CreateParser(<o:p></o:p></span></p>

<p class=MsoNormal style='margin-left:.5in;text-autospace:none'><span
style='font-size:8.0pt;font-family:Consolas'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span
style='color:blue'>new</span> <span style='color:#2B91AF'>CompilerContext</span>(unit,
<span style='color:blue'>new</span> <span style='color:#2B91AF'>PythonCompilerOptions</span>(),
<span style='color:#2B91AF'>ErrorSink</span>.Null),<o:p></o:p></span></p>

<p class=MsoNormal style='margin-left:.5in;text-autospace:none'><span
style='font-size:8.0pt;font-family:Consolas'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span
style='color:blue'>new</span> <span style='color:#2B91AF'>PythonOptions</span>()<o:p></o:p></span></p>

<p class=MsoNormal style='margin-left:.5in;text-autospace:none'><span
style='font-size:8.0pt;font-family:Consolas'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; );<o:p></o:p></span></p>

<p class=MsoNormal style='margin-left:.5in;text-autospace:none'><span
style='font-size:8.0pt;font-family:Consolas'><o:p>&nbsp;</o:p></span></p>

<p class=MsoNormal style='margin-left:.5in;text-autospace:none'><span
style='font-size:8.0pt;font-family:Consolas'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style='color:#2B91AF'>PythonAst</span>
ast = p.ParseFile(<span style='color:blue'>false</span>);<o:p></o:p></span></p>

<p class=MsoNormal style='margin-left:.5in;text-autospace:none'><span
style='font-size:8.0pt;font-family:Consolas'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style='color:#2B91AF'>Walker</span>
w = <span style='color:blue'>new</span> <span style='color:#2B91AF'>Walker</span>(cmd.Length);<o:p></o:p></span></p>

<p class=MsoNormal style='margin-left:.5in;text-autospace:none'><span
style='font-size:8.0pt;font-family:Consolas'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ast.Walk(w);<o:p></o:p></span></p>

<p class=MsoNormal style='margin-left:.5in;text-autospace:none'><span
style='font-size:8.0pt;font-family:Consolas'><o:p>&nbsp;</o:p></span></p>

<p class=MsoNormal style='margin-left:.5in;text-autospace:none'><span
style='font-size:8.0pt;font-family:Consolas'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style='color:#2B91AF'>Stack</span>&lt;<span
style='color:blue'>string</span>&gt; members = w.GetResult();<o:p></o:p></span></p>

<p class=MsoNormal style='margin-left:.5in;text-autospace:none'><span
style='font-size:8.0pt;font-family:Consolas'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style='color:blue'>while</span>
(members.Count != 0)<o:p></o:p></span></p>

<p class=MsoNormal style='margin-left:.5in;text-autospace:none'><span
style='font-size:8.0pt;font-family:Consolas'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span
style='color:#2B91AF'>Console</span>.WriteLine(members.Pop());<o:p></o:p></span></p>

<p class=MsoNormal style='margin-left:.5in;text-autospace:none'><span
style='font-size:8.0pt;font-family:Consolas'>&nbsp;&nbsp;&nbsp; }<o:p></o:p></span></p>

<p class=MsoNormal style='margin-left:.5in;text-autospace:none'><span
style='font-size:8.0pt;font-family:Consolas'>}<o:p></o:p></span></p>

<p class=MsoNormal style='margin-left:.5in;text-autospace:none'><span
style='font-size:8.0pt;font-family:Consolas'><o:p>&nbsp;</o:p></span></p>

<p class=MsoNormal style='margin-left:.5in;text-autospace:none'><span
style='font-size:8.0pt;font-family:Consolas;color:blue'>public</span><span
style='font-size:8.0pt;font-family:Consolas'> <span style='color:blue'>class</span>
<span style='color:#2B91AF'>Walker</span> : <span style='color:#2B91AF'>PythonWalker<o:p></o:p></span></span></p>

<p class=MsoNormal style='margin-left:.5in;text-autospace:none'><span
style='font-size:8.0pt;font-family:Consolas'>{<o:p></o:p></span></p>

<p class=MsoNormal style='margin-left:.5in;text-autospace:none'><span
style='font-size:8.0pt;font-family:Consolas'>&nbsp;&nbsp;&nbsp; <span style='color:blue'>int</span>
mIndex;<o:p></o:p></span></p>

<p class=MsoNormal style='margin-left:.5in;text-autospace:none'><span
style='font-size:8.0pt;font-family:Consolas'>&nbsp;&nbsp;&nbsp; <span style='color:#2B91AF'>Stack</span>&lt;<span
style='color:blue'>string</span>&gt; mResult = <span style='color:blue'>null</span>;<o:p></o:p></span></p>

<p class=MsoNormal style='margin-left:.5in;text-autospace:none'><span
style='font-size:8.0pt;font-family:Consolas'>&nbsp;&nbsp;&nbsp; <span style='color:blue'>public</span>
Walker(<span style='color:blue'>int</span> index)<o:p></o:p></span></p>

<p class=MsoNormal style='margin-left:.5in;text-autospace:none'><span
style='font-size:8.0pt;font-family:Consolas'>&nbsp;&nbsp;&nbsp; {<o:p></o:p></span></p>

<p class=MsoNormal style='margin-left:.5in;text-autospace:none'><span
style='font-size:8.0pt;font-family:Consolas'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; mIndex = index;<o:p></o:p></span></p>

<p class=MsoNormal style='margin-left:.5in;text-autospace:none'><span
style='font-size:8.0pt;font-family:Consolas'>&nbsp;&nbsp;&nbsp; }<o:p></o:p></span></p>

<p class=MsoNormal style='margin-left:.5in;text-autospace:none'><span
style='font-size:8.0pt;font-family:Consolas'><o:p>&nbsp;</o:p></span></p>

<p class=MsoNormal style='margin-left:.5in;text-autospace:none'><span
style='font-size:8.0pt;font-family:Consolas'>&nbsp;&nbsp;&nbsp; <span style='color:blue'>public</span>
<span style='color:#2B91AF'>Stack</span>&lt;<span style='color:blue'>string</span>&gt;
GetResult()<o:p></o:p></span></p>

<p class=MsoNormal style='margin-left:.5in;text-autospace:none'><span
style='font-size:8.0pt;font-family:Consolas'>&nbsp;&nbsp;&nbsp; {<o:p></o:p></span></p>

<p class=MsoNormal style='margin-left:.5in;text-autospace:none'><span
style='font-size:8.0pt;font-family:Consolas'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style='color:blue'>return</span>
mResult;<o:p></o:p></span></p>

<p class=MsoNormal style='margin-left:.5in;text-autospace:none'><span
style='font-size:8.0pt;font-family:Consolas'>&nbsp;&nbsp;&nbsp; }<o:p></o:p></span></p>

<p class=MsoNormal style='margin-left:.5in;text-autospace:none'><span
style='font-size:8.0pt;font-family:Consolas'><o:p>&nbsp;</o:p></span></p>

<p class=MsoNormal style='margin-left:.5in;text-autospace:none'><span
style='font-size:8.0pt;font-family:Consolas'>&nbsp;&nbsp;&nbsp; <span style='color:blue'>public</span>
<span style='color:blue'>override</span> <span style='color:blue'>bool</span>
Walk(<span style='color:#2B91AF'>MemberExpression</span> node)<o:p></o:p></span></p>

<p class=MsoNormal style='margin-left:.5in;text-autospace:none'><span
style='font-size:8.0pt;font-family:Consolas'>&nbsp;&nbsp;&nbsp; {<o:p></o:p></span></p>

<p class=MsoNormal style='margin-left:.5in;text-autospace:none'><span
style='font-size:8.0pt;font-family:Consolas'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style='color:blue'>if</span>
(mIndex == node.Span.End.Index)<o:p></o:p></span></p>

<p class=MsoNormal style='margin-left:.5in;text-autospace:none'><span
style='font-size:8.0pt;font-family:Consolas'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<o:p></o:p></span></p>

<p class=MsoNormal style='margin-left:.5in;text-autospace:none'><span
style='font-size:8.0pt;font-family:Consolas'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; mResult = <span
style='color:blue'>new</span> <span style='color:#2B91AF'>Stack</span>&lt;<span
style='color:blue'>string</span>&gt;();<o:p></o:p></span></p>

<p class=MsoNormal style='margin-left:.5in;text-autospace:none'><span
style='font-size:8.0pt;font-family:Consolas'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span
style='color:#2B91AF'>MemberExpression</span> curr = node;<o:p></o:p></span></p>

<p class=MsoNormal style='margin-left:.5in;text-autospace:none'><span
style='font-size:8.0pt;font-family:Consolas'><o:p>&nbsp;</o:p></span></p>

<p class=MsoNormal style='margin-left:.5in;text-autospace:none'><span
style='font-size:8.0pt;font-family:Consolas'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span
style='color:blue'>while</span> (curr.Target <span style='color:blue'>is</span>
<span style='color:#2B91AF'>MemberExpression</span>)<o:p></o:p></span></p>

<p class=MsoNormal style='margin-left:.5in;text-autospace:none'><span
style='font-size:8.0pt;font-family:Consolas'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<o:p></o:p></span></p>

<p class=MsoNormal style='margin-left:.5in;text-autospace:none'><span
style='font-size:8.0pt;font-family:Consolas'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; curr = (<span
style='color:#2B91AF'>MemberExpression</span>)curr.Target;<o:p></o:p></span></p>

<p class=MsoNormal style='margin-left:.5in;text-autospace:none'><span
style='font-size:8.0pt;font-family:Consolas'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;mResult.Push(curr.Name.ToString());<o:p></o:p></span></p>

<p class=MsoNormal style='margin-left:.5in;text-autospace:none'><span
style='font-size:8.0pt;font-family:Consolas'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<o:p></o:p></span></p>

<p class=MsoNormal style='margin-left:.5in;text-autospace:none'><span
style='font-size:8.0pt;font-family:Consolas'><o:p>&nbsp;</o:p></span></p>

<p class=MsoNormal style='margin-left:.5in;text-autospace:none'><span
style='font-size:8.0pt;font-family:Consolas'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span
style='color:blue'>if</span> (curr.Target <span style='color:blue'>is</span> <span
style='color:#2B91AF'>NameExpression</span>)<o:p></o:p></span></p>

<p class=MsoNormal style='margin-left:.5in;text-autospace:none'><span
style='font-size:8.0pt;font-family:Consolas'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; mResult.Push(((<span
style='color:#2B91AF'>NameExpression</span>)curr.Target).Name.ToString());<o:p></o:p></span></p>

<p class=MsoNormal style='margin-left:.5in;text-autospace:none'><span
style='font-size:8.0pt;font-family:Consolas'><o:p>&nbsp;</o:p></span></p>

<p class=MsoNormal style='margin-left:.5in;text-autospace:none'><span
style='font-size:8.0pt;font-family:Consolas'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span
style='color:blue'>return</span> <span style='color:blue'>false</span>;<o:p></o:p></span></p>

<p class=MsoNormal style='margin-left:.5in;text-autospace:none'><span
style='font-size:8.0pt;font-family:Consolas'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<o:p></o:p></span></p>

<p class=MsoNormal style='margin-left:.5in;text-autospace:none'><span
style='font-size:8.0pt;font-family:Consolas'><o:p>&nbsp;</o:p></span></p>

<p class=MsoNormal style='margin-left:.5in;text-autospace:none'><span
style='font-size:8.0pt;font-family:Consolas'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style='color:blue'>return</span>
<span style='color:blue'>true</span>;<o:p></o:p></span></p>

<p class=MsoNormal style='margin-left:.5in;text-autospace:none'><span
style='font-size:8.0pt;font-family:Consolas'>&nbsp;&nbsp;&nbsp; }<o:p></o:p></span></p>

<p class=MsoNormal style='margin-left:.5in'><span style='font-size:8.0pt;
font-family:Consolas'>}</span><o:p></o:p></p>

<p class=MsoNormal><o:p>&nbsp;</o:p></p>

<p class=MsoNormal>-Lee<o:p></o:p></p>

<p class=MsoNormal><o:p>&nbsp;</o:p></p>

<p class=MsoPlainText><o:p>&nbsp;</o:p></p>

<p class=MsoPlainText>-----Original Message-----<br>
From: users-bounces@lists.ironpython.com
[mailto:users-bounces@lists.ironpython.com] On Behalf Of Dino Viehland<br>
Sent: Tuesday, December 01, 2009 4:15 PM<br>
To: Discussion of IronPython<br>
Subject: Re: [IronPython] Is it possible to get the DLR's AST when it fails to
parse?<o:p></o:p></p>

<p class=MsoPlainText><o:p>&nbsp;</o:p></p>

<p class=MsoPlainText>Tokenization would save some work but he could also just
use the IronPython<o:p></o:p></p>

<p class=MsoPlainText>parser.&nbsp; It's unfortunately a small pain to create (it's
overly tied to the<o:p></o:p></p>

<p class=MsoPlainText>DLR APIs right now) but it's:<o:p></o:p></p>

<p class=MsoPlainText><o:p>&nbsp;</o:p></p>

<p class=MsoPlainText>return Parser.CreateParser(<o:p></o:p></p>

<p class=MsoPlainText>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; new CompilerContext(sourceUnit, new
PythonCompilerOptions(), ErrorSink.Null),<o:p></o:p></p>

<p class=MsoPlainText>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; new PythonOptions()<o:p></o:p></p>

<p class=MsoPlainText>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; );<o:p></o:p></p>

<p class=MsoPlainText><o:p>&nbsp;</o:p></p>

<p class=MsoPlainText>And to get that SourceUnit you can do
HostingHelpers.GetSourceUnit on the ScriptSource.<o:p></o:p></p>

<p class=MsoPlainText><o:p>&nbsp;</o:p></p>

<p class=MsoPlainText>The resulting parsed expression will include
ErrorExpression's where <o:p></o:p></p>

<p class=MsoPlainText>we encounter invalid code.&nbsp; You may also find that things
like class and<o:p></o:p></p>

<p class=MsoPlainText>function definitions can be missing their names if you
are parsing <o:p></o:p></p>

<p class=MsoPlainText>incomplete code like &quot;def &quot;.&nbsp; Then you'll be
working on the IronPython AST<o:p></o:p></p>

<p class=MsoPlainText>instead of the DLR AST (but the two will be the same
likely in <o:p></o:p></p>

<p class=MsoPlainText>IronPython 2.6.1 - the ASTs are now reducible DLR ASTs).<o:p></o:p></p>

<p class=MsoPlainText><o:p>&nbsp;</o:p></p>

<p class=MsoPlainText><o:p>&nbsp;</o:p></p>

<p class=MsoPlainText>&gt; -----Original Message-----<o:p></o:p></p>

<p class=MsoPlainText>&gt; From: users-bounces@lists.ironpython.com
[mailto:users-<o:p></o:p></p>

<p class=MsoPlainText>&gt; bounces@lists.ironpython.com] On Behalf Of Michael
Foord<o:p></o:p></p>

<p class=MsoPlainText>&gt; Sent: Tuesday, December 01, 2009 4:07 PM<o:p></o:p></p>

<p class=MsoPlainText>&gt; To: Discussion of IronPython<o:p></o:p></p>

<p class=MsoPlainText>&gt; Subject: Re: [IronPython] Is it possible to get the
DLR's AST when it fails to<o:p></o:p></p>

<p class=MsoPlainText>&gt; parse?<o:p></o:p></p>

<p class=MsoPlainText>&gt; <o:p></o:p></p>

<p class=MsoPlainText>&gt; No time for a longer reply, but you probably want to
tokenize rather<o:p></o:p></p>

<p class=MsoPlainText>&gt; than parse.<o:p></o:p></p>

<p class=MsoPlainText>&gt; <o:p></o:p></p>

<p class=MsoPlainText>&gt; Michael<o:p></o:p></p>

<p class=MsoPlainText>&gt; <o:p></o:p></p>

<p class=MsoPlainText>&gt; Lee Culver wrote:<o:p></o:p></p>

<p class=MsoPlainText>&gt; &gt;<o:p></o:p></p>

<p class=MsoPlainText>&gt; &gt; I have been playing with an implementation of a
simple GUI console for<o:p></o:p></p>

<p class=MsoPlainText>&gt; &gt; IronPython (similar to IDLE, without it's
text-editor IDE). I've<o:p></o:p></p>

<p class=MsoPlainText>&gt; &gt; mostly brought it up to rough feature parity
with IDLE, but I'd like<o:p></o:p></p>

<p class=MsoPlainText>&gt; &gt; to add a rudimentary itellisense such that when
you type something on<o:p></o:p></p>

<p class=MsoPlainText>&gt; &gt; the order of &quot;foo.&quot;, the interpreter
can pop up a menu containing the<o:p></o:p></p>

<p class=MsoPlainText>&gt; &gt; contents of foo (assuming it's something
already defined in the local<o:p></o:p></p>

<p class=MsoPlainText>&gt; &gt; scope). However, I'd really rather not get in
the business of parsing<o:p></o:p></p>

<p class=MsoPlainText>&gt; &gt; Python code. (That's what the DLR is for!)<o:p></o:p></p>

<p class=MsoPlainText>&gt; &gt;<o:p></o:p></p>

<p class=MsoPlainText>&gt; &gt; Is there any way I can use DLR to give me the
AST up to the point at<o:p></o:p></p>

<p class=MsoPlainText>&gt; &gt; which it failed to parse so that I can walk
that and see if we are in<o:p></o:p></p>

<p class=MsoPlainText>&gt; &gt; a valid place to look up the fields of an
object? I looked at using<o:p></o:p></p>

<p class=MsoPlainText>&gt; &gt; the ErrorListener class with
ScriptSource.Compile, but it only gives<o:p></o:p></p>

<p class=MsoPlainText>&gt; &gt; me &quot;unexpected &lt;eof&gt; found&quot; at
the point where the &quot;.&quot; is...which I<o:p></o:p></p>

<p class=MsoPlainText>&gt; &gt; already knew.<o:p></o:p></p>

<p class=MsoPlainText>&gt; &gt;<o:p></o:p></p>

<p class=MsoPlainText>&gt; &gt; Basically, whenever the user presses the
&quot;.&quot; key in the console what I<o:p></o:p></p>

<p class=MsoPlainText>&gt; &gt; would like to do is roughly this code:<o:p></o:p></p>

<p class=MsoPlainText>&gt; &gt;<o:p></o:p></p>

<p class=MsoPlainText>&gt; &gt; ScriptEngine engine = Python.CreateEngine();<o:p></o:p></p>

<p class=MsoPlainText>&gt; &gt;<o:p></o:p></p>

<p class=MsoPlainText>&gt; &gt; ScriptScope scope = engine.CreateScope();<o:p></o:p></p>

<p class=MsoPlainText>&gt; &gt;<o:p></o:p></p>

<p class=MsoPlainText>&gt; &gt; ScriptSource source =
engine.CreateScriptSourceFromString(&quot;if foo.&quot;,<o:p></o:p></p>

<p class=MsoPlainText>&gt; &gt; Microsoft.Scripting.SourceCodeKind.InteractiveCode);<o:p></o:p></p>

<p class=MsoPlainText>&gt; &gt;<o:p></o:p></p>

<p class=MsoPlainText>&gt; &gt; source.Compile(); // &lt;-- This *should* fail.
I want the AST when it does.<o:p></o:p></p>

<p class=MsoPlainText>&gt; &gt;<o:p></o:p></p>

<p class=MsoPlainText>&gt; &gt; Primarily, I'm trying to find chains of
identifiers to walk so that I<o:p></o:p></p>

<p class=MsoPlainText>&gt; &gt; can display the Nth identifier's fields:<o:p></o:p></p>

<p class=MsoPlainText>&gt; &gt;<o:p></o:p></p>

<p class=MsoPlainText>&gt; &gt; identifier1 . identifier2 . identifier3 . ...<o:p></o:p></p>

<p class=MsoPlainText>&gt; &gt;<o:p></o:p></p>

<p class=MsoPlainText>&gt; &gt; I need to distinguish this from things like
this, because there's<o:p></o:p></p>

<p class=MsoPlainText>&gt; &gt; nothing you can reasonably do to have
intellisense in this case:<o:p></o:p></p>

<p class=MsoPlainText>&gt; &gt;<o:p></o:p></p>

<p class=MsoPlainText>&gt; &gt; Function(args) . identifier1 . identifier2<o:p></o:p></p>

<p class=MsoPlainText>&gt; &gt;<o:p></o:p></p>

<p class=MsoPlainText>&gt; &gt; (Yes, I realize that walking this chain can
execute code and have side<o:p></o:p></p>

<p class=MsoPlainText>&gt; &gt; effects, I'm willing to live with that for my
purposes.) Is there any<o:p></o:p></p>

<p class=MsoPlainText>&gt; &gt; mechanism through which I can have the DLR
parse this for me and give<o:p></o:p></p>

<p class=MsoPlainText>&gt; &gt; me the resulting AST that I can walk so I can
see if we can pop up an<o:p></o:p></p>

<p class=MsoPlainText>&gt; &gt; intellisense-like view?<o:p></o:p></p>

<p class=MsoPlainText>&gt; &gt;<o:p></o:p></p>

<p class=MsoPlainText>&gt; &gt; Can anyone recommend a better way to do this
outside of simply writing<o:p></o:p></p>

<p class=MsoPlainText>&gt; &gt; my own mini-parser?<o:p></o:p></p>

<p class=MsoPlainText>&gt; &gt;<o:p></o:p></p>

<p class=MsoPlainText>&gt; &gt; Thanks,<o:p></o:p></p>

<p class=MsoPlainText>&gt; &gt;<o:p></o:p></p>

<p class=MsoPlainText>&gt; &gt; -Lee Culver<o:p></o:p></p>

<p class=MsoPlainText>&gt; &gt;<o:p></o:p></p>

<p class=MsoPlainText>&gt; &gt;
------------------------------------------------------------------------<o:p></o:p></p>

<p class=MsoPlainText>&gt; &gt;<o:p></o:p></p>

<p class=MsoPlainText>&gt; &gt; _______________________________________________<o:p></o:p></p>

<p class=MsoPlainText>&gt; &gt; Users mailing list<o:p></o:p></p>

<p class=MsoPlainText>&gt; &gt; Users@lists.ironpython.com<o:p></o:p></p>

<p class=MsoPlainText>&gt; &gt;
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com<o:p></o:p></p>

<p class=MsoPlainText>&gt; &gt;<o:p></o:p></p>

<p class=MsoPlainText>&gt; <o:p></o:p></p>

<p class=MsoPlainText>&gt; <o:p></o:p></p>

<p class=MsoPlainText>&gt; --<o:p></o:p></p>

<p class=MsoPlainText>&gt; http://www.ironpythoninaction.com/<o:p></o:p></p>

<p class=MsoPlainText>&gt; http://www.voidspace.org.uk/blog<o:p></o:p></p>

<p class=MsoPlainText>&gt; <o:p></o:p></p>

<p class=MsoPlainText>&gt; <o:p></o:p></p>

<p class=MsoPlainText>&gt; _______________________________________________<o:p></o:p></p>

<p class=MsoPlainText>&gt; Users mailing list<o:p></o:p></p>

<p class=MsoPlainText>&gt; Users@lists.ironpython.com<o:p></o:p></p>

<p class=MsoPlainText>&gt;
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com<o:p></o:p></p>

<p class=MsoPlainText>_______________________________________________<o:p></o:p></p>

<p class=MsoPlainText>Users mailing list<o:p></o:p></p>

<p class=MsoPlainText>Users@lists.ironpython.com<o:p></o:p></p>

<p class=MsoPlainText>http://lists.ironpython.com/listinfo.cgi/users-ironpython.com<o:p></o:p></p>

<p class=MsoPlainText><o:p>&nbsp;</o:p></p>

</div>

</body>

</html>