#!/bin/bash # If this file has already been sourced, just return test $(LISHP_SH+true)TODO && return declare -g LISHP_SH = 'true'TODO declare -g VERBOSE = '' if test $(1+isset) && test $1 == "-verbose" { setglobal VERBOSE = 'true' shift } else { setglobal VERBOSE = 'false' } source ${BASH_SOURCE%/*}/common.sh source ${BASH_SOURCE%/*}/variables.sh source ${BASH_SOURCE%/*}/variables.arraylist.sh source ${BASH_SOURCE%/*}/variables.atom.sh source ${BASH_SOURCE%/*}/variables.linkedlist.sh source ${BASH_SOURCE%/*}/variables.map.sh source ${BASH_SOURCE%/*}/variables.queue.sh source ${BASH_SOURCE%/*}/variables.stack.sh source ${BASH_SOURCE%/*}/callable.sh source ${BASH_SOURCE%/*}/callable.lambda.sh source ${BASH_SOURCE%/*}/environment.sh source ${BASH_SOURCE%/*}/evaluator.sh source ${BASH_SOURCE%/*}/evaluator.functions.builtin.sh source ${BASH_SOURCE%/*}/parser.sh source ${BASH_SOURCE%/*}/logger.sh source ${BASH_SOURCE%/*}/specialforms.sh source ${BASH_SOURCE%/*}/specialforms.if.sh source ${BASH_SOURCE%/*}/specialforms.lambda.sh source ${BASH_SOURCE%/*}/specialforms.let.sh source ${BASH_SOURCE%/*}/specialforms.letstar.sh $VERBOSE && echo "Sourced libraries!" # (lambda (x y) # (+ x y) # per: http://stackoverflow.com/questions/6980090/bash-read-from-file-or-stdin # This will read from the filename specified as a parameter... # or from stdin if none specified read -r -d '' code < $(1:-/proc/${$}/fd/0) $VERBOSE && echo "Code read!" $VERBOSE && echo ================= $VERBOSE && echo $code $VERBOSE && echo ================= if ! parser::parse::multiExpression $(code) { echo "Could not parse input ==== $(code) ====" exit 1 } $VERBOSE && echo "Parsed!" #variable::printMetadata #variable::toSexp "${PARSER_PARSED}" ; echo ${RESULT} #variable::debug "${PARSER_PARSED}" ; echo ${RESULT} environment::newTODO ; declare env = $(RESULT) evaluator::setup_builtins $(env) $VERBOSE && echo "Environment setup!" evaluator::evalFromLinkedList $(env) $(PARSER_PARSED) variable::debug $(RESULT) $VERBOSE && echo "Done!" $VERBOSE && echo ================= echo $RESULT $VERBOSE && echo =================