diff --git a/.gitignore b/.gitignore index e92e2846..bbebfa4b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,12 @@ +# This is created by bin/test/languages.bash. But should not be committed. +languages/ + # PLCC places generated Java files in directories named Java. Ignore them. Java/ +# PLCC places generated Python files in directories named Python. Ignore them. +Python/ + # Created by Docker environment .bash_history diff --git a/bin/test/languages.bash b/bin/test/languages.bash new file mode 100644 index 00000000..31d442eb --- /dev/null +++ b/bin/test/languages.bash @@ -0,0 +1,14 @@ +#!/usr/bin/env bash + +set -euo pipefail + +LANGUAGES_VERSION="${LANGUAGES_VERSION:-}" +cd /tmp + +rm -rf languages +git clone https://github.com/ourPLCC/languages.git +if [ -n "${LANGUAGES_VERSION}" ] ; then + git -C ./languages checkout "${LANGUAGES_VERSION}" +fi +languages/bin/test.bash +rm -rf languages diff --git a/docs/Developer.md b/docs/Developer.md index 121ba556..e2756cbb 100644 --- a/docs/Developer.md +++ b/docs/Developer.md @@ -211,6 +211,20 @@ bin/test/everything.bash bin/test/functionality.bash ``` +### Test languages + +Check if our changes work with ourPLCC/languages: + +```bash +bin/test/languages.bash +``` + +Test a specific version (git tag, branch, or commit hash) of ourPLCC/languages: + +```bash +LANGUAGES_VESRION=v1.0.1 bin/test/languages.bash +``` + ### Test other things To learn what other class of tests you can run... diff --git a/src/plcc.py b/src/plcc.py index 6175555f..a2f5bc72 100644 --- a/src/plcc.py +++ b/src/plcc.py @@ -719,7 +719,7 @@ def python_makeAbstractStub(base): #{base}:top# #{base}:import# -class {base}({ext}): #{base}:class# +class {base}({ext}): #{base}:class# className = "{base}" @@ -843,7 +843,7 @@ def python_makeStub(cls): #{cls}:import# # {ruleString} -class {cls}({ext}): #{cls}:class# +class {cls}({ext}): #{cls}:class# className = "{cls}" ruleString = "{ruleString}" @@ -1101,7 +1101,7 @@ def sem(nxt): deathLNO('no stub for class {} -- cannot replace //{}:{}//'.format(cls, cls, mod)) stubs[cls] = codeString semFinishUp() - + def getCode(nxt): code = [] @@ -1130,10 +1130,11 @@ def getCode(nxt): else: deathLNO('premature end of file') lineMode = False # switch off line mode - while len(code[0]) == 0: - code.pop(0) - while len(code[-1]) == 0: - code.pop() + if len(code)>0 : + while len(code[0]) == 0: + code.pop(0) + while len(code[-1]) == 0: + code.pop() return code def semFinishUp():