Skip to content
This repository has been archived by the owner on Jun 6, 2020. It is now read-only.

Commit

Permalink
Added compilation buffer
Browse files Browse the repository at this point in the history
  • Loading branch information
G. Roggemans committed May 17, 2016
1 parent 8bbfce2 commit cf9b0ef
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/compiler.bash
Original file line number Diff line number Diff line change
Expand Up @@ -57,19 +57,22 @@ compiler.compile() {

# Target defaults to "$file.out"
local target="${2:-${file}.out}"
local tmp_target="$(mktemp /tmp/ec_out-XXXXXX)"

#@TODO Compile to tmp file and replace if successful

# Preserve leading whitespace by changing word separator
IFS=$'\n'

msg.bold "Compiling $file_name"
echo "$EC_COMMENT Compiled by Ellipsis-Compiler on $(date)" > "$target"
echo "$EC_COMMENT Compiled by Ellipsis-Compiler on $(date)" > "$tmp_target"
compiler.parse_file "$file"

# Reset IFS to default
unset IFS

mv "$tmp_target" "$target"

#@TODO Log if config changed
msg.print "Successfully compiled $file_name"
}
Expand Down Expand Up @@ -209,7 +212,7 @@ compiler.parse_line() {
;;
\>|write)
if "$output"; then
echo "$line" >> "$target"
echo "$line" >> "$tmp_target"
fi
;;
msg)
Expand All @@ -229,7 +232,7 @@ compiler.parse_line() {
# Ignore commented and empty lines
:
elif "$output"; then
echo "$line" >> "$target"
echo "$line" >> "$tmp_target"
fi
}

Expand Down

0 comments on commit cf9b0ef

Please sign in to comment.