Skip to content

Commit 93ff5ab

Browse files
committed
Updated script for doubles, chapter 13
1 parent a40b99a commit 93ff5ab

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

scripts/mycc

+14-5
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,20 @@
55
# Inputs: /path/to/program.c
66
# Outputs: /path/to/program (executable)
77

8-
# Use last argument as filepath.
9-
filepath=${!#}
8+
last=${!#}
9+
library=""
10+
# Library linking added page 301
11+
if [[ $last == '-lm' ]]; then
12+
library="-lm"
13+
# second to last arg.
14+
filepath="${@:(-2):1}"
15+
else
16+
filepath="$last"
17+
fi
18+
1019
# Strip the extension
1120
base="${filepath%.*}"
12-
# echo "Compiling $base (.c)"
21+
echo "Compiling $base (.c)"
1322

1423
# Preprocess
1524
gcc -E -P $base.c -o $base.i
@@ -23,9 +32,9 @@ else
2332
rv=$?
2433
if [[ $rv == '0' ]]; then
2534
if [[ $1 == '-c' ]]; then
26-
gcc -c $base.s -o $base.o
35+
gcc -c $base.s -o $base.o $library
2736
else
28-
gcc $base.s -o $base
37+
gcc $base.s -o $base $library
2938
fi
3039
fi
3140
if [[ $1 != '-S' ]]; then

src/com/plasstech/lang/c/lex/TokenType.java

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ public enum TokenType {
1717
LONG(true),
1818
UNSIGNED(true),
1919
SIGNED(true),
20+
DOUBLE(true),
2021
IDENTIFIER,
2122
// STRING_LITERAL,
2223
NUMERIC_LITERAL,

0 commit comments

Comments
 (0)