--- /dev/null
+#!/bin/sh
+
+output="a.out"
+objects=""
+
+# Parse command line options
+while :; do
+ case $1 in
+ -o|--output)
+ if [ -n "$2" ]; then
+ output=$2
+ shift
+ else
+ printf 'ERROR: "--output" requires a non-empty option argument.\n' >&2
+ exit 1
+ fi
+ ;;
+ --output=?*)
+ output=${1#*=}
+ ;;
+ --output=)
+ printf 'ERROR: "--file" requires a non-empty option argument.\n' >&2
+ exit 1
+ ;;
+ *)
+ break
+ esac
+ shift
+done
+
+# Now assemble all the files
+PATH="$PWD:$PATH"
+export PATH
+for f in "$@"; do
+ cerise.rb "$f" > "$f.s"
+ aas.rb "$f.s" | as - -o "$f.o"
+ rm -f "$f.s"
+ objects="$objects $f.o"
+done
+
+# And link them altogether
+ld --gc-sections -o "$output" $objects
\ No newline at end of file
end
def self.emit_return(v)
+ emit(v.value)
+ puts " retwv"
end
def self.emit_const(v)
+ if v.value.is_a? Integer
+ puts " int #{v.value}"
+ end
end
end
$parser = Parser.new("cerise.m")
$parser.defs.each do |name, val|
puts "func #{name.to_sym.inspect} do"
+ val.value.body.each do |stmnt|
+ Codegen.emit(stmnt)
+ end
puts "end"
- puts val
+# puts val
end