<table><tr><td style="">michaelh requested changes to this revision.<br />michaelh added a comment.<br />This revision now requires changes to proceed.
</td><a style="text-decoration: none; padding: 4px 8px; margin: 0 8px 8px; float: right; color: #464C5C; font-weight: bold; border-radius: 3px; background-color: #F7F7F9; background-image: linear-gradient(to bottom,#fff,#f1f0f1); display: inline-block; border: 1px solid rgba(71,87,120,.2);" href="https://phabricator.kde.org/D11888">View Revision</a></tr></table><br /><div><div><p>It would be great if you could add tests for <tt style="background: #ebebeb; font-size: 13px;">==</tt>, <tt style="background: #ebebeb; font-size: 13px;">:=</tt> and  <tt style="background: #ebebeb; font-size: 13px;">((...)...)</tt> to <tt style="background: #ebebeb; font-size: 13px;">autotests/unit/lib/advancedqueryparsertest.cpp</tt></p></div></div><br /><div><strong>INLINE COMMENTS</strong><div><div style="margin: 6px 0 12px 0;"><div style="border: 1px solid #C7CCD9; border-radius: 3px;"><div style="padding: 0; background: #F7F7F7; border-color: #e3e4e8; border-style: solid; border-width: 0 0 1px 0; margin: 0;"><div style="color: #74777d; background: #eff2f4; padding: 6px 8px; overflow: hidden;"><a style="float: right; text-decoration: none;" href="https://phabricator.kde.org/D11888#inline-59369">View Inline</a><span style="color: #4b4d51; font-weight: bold;">advancedqueryparser.cpp:35</span></div>
<div style="font: 11px/15px "Menlo", "Consolas", "Monaco", monospace; white-space: pre-wrap; clear: both; padding: 4px 0; margin: 0;"><div style="padding: 0 8px; margin: 0 4px; "><span class="p">{</span>
</div><div style="padding: 0 8px; margin: 0 4px; ">    <span class="n">QStringList</span> <span class="n">tokens</span><span class="p">;</span>
</div><div style="padding: 0 8px; margin: 0 4px; ">    <span class="n">QString</span> <span class="n">token</span><span class="p">;</span>
</div></div></div>
<div style="margin: 8px 0; padding: 0 12px;"><p style="padding: 0; margin: 8px;">Suggestion: Rename to <tt style="background: #ebebeb; font-size: 13px;">tokenList</tt>. It's less likely to confuse it with <tt style="background: #ebebeb; font-size: 13px;">token</tt> that way.</p></div></div><br /><div style="border: 1px solid #C7CCD9; border-radius: 3px;"><div style="padding: 0; background: #F7F7F7; border-color: #e3e4e8; border-style: solid; border-width: 0 0 1px 0; margin: 0;"><div style="color: #74777d; background: #eff2f4; padding: 6px 8px; overflow: hidden;"><a style="float: right; text-decoration: none;" href="https://phabricator.kde.org/D11888#inline-59363">View Inline</a><span style="color: #4b4d51; font-weight: bold;">advancedqueryparser.cpp:50</span></div>
<div style="font: 11px/15px "Menlo", "Consolas", "Monaco", monospace; white-space: pre-wrap; clear: both; padding: 4px 0; margin: 0;"><div style="padding: 0 8px; margin: 0 4px; background: rgba(251, 175, 175, .7);">            <span style="color: #74777d">// Spaces <span class="bright">and operators </span>end tokens</span>
</div><div style="padding: 0 8px; margin: 0 4px; background: rgba(151, 234, 151, .6);">            <span style="color: #74777d">// Spaces end tokens</span>
</div><div style="padding: 0 8px; margin: 0 4px; ">            <span style="color: #aa4000">if</span> <span class="p">(</span><span class="n">token</span><span class="p">.</span><span class="n">size</span><span class="p">()</span> <span style="color: #aa2211">></span> <span style="color: #601200">0</span><span class="p">)</span> <span class="p">{</span>
</div><div style="padding: 0 8px; margin: 0 4px; ">                <span class="n">tokens</span><span class="p">.</span><span class="n">append</span><span class="p">(</span><span class="n">token</span><span class="p">);</span>
</div></div></div>
<div style="margin: 8px 0; padding: 0 12px;"><p style="padding: 0; margin: 8px;">Please use  <tt style="background: #ebebeb; font-size: 13px;">!token.isEmpty()</tt><br />
(Don't exactly know why, but have myself been told so several times. Maybe it's faster. :-)</p></div></div><br /><div style="border: 1px solid #C7CCD9; border-radius: 3px;"><div style="padding: 0; background: #F7F7F7; border-color: #e3e4e8; border-style: solid; border-width: 0 0 1px 0; margin: 0;"><div style="color: #74777d; background: #eff2f4; padding: 6px 8px; overflow: hidden;"><a style="float: right; text-decoration: none;" href="https://phabricator.kde.org/D11888#inline-59360">View Inline</a><span style="color: #4b4d51; font-weight: bold;">advancedqueryparser.cpp:54</span></div>
<div style="font: 11px/15px "Menlo", "Consolas", "Monaco", monospace; white-space: pre-wrap; clear: both; padding: 4px 0; margin: 0;"><div style="padding: 0 8px; margin: 0 4px; ">            <span class="p">}</span>
</div><div style="padding: 0 8px; margin: 0 4px; background: rgba(251, 175, 175, .7);">
</div><div style="padding: 0 8px; margin: 0 4px; background: rgba(251, 175, 175, .7);">            <span style="color: #74777d">// <span class="bright">Operators</span> are tokens themselves</span>
</div><div style="padding: 0 8px; margin: 0 4px; background: rgba(151, 234, 151, .6);"><span class="bright">        </span><span class="p"><span class="bright">}</span></span><span class="bright"> </span><span style="color: #aa4000"><span class="bright">else</span></span><span class="bright"> </span><span style="color: #aa4000"><span class="bright">if</span></span><span class="bright"> </span><span class="p"><span class="bright">(</span></span><span class="bright"></span><span class="n"><span class="bright">c</span></span><span class="bright"> </span><span style="color: #aa2211"><span class="bright">==</span></span><span class="bright"> </span><span style="color: #766510"><span class="bright">'('</span></span><span class="bright"> </span><span style="color: #aa2211"><span class="bright">||</span></span><span class="bright"> </span><span class="n"><span class="bright">c</span></span><span class="bright"> </span><span style="color: #aa2211"><span class="bright">==</span></span><span class="bright"> </span><span style="color: #766510"><span class="bright">')'</span></span><span class="bright"></span><span class="p"><span class="bright">)</span></span><span class="bright"> </span><span class="p"><span class="bright">{</span></span>
</div><div style="padding: 0 8px; margin: 0 4px; background: rgba(151, 234, 151, .6);">            <span style="color: #74777d">// <span class="bright">Parentheses end tokens, and</span> are tokens<span class="bright"> by</span> themselves</span>
</div></div></div>
<div style="margin: 8px 0; padding: 0 12px;"><p style="padding: 0; margin: 8px;">Please use QLatin1Char</p></div></div><br /><div style="border: 1px solid #C7CCD9; border-radius: 3px;"><div style="padding: 0; background: #F7F7F7; border-color: #e3e4e8; border-style: solid; border-width: 0 0 1px 0; margin: 0;"><div style="color: #74777d; background: #eff2f4; padding: 6px 8px; overflow: hidden;"><a style="float: right; text-decoration: none;" href="https://phabricator.kde.org/D11888#inline-59365">View Inline</a><span style="color: #4b4d51; font-weight: bold;">advancedqueryparser.cpp:55</span></div>
<div style="font: 11px/15px "Menlo", "Consolas", "Monaco", monospace; white-space: pre-wrap; clear: both; padding: 4px 0; margin: 0;"><div style="padding: 0 8px; margin: 0 4px; background: rgba(251, 175, 175, .7);">            <span style="color: #74777d">// <span class="bright">Operators</span> are tokens themselves</span>
</div><div style="padding: 0 8px; margin: 0 4px; background: rgba(251, 175, 175, .7);">            <span style="color: #aa4000">if</span> <span class="p">(<span class="bright"></span></span><span class="bright"></span><span class="n"><span class="bright">isOperator</span></span><span class="bright"></span><span class="p"><span class="bright">(</span></span><span class="bright"></span><span class="n"><span class="bright">c</span></span><span class="bright"></span><span class="p"><span class="bright">)</span>)</span> <span class="p">{</span>
</div><div style="padding: 0 8px; margin: 0 4px; background: rgba(151, 234, 151, .6);"><span class="bright">        </span><span class="p"><span class="bright">}</span></span><span class="bright"> </span><span style="color: #aa4000"><span class="bright">else</span></span><span class="bright"> </span><span style="color: #aa4000"><span class="bright">if</span></span><span class="bright"> </span><span class="p"><span class="bright">(</span></span><span class="bright"></span><span class="n"><span class="bright">c</span></span><span class="bright"> </span><span style="color: #aa2211"><span class="bright">==</span></span><span class="bright"> </span><span style="color: #766510"><span class="bright">'('</span></span><span class="bright"> </span><span style="color: #aa2211"><span class="bright">||</span></span><span class="bright"> </span><span class="n"><span class="bright">c</span></span><span class="bright"> </span><span style="color: #aa2211"><span class="bright">==</span></span><span class="bright"> </span><span style="color: #766510"><span class="bright">')'</span></span><span class="bright"></span><span class="p"><span class="bright">)</span></span><span class="bright"> </span><span class="p"><span class="bright">{</span></span>
</div><div style="padding: 0 8px; margin: 0 4px; background: rgba(151, 234, 151, .6);">            <span style="color: #74777d">// <span class="bright">Parentheses end tokens, and</span> are tokens<span class="bright"> by</span> themselves</span>
</div><div style="padding: 0 8px; margin: 0 4px; background: rgba(151, 234, 151, .6);">            <span style="color: #aa4000">if</span> <span class="p">(<span class="bright"></span></span><span class="bright"></span><span class="n"><span class="bright">token</span></span><span class="bright"></span><span class="p"><span class="bright">.</span></span><span class="bright"></span><span class="n"><span class="bright">size</span></span><span class="bright"></span><span class="p"><span class="bright">()</span></span><span class="bright"> </span><span style="color: #aa2211"><span class="bright">></span></span><span class="bright"> </span><span style="color: #601200"><span class="bright">0</span></span><span class="p">)</span> <span class="p">{</span>
</div></div></div>
<div style="margin: 8px 0; padding: 0 12px;"><p style="padding: 0; margin: 8px;">// Parentheses delimit tokens, and are tokens by themselves</p></div></div><br /><div style="border: 1px solid #C7CCD9; border-radius: 3px;"><div style="padding: 0; background: #F7F7F7; border-color: #e3e4e8; border-style: solid; border-width: 0 0 1px 0; margin: 0;"><div style="color: #74777d; background: #eff2f4; padding: 6px 8px; overflow: hidden;"><a style="float: right; text-decoration: none;" href="https://phabricator.kde.org/D11888#inline-59361">View Inline</a><span style="color: #4b4d51; font-weight: bold;">advancedqueryparser.cpp:61</span></div>
<div style="font: 11px/15px "Menlo", "Consolas", "Monaco", monospace; white-space: pre-wrap; clear: both; padding: 4px 0; margin: 0;"><div style="padding: 0 8px; margin: 0 4px; background: rgba(151, 234, 151, .6);">            <span class="n">tokens</span><span class="p">.</span><span class="n">append</span><span class="p">(</span><span class="n">c</span><span class="p">);</span>
</div><div style="padding: 0 8px; margin: 0 4px; background: rgba(151, 234, 151, .6);">        <span class="p">}</span> <span style="color: #aa4000">else</span> <span style="color: #aa4000">if</span> <span class="p">(</span><span class="n">c</span> <span style="color: #aa2211">==</span> <span style="color: #766510">'>'</span> <span style="color: #aa2211">||</span> <span class="n">c</span> <span style="color: #aa2211">==</span> <span style="color: #766510">'<'</span> <span style="color: #aa2211">||</span> <span class="n">c</span> <span style="color: #aa2211">==</span> <span style="color: #766510">':'</span> <span style="color: #aa2211">||</span> <span class="n">c</span> <span style="color: #aa2211">==</span> <span style="color: #766510">'='</span><span class="p">)</span> <span class="p">{</span>
</div><div style="padding: 0 8px; margin: 0 4px; background: rgba(151, 234, 151, .6);">            <span style="color: #74777d">// Operators end tokens</span>
</div></div></div>
<div style="margin: 8px 0; padding: 0 12px;"><p style="padding: 0; margin: 8px;">Please use QLatin1Char</p></div></div><br /><div style="border: 1px solid #C7CCD9; border-radius: 3px;"><div style="padding: 0; background: #F7F7F7; border-color: #e3e4e8; border-style: solid; border-width: 0 0 1px 0; margin: 0;"><div style="color: #74777d; background: #eff2f4; padding: 6px 8px; overflow: hidden;"><a style="float: right; text-decoration: none;" href="https://phabricator.kde.org/D11888#inline-59366">View Inline</a><span style="color: #4b4d51; font-weight: bold;">advancedqueryparser.cpp:63</span></div>
<div style="font: 11px/15px "Menlo", "Consolas", "Monaco", monospace; white-space: pre-wrap; clear: both; padding: 4px 0; margin: 0;"><div style="padding: 0 8px; margin: 0 4px; background: rgba(151, 234, 151, .6);">            <span style="color: #74777d">// Operators end tokens</span>
</div><div style="padding: 0 8px; margin: 0 4px; background: rgba(151, 234, 151, .6);">            <span style="color: #aa4000">if</span> <span class="p">(</span><span class="n">token</span><span class="p">.</span><span class="n">size</span><span class="p">()</span> <span style="color: #aa2211">></span> <span style="color: #601200">0</span><span class="p">)</span> <span class="p">{</span>
</div><div style="padding: 0 8px; margin: 0 4px; background: rgba(151, 234, 151, .6);">                <span class="n">tokens</span><span class="p">.</span><span class="n">append</span><span class="p">(</span><span class="n">token</span><span class="p">);</span>
</div></div></div>
<div style="margin: 8px 0; padding: 0 12px;"><p style="padding: 0; margin: 8px;">Please use <tt style="background: #ebebeb; font-size: 13px;">!token.isEmpty()</tt></p></div></div><br /><div style="border: 1px solid #C7CCD9; border-radius: 3px;"><div style="padding: 0; background: #F7F7F7; border-color: #e3e4e8; border-style: solid; border-width: 0 0 1px 0; margin: 0;"><div style="color: #74777d; background: #eff2f4; padding: 6px 8px; overflow: hidden;"><a style="float: right; text-decoration: none;" href="https://phabricator.kde.org/D11888#inline-59362">View Inline</a><span style="color: #4b4d51; font-weight: bold;">advancedqueryparser.cpp:68</span></div>
<div style="font: 11px/15px "Menlo", "Consolas", "Monaco", monospace; white-space: pre-wrap; clear: both; padding: 4px 0; margin: 0;"><div style="padding: 0 8px; margin: 0 4px; background: rgba(251, 175, 175, .7);">            <span class="bright">    </span><span class="n"><span class="bright">tokens</span></span><span class="bright"></span><span class="p"><span class="bright">.</span></span><span class="bright"></span><span class="n"><span class="bright">append</span></span><span class="bright"></span><span class="p"><span class="bright">(</span></span><span class="bright"></span><span class="n"><span class="bright">QString</span></span><span class="bright"></span><span class="p"><span class="bright">(</span></span><span class="bright"></span><span class="n"><span class="bright">c</span></span><span class="bright"></span><span class="p"><span class="bright">));</span></span>
</div><div style="padding: 0 8px; margin: 0 4px; background: rgba(151, 234, 151, .6);">            <span class="bright"></span><span style="color: #74777d"><span class="bright">// accept '=' after any of the above</span></span>
</div><div style="padding: 0 8px; margin: 0 4px; background: rgba(151, 234, 151, .6);">            <span style="color: #aa4000">if</span> <span class="p">(</span><span class="n">text</span><span class="p">.</span><span class="n">at</span><span class="p">(</span><span class="n">i</span> <span style="color: #aa2211">+</span> <span style="color: #601200">1</span><span class="p">)</span> <span style="color: #aa2211">==</span> <span style="color: #766510">'='</span><span class="p">)</span> <span class="p">{</span>
</div><div style="padding: 0 8px; margin: 0 4px; background: rgba(151, 234, 151, .6);">                <span class="n">tokens</span><span class="p">.</span><span class="n">append</span><span class="p">(</span><span class="n">text</span><span class="p">.</span><span class="n">mid</span><span class="p">(</span><span class="n">i</span><span class="p">,</span> <span style="color: #601200">2</span><span class="p">));</span>
</div></div></div>
<div style="margin: 8px 0; padding: 0 12px;"><p style="padding: 0; margin: 8px;">Please use QLatin1Char</p></div></div><br /><div style="border: 1px solid #C7CCD9; border-radius: 3px;"><div style="padding: 0; background: #F7F7F7; border-color: #e3e4e8; border-style: solid; border-width: 0 0 1px 0; margin: 0;"><div style="color: #74777d; background: #eff2f4; padding: 6px 8px; overflow: hidden;"><a style="float: right; text-decoration: none;" href="https://phabricator.kde.org/D11888#inline-59375">View Inline</a><span style="color: #4b4d51; font-weight: bold;">advancedqueryparser.cpp:69</span></div>
<div style="font: 11px/15px "Menlo", "Consolas", "Monaco", monospace; white-space: pre-wrap; clear: both; padding: 4px 0; margin: 0;"><div style="padding: 0 8px; margin: 0 4px; background: rgba(151, 234, 151, .6);">            <span style="color: #aa4000">if</span> <span class="p">(</span><span class="n">text</span><span class="p">.</span><span class="n">at</span><span class="p">(</span><span class="n">i</span> <span style="color: #aa2211">+</span> <span style="color: #601200">1</span><span class="p">)</span> <span style="color: #aa2211">==</span> <span style="color: #766510">'='</span><span class="p">)</span> <span class="p">{</span>
</div><div style="padding: 0 8px; margin: 0 4px; background: rgba(151, 234, 151, .6);">                <span class="n">tokens</span><span class="p">.</span><span class="n">append</span><span class="p">(</span><span class="n">text</span><span class="p">.</span><span class="n">mid</span><span class="p">(</span><span class="n">i</span><span class="p">,</span> <span style="color: #601200">2</span><span class="p">));</span>
</div><div style="padding: 0 8px; margin: 0 4px; background: rgba(151, 234, 151, .6);">                <span class="n">i</span><span style="color: #aa2211">++</span><span class="p">;</span>
</div></div></div>
<div style="margin: 8px 0; padding: 0 12px;"><p style="padding: 0; margin: 8px;">':' means <tt style="background: #ebebeb; font-size: 13px;">Term::Contains</tt> and '=' means <tt style="background: #ebebeb; font-size: 13px;">Term::Equal</tt> so ':=' is a little ambigous. <br />
Unless you have a particular reason to interpret ':=' as '=' we should take it as ':'.<br />
It may be better to have and extra <tt style="background: #ebebeb; font-size: 13px;">If</tt> for '=' and ':' and simply drop any second "=" so we come out with ':' or '=' as token.</p>

<p style="padding: 0; margin: 8px;">The <tt style="background: #ebebeb; font-size: 13px;">parse()</tt> function checks the second char only in case of '<' or '>'. So ':=' will become ':'. The<br />
2-char tokens should to be added to the <tt style="background: #ebebeb; font-size: 13px;">switch</tt> in <tt style="background: #ebebeb; font-size: 13px;">parse()</tt> which then also could be simplified. The distinction between '>' and '>=' is the lexer's job, right?</p></div></div></div></div></div><br /><div><strong>REPOSITORY</strong><div><div>R293 Baloo</div></div></div><br /><div><strong>REVISION DETAIL</strong><div><a href="https://phabricator.kde.org/D11888">https://phabricator.kde.org/D11888</a></div></div><br /><div><strong>To: </strong>bruns, Baloo, michaelh<br /><strong>Cc: </strong>Frameworks, ashaposhnikov, michaelh, astippich, spoorun, ngraham, alexeymin<br /></div>