Skip to content
Snippets Groups Projects
Commit 68d4c5b0 authored by Jaime Arias's avatar Jaime Arias
Browse files

feat: add tranformation to the cli

parent 16684433
No related branches found
No related tags found
No related merge requests found
...@@ -65,7 +65,14 @@ function parse_imitator { ...@@ -65,7 +65,14 @@ function parse_imitator {
local imitator_model=$1 local imitator_model=$1
local method=$2 local method=$2
local parser="./nptav2maude/app.py" local parser="./nptav2maude/app.py"
local parser_src="./nptav2maude/src"
local output_file="${imitator_model%.*}.maude" local output_file="${imitator_model%.*}.maude"
# check if grammar exists
if [ ! -d "${parser_src}/dist" ]; then
(cd ${parser_src} && antlr -Dlanguage=Python3 -no-listener -visitor -o dist Imitator.g4)
fi
echo -e "\nParsing ${imitator_model} with method \"${method}\" ..." echo -e "\nParsing ${imitator_model} with method \"${method}\" ..."
python3 ${parser} --input "${imitator_model}" --output "${output_file}" --method "${method}" python3 ${parser} --input "${imitator_model}" --output "${output_file}" --method "${method}"
} }
...@@ -142,11 +149,12 @@ function create_package { ...@@ -142,11 +149,12 @@ function create_package {
############################################################################## ##############################################################################
function usage { function usage {
# Display help # Display help
echo "Usage: $(basename "$0") [-d|h] [-r MODEL METHOD SOLVER TIMEOUT]" echo "Usage: $(basename "$0") [-d|h] [-r MODEL METHOD SOLVER TIMEOUT] [-t MODEL METHOD]"
echo echo
echo -e " -d, --deploy Create package with all the files." echo -e " -d, --deploy Create package with all the files."
echo -e " -h, --help Print this help." echo -e " -h, --help Print this help."
echo -e " -r, --run Run Maude using a PTA as input." echo -e " -r, --run Run Maude using a PTA as input."
echo -e " -t, --transform Transform a PTA into Maude."
echo echo
exit 1 exit 1
} }
...@@ -157,7 +165,7 @@ function usage { ...@@ -157,7 +165,7 @@ function usage {
# If no arguments provided, display usage information # If no arguments provided, display usage information
[[ $# -eq 0 ]] && usage [[ $# -eq 0 ]] && usage
while getopts ":hdr:" options; do while getopts ":hdr:t:" options; do
case "${options}" in case "${options}" in
h) # display Help h) # display Help
usage ;; usage ;;
...@@ -171,6 +179,12 @@ while getopts ":hdr:" options; do ...@@ -171,6 +179,12 @@ while getopts ":hdr:" options; do
run_pipeline "$@" run_pipeline "$@"
exit exit
;; ;;
t) # run the parser
shift 1
[[ $# -ne 2 ]] && usage
parse_imitator "$@"
exit
;;
*) # incorrect option *) # incorrect option
echo -e "Error: Invalid option\n" echo -e "Error: Invalid option\n"
usage usage
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment