From 95449ab1ed5b71644c0609b7a5af1e7a1b5f5f2e Mon Sep 17 00:00:00 2001 From: Andrew Jewett Date: Thu, 6 Aug 2020 12:22:44 -0700 Subject: [PATCH] fixed an edge-case bug preventing generation of helpful error messages in response to non-sensical user input (eg "@atom:") --- moltemplate/scripts/moltemplate.sh | 4 ++-- moltemplate/ttree.py | 11 +++++++++-- setup.py | 4 ++-- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/moltemplate/scripts/moltemplate.sh b/moltemplate/scripts/moltemplate.sh index 97ab74b2..ec501485 100755 --- a/moltemplate/scripts/moltemplate.sh +++ b/moltemplate/scripts/moltemplate.sh @@ -6,8 +6,8 @@ # Copyright (c) 2013 G_PROGRAM_NAME="moltemplate.sh" -G_VERSION="2.18.4" -G_DATE="2020-8-05" +G_VERSION="2.18.5" +G_DATE="2020-8-06" echo "${G_PROGRAM_NAME} v${G_VERSION} ${G_DATE}" >&2 echo "" >&2 diff --git a/moltemplate/ttree.py b/moltemplate/ttree.py index bc82ce6b..42eddba1 100755 --- a/moltemplate/ttree.py +++ b/moltemplate/ttree.py @@ -102,8 +102,8 @@ g_module_name = g_filename if g_filename.rfind('.py') != -1: g_module_name = g_filename[:g_filename.rfind('.py')] -g_date_str = '2020-8-05' -g_version_str = '0.86.5' +g_date_str = '2020-8-06' +g_version_str = '0.86.6' class ClassReference(object): @@ -872,6 +872,7 @@ def FollowPathCounterVar(leaf_ptkns, starting_node, dbg_loc): is_static_node = isinstance(starting_node, StaticObj) + assert(len(leaf_ptkns) > 0) if is_static_node: is_simple_node = ((len(last_node.children) == 0) and (len(last_node.instance_commands) == 0) and @@ -1435,6 +1436,12 @@ def DescrToCatLeafNodes(descr_str, context_node, dbg_loc): cat_name, cat_ptkns, leaf_ptkns = DescrToCatLeafPtkns(descr_str, dbg_loc) + if len(leaf_ptkns) == 0: + raise InputError('Error(' + g_module_name + '.DescrToCatLeafNodes()):\n' + ' Error near ' + + ErrorLeader(dbg_loc.infile, dbg_loc.lineno) + '\n' + ' Illegal counter variable \"' + descr_str + '\"\n') + # ---- ellipsis hack ---- # # Search for class: diff --git a/setup.py b/setup.py index 9fd7c86a..0bc45b18 100644 --- a/setup.py +++ b/setup.py @@ -45,9 +45,9 @@ url='https://github.com/jewettaij/moltemplate', - download_url='https://github.com/jewettaij/moltemplate/archive/v2.18.4.zip', + download_url='https://github.com/jewettaij/moltemplate/archive/v2.18.5.zip', - version='2.18.4', + version='2.18.5', keywords=['simulation', 'LAMMPS', 'molecule editor', 'molecule builder', 'ESPResSo'],