Skip to content

Commit 98e8aa9

Browse files
authored
Merge pull request #121 from cmsc430/stdin
Stdin
2 parents fc31655 + 2cc2cdc commit 98e8aa9

File tree

105 files changed

+590
-656
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

105 files changed

+590
-656
lines changed

langs/abscond/Makefile

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@ UNAME := $(shell uname)
22

33
ifeq ($(UNAME), Darwin)
44
format=macho64
5+
CC=arch -x86_64 gcc
56
else
67
format=elf64
8+
CC=gcc
79
endif
810

911
objs = \
@@ -16,16 +18,16 @@ runtime.o: $(objs)
1618
ld -r $(objs) -o runtime.o
1719

1820
%.run: %.o runtime.o
19-
arch -x86_64 gcc runtime.o $< -o $@
21+
$(CC) runtime.o $< -o $@
2022

2123
.c.o:
22-
arch -x86_64 gcc -fPIC -c -g -o $@ $<
24+
$(CC) -fPIC -c -g -o $@ $<
2325

2426
.s.o:
2527
nasm -g -f $(format) -o $@ $<
2628

2729
%.s: %.rkt
28-
racket -t compile-file.rkt -m $< > $@
30+
cat $< | racket -t compile-stdin.rkt -m > $@
2931

3032
clean:
3133
rm *.o *.s *.run

langs/abscond/compile-file.rkt

Lines changed: 0 additions & 13 deletions
This file was deleted.

langs/abscond/compile-stdin.rkt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#lang racket
2+
(provide main)
3+
(require "parse.rkt" "compile.rkt" a86/printer)
4+
5+
;; -> Void
6+
;; Compile contents of stdin,
7+
;; emit asm code on stdout
8+
(define (main)
9+
(read-line) ; ignore #lang racket line
10+
(asm-display (compile (parse (read)))))

langs/abscond/interp-file.rkt

Lines changed: 0 additions & 13 deletions
This file was deleted.

langs/abscond/interp-stdin.rkt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#lang racket
2+
(provide main)
3+
(require "parse.rkt" "interp.rkt")
4+
5+
;; -> Void
6+
;; Parse and interpret contents of stdin,
7+
;; print result on stdout
8+
(define (main)
9+
(read-line) ; ignore #lang racket line
10+
(println (interp (parse (read)))))

langs/blackmail/Makefile

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
UNAME := $(shell uname)
2-
.PHONY: test
32

43
ifeq ($(UNAME), Darwin)
54
format=macho64
5+
CC=arch -x86_64 gcc
66
else
77
format=elf64
8+
CC=gcc
89
endif
910

1011
objs = \
@@ -17,19 +18,19 @@ runtime.o: $(objs)
1718
ld -r $(objs) -o runtime.o
1819

1920
%.run: %.o runtime.o
20-
gcc runtime.o $< -o $@
21+
$(CC) runtime.o $< -o $@
2122

2223
.c.o:
23-
gcc -fPIC -c -g -o $@ $<
24+
$(CC) -fPIC -c -g -o $@ $<
2425

2526
.s.o:
2627
nasm -g -f $(format) -o $@ $<
2728

2829
%.s: %.rkt
29-
racket -t compile-file.rkt -m $< > $@
30+
cat $< | racket -t compile-stdin.rkt -m > $@
3031

3132
clean:
3233
rm *.o *.s *.run
3334

34-
test: example.run
35-
@test "$(shell ./example.run)" = "$(shell racket example.rkt)"
35+
%.test: %.run %.rkt
36+
@test "$(shell ./$(<))" = "$(shell racket $(word 2,$^))"

langs/blackmail/compile-file.rkt

Lines changed: 0 additions & 13 deletions
This file was deleted.

langs/blackmail/compile-stdin.rkt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#lang racket
2+
(provide main)
3+
(require "parse.rkt" "compile.rkt" a86/printer)
4+
5+
;; -> Void
6+
;; Compile contents of stdin,
7+
;; emit asm code on stdout
8+
(define (main)
9+
(read-line) ; ignore #lang racket line
10+
(asm-display (compile (parse (read)))))

langs/blackmail/interp-file.rkt

Lines changed: 0 additions & 13 deletions
This file was deleted.

langs/blackmail/interp-stdin.rkt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#lang racket
2+
(provide main)
3+
(require "parse.rkt" "interp.rkt")
4+
5+
;; -> Void
6+
;; Parse and interpret contents of stdin,
7+
;; print result on stdout
8+
(define (main)
9+
(read-line) ; ignore #lang racket line
10+
(println (interp (parse (read)))))

0 commit comments

Comments
 (0)