-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor!: convert plcc.py to python package plcc
BREAKING CHANGE: plcc is now a Python package, and plcc.py has been removed. So plcc.py can no longer be called directly like this python3 path/to/plcc.py grammar Instead, use plcc like this plcc grammar --- This commit restructures the PLCC codebase into that of a conventional Python project. This should make it easier to redesign the internal structure of PLCC, making it easier to maintain and add new functionality. It should also help us prepare to distribute PLCC through PyPI, making it easier to install. Here is a summary of changes. - Convert plcc.py into python package plcc - Remove environment variable LIBPLCC - Move src/Std/ under src/plcc (the PLCC Python package) - Move lib/jackson under src/plcc (the PLCC Python package) - Pull common functionality of scripts into common.bash --- Related Issues - Related to #119 - Closes #121 - Closes #120
- Loading branch information
1 parent
f773580
commit 231d139
Showing
43 changed files
with
151 additions
and
205 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,10 @@ | ||
#!/usr/bin/env bash | ||
PLCC_DIR="$(dirname -- "${BASH_SOURCE[0]}" )/../.." | ||
PLCC_DIR="$(cd -- "${PLCC_DIR}" &> /dev/null && pwd)" | ||
|
||
echo " | ||
export LIBPLCC=\"${HOME}/.local/lib/plcc/src\" | ||
export PATH=\"\${LIBPLCC}:\$PATH\" | ||
export PATH=\"${PLCC_DIR}/src/plcc/bin:\$PATH\" | ||
function plcc-con() { | ||
docker run --rm -it -v \"\$PWD:/workdir\" --user \"\$(id -u):\$(id -g)\" ghcr.io/ourplcc/plcc:latest \"\$@\" | ||
} | ||
" | ||
" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
|
||
init() { | ||
set -euo pipefail | ||
if is_first_call_to_init ; then return 0 ; fi | ||
define_PLCC_DIR | ||
update_PYTHONPATH | ||
update_CLASSPATH | ||
} | ||
|
||
is_first_call_to_init() { | ||
if [[ -n "${PLCC_FIRST_CALL_TO_INIT:-}" ]] ; then | ||
return 0 | ||
else | ||
PLCC_FIRST_CALL_TO_INIT='false' | ||
export PLCC_FIRST_CALL_TO_INIT | ||
return 1 | ||
fi | ||
} | ||
|
||
define_PLCC_DIR() { | ||
PLCC_DIR="$( abspath "$( dirname -- "${BASH_SOURCE[0]}" )/../.." )" | ||
export PLCC_DIR | ||
} | ||
|
||
update_PYTHONPATH() { | ||
PYTHONPATH="${PYTHONPATH:+${PYTHONPATH}:}${PLCC_DIR}" | ||
export PYTHONPATH | ||
} | ||
|
||
update_CLASSPATH() { | ||
JACKSON_VERSION="2.15.2" | ||
JACKSON_ANNOTATIONS="${PLCC_DIR}/plcc/lib/jackson/jackson-annotations-${JACKSON_VERSION}.jar" | ||
JACKSON_CORE="${PLCC_DIR}/plcc/lib/jackson/jackson-core-${JACKSON_VERSION}.jar" | ||
JACKSON_DATABIND="${PLCC_DIR}/plcc/lib/jackson/jackson-databind-${JACKSON_VERSION}.jar" | ||
CP="./Java:${JACKSON_ANNOTATIONS}:${JACKSON_CORE}:${JACKSON_DATABIND}" | ||
CLASSPATH="${CLASSPATH:+${CLASSPATH}:}${CP}" | ||
export CLASSPATH | ||
} | ||
|
||
abspath() { echo "$( cd -- "${1}" &> /dev/null && pwd )" ; } | ||
|
||
assert_file_exists (){ | ||
[ -f "${1}" ] || { | ||
echo "${1} missing" >&2 | ||
exit 2 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#!/usr/bin/env bash | ||
source "$(dirname -- "${BASH_SOURCE[0]}" )/common.bash" && init | ||
|
||
assert_file_exists Java/Parse.class | ||
|
||
if echo "$*" | grep -- "--json_ast" &> /dev/null | ||
then | ||
|
||
ARGS=() | ||
while [ $# -gt 0 ] ; do | ||
case "$1" in | ||
--json_ast) | ||
shift | ||
;; | ||
*) | ||
ARGS+=("$1") | ||
shift | ||
;; | ||
esac | ||
done | ||
|
||
if ! java ParseJsonAst "${ARGS[@]}" ; then | ||
>&2 echo "Did you forget to pass --json_ast to plccmk?" | ||
exit 1 | ||
fi | ||
else | ||
java Parse "$@" | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/usr/bin/env bash | ||
source "$(dirname -- "${BASH_SOURCE[0]}" )/common.bash" && init | ||
|
||
python3 -m plcc "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#!/usr/bin/env bash | ||
source "$(dirname -- "${BASH_SOURCE[0]}" )/common.bash" && init | ||
|
||
if [[ "${1:-}" == "-c" ]] | ||
then | ||
rm -f Java/*.java Java/*.class | ||
shift | ||
fi | ||
|
||
if [ $# -eq 0 ] | ||
then | ||
DEFAULT=spec | ||
[ -f "$DEFAULT" ] || DEFAULT=grammar | ||
set - $DEFAULT | ||
fi | ||
|
||
plcc "$@" | ||
(cd ./Java ; javac *.java) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#!/usr/bin/env bash | ||
source "$(dirname -- "${BASH_SOURCE[0]}" )/common.bash" && init | ||
|
||
assert_file_exists Java/Rep.class | ||
java Rep "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#!/usr/bin/env bash | ||
source "$(dirname -- "${BASH_SOURCE[0]}" )/common.bash" && init | ||
|
||
assert_file_exists Java/Scan.class | ||
java Scan |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.