    <rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:admin="http://webns.net/mvcb/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:content="http://purl.org/rss/1.0/modules/content/">
     <channel>
        <title>ACCU  :: Letters to the Editor(s)</title>
        <link>https://members.accu.org/index.php/journals/334</link>
        <description>Professionalism in Programming</description>
        <dc:language>en-us</dc:language> 
        <dc:creator>Administrator</dc:creator> 
        <admin:generatorAgent rdf:resource="http://www.xaraya.org" /> 
        <admin:errorReportsTo rdf:resource="mailto:webeditor@accu.org" />
       <sy:updatePeriod>hourly</sy:updatePeriod>
       <sy:updateFrequency>1</sy:updateFrequency>
       <docs>http://backend.userland.com/rss</docs>


        <h2>Journal Articles</h2>


<div class="xar-mod-head"><span class="xar-mod-title">Overload Journal #57 - Oct 2003 + Letters to the Editor</span></div>

<table border="0" cellpadding="1" cellspacing="0">
    <tbody>
    <tr>
        <td valign="top">
            Browse in :
       </td>
       <td valign="top">

                                            <a href="https://members.accu.org/index.php/journals/">All</a>

                     &gt;                         <a href="https://members.accu.org/index.php/journals/c76/">Journals</a>

                     &gt;                         <a href="https://members.accu.org/index.php/journals/c78/">Overload</a>

                     &gt;                         <a href="https://members.accu.org/index.php/journals/c155/">57</a>
                    (12)
<br />

                                            <a href="https://members.accu.org/index.php/journals/">All</a>

                     &gt;                         <a href="https://members.accu.org/index.php/journals/c184/">Journal Columns</a>

                     &gt;                         <a href="https://members.accu.org/index.php/journals/c186/">LettersEditor</a>
                    (132)
<br />

                                            <a href="https://members.accu.org/index.php/journals/c155-186/">Any of these categories</a>

                    -                        <a href="https://members.accu.org/index.php/journals/c155+186/">All of these categories</a>
<br />
</td>
   </tr>
   </tbody>
</table>




<div class="xar-error">
   <p>
 <strong>Note:</strong> when you create a new publication type,
the articles module will automatically use the templates
<em>user-display-[publicationtype].xt</em>
and <em>user-summary-[publicationtype].xt</em>.
If those templates do not exist when you try to preview or display a new article,
you'll get this warning :-)  Please place your own templates in themes/<em>yourtheme</em>/modules/articles . The templates will get the extension .xt there. </p>
</div>
<div class="xar-norm xar-standard-box-padding">
   <h1><strong>Title:</strong>&nbsp;Letters to the Editor(s)</h1>
<p><strong>Author:</strong>&nbsp;</p>
<p>
<strong>Date:</strong> 02 October 2003 22:56:14 +01:00 or Thu, 02 October 2003 22:56:14 +01:00</p>
<p><strong>Summary:</strong>&nbsp;</p>
<p><strong>Body:</strong>&nbsp;<div class="sect1" lang="en">
<div class="titlepage">
<h2><a name="d0e20" id="d0e20"></a></h2>
</div>
<p>Fundamentally, this paper describes a technique for writing
recursive-descent parsers in C++ using operator overloading so that
the driving logic of the parser is written in a way that looks like
the parsed grammar rules. As presented, I think the technique is
not usable, but it is not completely flawed and can be made
usable.</p>
<p>My first comment is on usefulness. The author states &quot;while C++
is certainly capable of handling recursion, the language is not
really capable of handling recursive definitions such as the
grammar in its present state&quot;. I'm not so sure I understand that
sentence correctly as there is no explanation of what is lacking to
handle &quot;recursive definitions such as the grammar in its present
state&quot;. I think that what is hinted at is that applying the given
technique to a (directly or not) recursive grammar would produce
code with infinite recursion. While some use of recursion can be
removed by using closures (which the technique is able to handle by
special casing), not all can and I don't think parsing techniques
unable to handle recursion in a grammar are particularly useful. I
don't know how this problem is removed in functional programming
languages (Haskell could perhaps handle it using lazy evaluation,
but not Common Lisp). Related to this, the author presents a second
grammar as a rewriting of the original one with recursion removed.
There is no recursion in the second grammar, but the parsed
language is quite different to the one of the first grammar (and I
don't think rewriting could remove recursion for that grammar while
still parsing the same language).</p>
<p>My second comment is on the error handling, reporting and
recovery. There is no explanation of the way errors in the parsed
input are supposed to be reported, and as the technique uses
backtracking, the naive way is not valid. The code presented just
doesn't consume anything on the input in the presence of an error,
and nothing is present in the output to indicate that an error
occurred. There is also no error recovery strategy, but that's a
minor point as I don't know a general parsing technique using
backtracking with an error recovery strategy.</p>
<p>My next comment is on performance. The author states that the
code presented is not optimised for speed of execution, nor for
space, but is not slow. How do you qualify a parser with an
exponential behaviour in terms of input length? Indeed, alternation
is handled by backtracking and using backtracking without early
termination due to error detection can lead to exponential time
behaviour even in simple grammars which are parsable using LL(1)
parser. A comparatively minor inefficiency is that the remaining
input is copied around and in most grammars I know, tail rules
consume a bounded (and often quite limited) number of tokens. This
alone would give an O(N?) behaviour.</p>
<p>The technique presented is interesting, and can be ameliorated
to the point of being usable. For example, an error state could be
added to the result. It can be used as a criteria for the
alternation operator (if several cases are not errors, that can be
considered as an error or handled with the list of results approach
given in the paper - this is better that the &quot;use the longest
match&quot; rule used first in the paper) and to stop parsing by the
sequence operator. With that modification, first, one should be
able to handle non left recursive grammars (the Dragon book gives
an algorithm to remove any left recursion of a grammar) and second,
the exponential behaviour is removed leaving us with the quadratic
one.</p>
<p>Removing the quadratic behaviour is easy: instead of copying a
list around, use an iterator. After that, I guess that the parser
will have a linear time behaviour for LL(k) grammars and be able to
handle any non ambiguous grammar or any grammar with the list of
results approach.</p>
<p>Now, how to report errors to the user in a useful way? As the
method uses backtracking, it is not possible to report the error
when it is detected. A possibility is to add an error message and
an error position to the error state. In case of error, alternation
would build an special error message if the error is that an
ambiguity is detected or choose one of the error messages (the one
which produced the longest parse before failing is the obvious
candidate) of the failing cases when all possibilities fail.</p>
<p>One would still miss an error recovery scheme (that is how to
continue to parse after having reported one error so that other
errors can be reported), but, as I've never seen one presented for
parsing techniques using backtracking, this is a very minor
point.</p>
<p>Browsing <a href="http://www.boost.org/" target=
"_top">boost.org</a> I found out that they have a parser framework.
From the documentation it looks like a finalized variation on the
same themes as Frank's paper taking into account my comments. It
surely needs to be looked at by anyone wanting to expand on Frank's
paper for a purpose other than experimentation with C++ syntax or
parser definition.</p>
</div>
</p>
<p><strong>Notes:</strong>&nbsp;</p>
<p><em>More fields may be available via dynamicdata ..</em></p>
</div>
</channel>
</rss>
