Skip to content

Commit

Permalink
Fix handling of brackets following greek symbols (or more generally '…
Browse files Browse the repository at this point in the history
…backslashnames') following sub- or superscript characters.
  • Loading branch information
Kasper Peeters committed Oct 3, 2024
1 parent 057e6ce commit 04640fe
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 6 deletions.
2 changes: 1 addition & 1 deletion cmake/version.cmake
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
set(CADABRA_VERSION_MAJOR 2)
set(CADABRA_VERSION_MINOR 5)
set(CADABRA_VERSION_PATCH 6)
set(CADABRA_VERSION_PATCH 7)
set(CADABRA_VERSION_TWEAK 0)
set(CADABRA_VERSION_SEM ${CADABRA_VERSION_MAJOR}.${CADABRA_VERSION_MINOR}.${CADABRA_VERSION_PATCH})
set(COPYRIGHT_YEARS "2001-2024")
Expand Down
15 changes: 14 additions & 1 deletion core/Parser.cc
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ You should have received a copy of the GNU General Public License
#include <iostream>
#include <typeinfo>

//#define DEBUG 1
// #define DEBUG 1

std::istream& operator>>(std::istream& str, cadabra::Parser& pa)
{
Expand Down Expand Up @@ -394,6 +394,19 @@ bool Parser::string2tree(const std::string& inp)
tmp.clear();
break;
}
if(is_opening_bracket(c)!=str_node::b_no) {
// This happens with e.g. `\partial_\theta{f}`. The `\theta`
// is a backslashname, and should be terminated as soon as
// the opening brace is found. If you want the whole thing
// to go into the subscript you should use `\partial_{\theta{f}}`
// and that will then not trigger backslashname (just ordinary name).
current_mode.pop_back();
tree->append_child(current_parent,str_node(tmp,
current_bracket.back(),
current_parent_rel.back()));
tmp.clear();
break;
}
tmp+=c;
advance(i);
if(c=='\"')
Expand Down
10 changes: 10 additions & 0 deletions tests/basic.cdb
Original file line number Diff line number Diff line change
Expand Up @@ -392,3 +392,13 @@ def test42():
print("Test 42b passed")

test42()

def test43():
ex:=\partial_\theta{A};
tst:= \partial_{\theta}{A} - @(ex);
assert(tst==0)
print("Test 43 passed")

test43()


24 changes: 20 additions & 4 deletions web2/cadabra2/source/changelog.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,32 @@ <h1>Change log</h1>
the code level, consult
the <a href="http://github.com/kpeeters/cadabra2">github
repository</a>. Odd patch levels correspond to versions in
development, even numbered ones are released in packaged form.
development which you can only get by building from source, while
even-numbered ones are released in packaged/installer form.
</p>
<a name="microtex"></a>
<h3>github microtex branch (2.5.x)</h3>
<a name="devel"></a>
<h3>github devel branch (2.5.7)</h3>
<ul>
<li>Fix handling of spurious backslashes
(<a href="https://github.com/kpeeters/cadabra2/issues/240">#240</a>)
and double backslashes
(<a href="https://github.com/kpeeters/cadabra2/issues/155">#155</a>).</li>
<li>Fix handling of backslash names (e.g. Greek characters)
appearing without curly brackets as sub- or superscripts
(<a href="https://github.com/kpeeters/cadabra2/issues/312">#312</a>).</li>
<li>Fix the path to our python files in the Docker container
build.</li>
<li>When an expression is fed through the sympy bridge, make sure to
not remove outer parent relations (so that the expression remains a
sub/superscript if it was one before entering the bridge).</li>
</ul>

<a name="master"></a>
<h3>github master branch (2.5.2)</h3>
<h3>2.5.6 (released 29-Sep-2024)</h3>
<ul>
<li>Windows build is working again, now using MSYS2 because that's the only system that provides binary packages of our dependencies and also still carries gtkmm-3.0. An installer is now auto-generated by the CI on every release.</li>
<li>Updates to the AppImage build to fix issues with sympy and matplotlib.</li>
<li>Many other small fixes and updates to ensure that all binaries can be built by the CI.</li>
</ul>

<h3>2.5.2 (released 14-Jun-2024)</h3>
Expand Down

0 comments on commit 04640fe

Please sign in to comment.