I have to convert the following shell file into a batch file:
\#!/bin/bash
\#
\# Generates and compiles a lexer or parser and runs it (this means
\# that the lexer/parser must contain a main method)
\#
\# Example usage: antlr4-run.sh Lexer.g4
DIR="$(cd `dirname "${BASH_SOURCE[0]}"` && pwd)"
ANTLR_JAR=$DIR/lib/antlr-4.2.2-complete.jar
BASENAME="${1%.*}"
OUTDIR=out
echo "Generating..."
java -jar $ANTLR_JAR $1 -o $OUTDIR || exit 1
echo "Compiling..."
(cd $OUTDIR; javac -cp .:$ANTLR_JAR ${BASENAME}*.java) || exit 1
\#\# run (try parser first, then lexer, then plain)
echo "Input (end with ^D):"
if [[ -a $OUTDIR/${BASENAME}Parser.class ]] ; then
(cd $OUTDIR; java -cp .:$ANTLR_JAR ${BASENAME}Parser) || exit 1
elif [[ -a $OUTDIR/${BASENAME}Lexer.class ]] ; then
(cd $OUTDIR; java -cp .:$ANTLR_JAR ${BASENAME}Lexer) || exit 1
elif [[ -a $OUTDIR/${BASENAME}.class ]] ; then
(cd $OUTDIR; java -cp .:$ANTLR_JAR ${BASENAME}) || exit 1
fi
exit 1
Could you please help me with give an example for the following line?
DIR="$(cd `dirname "${BASH_SOURCE[0]}"` && pwd)"
I know that I have to define a variable in a batch file with set Directory ="..." for example and that $
is a commandoline parameter
... but I don't know how to write this line in a batch file :/