<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Recent changes to 11: scanString start and end offsets incorrect.</title><link>https://sourceforge.net/p/pyparsing/support-requests/11/</link><description>Recent changes to 11: scanString start and end offsets incorrect.</description><atom:link href="https://sourceforge.net/p/pyparsing/support-requests/11/feed.rss" rel="self"/><language>en</language><lastBuildDate>Fri, 23 Oct 2015 20:51:55 -0000</lastBuildDate><atom:link href="https://sourceforge.net/p/pyparsing/support-requests/11/feed.rss" rel="self" type="application/rss+xml"/><item><title>#11 scanString start and end offsets incorrect.</title><link>https://sourceforge.net/p/pyparsing/support-requests/11/?limit=25#67c5</link><description>&lt;div class="markdown_content"&gt;&lt;p&gt;parseWithTabs() was the solution...&lt;/p&gt;
&lt;p&gt;Thanks&lt;br/&gt;
Gary&lt;/p&gt;&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Gary O'Leary-Steele</dc:creator><pubDate>Fri, 23 Oct 2015 20:51:55 -0000</pubDate><guid>https://sourceforge.net7e48b76c2a35a4d6c2c39ad31c944e2e41d1a6cf</guid></item><item><title>#11 scanString start and end offsets incorrect.</title><link>https://sourceforge.net/p/pyparsing/support-requests/11/?limit=25#26d8</link><description>&lt;div class="markdown_content"&gt;&lt;p&gt;Here is another example with simple grammar;&lt;/p&gt;
&lt;p&gt;import pyparsing as pp&lt;br/&gt;
variable = pp.Regex(r'\$&lt;span&gt;[a-zA-Z_\x7f-\xff]&lt;/span&gt;&lt;span&gt;[a-zA-Z0-9_\x7f-\xff]&lt;/span&gt;*').setResultsName('variable')&lt;/p&gt;
&lt;p&gt;grammar =  variable&lt;/p&gt;
&lt;p&gt;SAMPLE_PHP = r'''                 &lt;br/&gt;
    $test;&lt;br/&gt;
    $test1;&lt;br/&gt;
    $test2;&lt;br/&gt;
    $test3;  &lt;br/&gt;
}'''&lt;/p&gt;
&lt;p&gt;for token, start, stop in grammar.scanString(SAMPLE_PHP):&lt;br/&gt;
    print "{} &lt;span&gt;[{}:{}]&lt;/span&gt; from a string length of {}".format(token,start,stop,len(SAMPLE_PHP))&lt;/p&gt;
&lt;p&gt;I would have expected each token match to provide the offset of the match but its not working that way for me.&lt;/p&gt;&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Gary O'Leary-Steele</dc:creator><pubDate>Fri, 23 Oct 2015 20:20:54 -0000</pubDate><guid>https://sourceforge.net05c5dafc57b50a94300c1d98ffeb33dded893217</guid></item><item><title>scanString start and end offsets incorrect.</title><link>https://sourceforge.net/p/pyparsing/support-requests/11/</link><description>&lt;div class="markdown_content"&gt;&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;I'm using pyparsing to parse some PHP code and im trying to use scanString so that i can reference parsed components from the input text. For some reason im getting offsets for start and stop that are beyond the length of the string. Here is a simple example;&lt;/p&gt;
&lt;p&gt;def test_foreach_bug_standalong():&lt;br/&gt;
    '''&lt;br/&gt;
        test to diagnose a scanStringOffsetBug&lt;br/&gt;
    '''&lt;br/&gt;
    import pyparsing as pp&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span class="x"&gt;nested_block = pp.nestedExpr(opener="&lt;/span&gt;&lt;span class="err"&gt;{&lt;/span&gt;&lt;span class="x"&gt;", closer="}").setResultsName("block_code")&lt;/span&gt;
&lt;span class="x"&gt;foreach = pp.Group(pp.Literal("foreach") + "(" + ")" + \&lt;/span&gt;
&lt;span class="x"&gt;                nested_block&lt;/span&gt;
&lt;span class="x"&gt;                ).setResultsName("foreach")&lt;/span&gt;
&lt;span class="x"&gt;variable = pp.Regex(r'\&lt;/span&gt;&lt;span class="p"&gt;$&lt;/span&gt;&lt;span class="x"&gt;[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*').setResultsName('variable')&lt;/span&gt;

&lt;span class="x"&gt;grammar = foreach | variable&lt;/span&gt;

&lt;span class="x"&gt;SAMPLE_PHP = r'''&lt;/span&gt;
&lt;span class="x"&gt;        foreach()&lt;/span&gt;&lt;span class="err"&gt;{&lt;/span&gt;&lt;span class="x"&gt;          &lt;/span&gt;
&lt;span class="x"&gt;                eval(&lt;/span&gt;&lt;span class="p"&gt;$&lt;/span&gt;&lt;span class="nv"&gt;item&lt;/span&gt;&lt;span class="x"&gt;)&lt;/span&gt;
&lt;span class="x"&gt;            }                   &lt;/span&gt;
&lt;span class="x"&gt;        &lt;/span&gt;&lt;span class="p"&gt;$&lt;/span&gt;&lt;span class="nv"&gt;test&lt;/span&gt;&lt;span class="x"&gt;;&lt;/span&gt;

&lt;span class="x"&gt;}'''&lt;/span&gt;
&lt;span class="x"&gt;for token, start, stop in grammar.scanString(SAMPLE_PHP):&lt;/span&gt;
&lt;span class="x"&gt;    print "&lt;/span&gt;&lt;span class="err"&gt;{&lt;/span&gt;&lt;span class="x"&gt;} [&lt;/span&gt;&lt;span class="err"&gt;{&lt;/span&gt;&lt;span class="x"&gt;}:&lt;/span&gt;&lt;span class="err"&gt;{&lt;/span&gt;&lt;span class="x"&gt;}] from a string length of &lt;/span&gt;&lt;span class="err"&gt;{&lt;/span&gt;&lt;span class="x"&gt;}".format(token,start,stop,len(SAMPLE_PHP))&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;The output generated from this is as follows;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;[['foreach', '(', ')', ['eval($item)']&lt;/span&gt;]] &lt;span&gt;[6:72]&lt;/span&gt; from a string length of 88&lt;br/&gt;
&lt;span&gt;['$test']&lt;/span&gt; &lt;span&gt;[112:117]&lt;/span&gt; from a string length of 88&lt;/p&gt;
&lt;p&gt;As you can see, the second match points to a start if 112 and ends 117 which is longer than the string.&lt;/p&gt;
&lt;p&gt;Am i doing something wrong here?&lt;/p&gt;
&lt;p&gt;Thanks&lt;br/&gt;
Gary&lt;/p&gt;&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Gary O'Leary-Steele</dc:creator><pubDate>Fri, 23 Oct 2015 20:01:35 -0000</pubDate><guid>https://sourceforge.net455fccc8d7e737aa8e584147a6fae5d281220247</guid></item></channel></rss>