1
0

More polite code

This commit is contained in:
Jon Michael Aanes 2024-09-24 22:59:14 +02:00
parent 70d2c9f12c
commit 9c737e0be1
Signed by: Jmaa
SSH Key Fingerprint: SHA256:Ab0GfHGCblESJx7JRE4fj4bFy/KRpeLhi41y4pF3sNA
3 changed files with 19 additions and 19 deletions

0
README.md Executable file → Normal file
View File

28
example.scm Executable file → Normal file
View File

@ -371,7 +371,7 @@
(eqv-test "eqv? inter-types"
'(
(#f 2 a)
(#f 4 "Derp")
(#f 4 "Test")
(#f () (a b))
(#f 9 ())
))
@ -627,7 +627,7 @@
(result (cadar rules))
(bindings (find-variable-bindings literals var-name (caar rules)))
)
(begin (display "Derp: ")
(begin (display "Test ")
(display bindings)
(newline)
@ -694,16 +694,16 @@
( #t . ,(bool 1))
))
(define-syntax derp
(define-syntax fun_macro
(syntax-rules (two)
((derp) 1)
((derp two) (+ (derp) (derp)))
((fun_macro) 1)
((fun_macro two) (+ (derp) (derp)))
))
(test "Defining weird macroes using syntax-rules."
`(
( 1 . ,(derp))
( 2 . ,(derp two))
( 1 . ,(fun_macro))
( 2 . ,(fun_macro two))
))
(define-syntax +1
@ -717,18 +717,18 @@
( 0 . ,(+1 -1))
))
(define-syntax derp
(define-syntax fun_macro
(syntax-rules ()
((derp a) a)
((derp a b ...) (+ a (derp b ...)))
((fun_macro a) a)
((fun_macro a b ...) (+ a (derp b ...)))
))
(test "Defining list using syntax-rules."
`(
( 1 . ,(derp 1))
( 6 . ,(derp 6))
( 9 . ,(derp 4 5))
( 3 . ,(derp 1 1 1))
( 1 . ,(fun_macro 1))
( 6 . ,(fun_macro 6))
( 9 . ,(fun_macro 4 5))
( 3 . ,(fun_macro 1 1 1))
))
(exit)

10
tigerscheme.tig Executable file → Normal file
View File

@ -633,7 +633,7 @@ let /* Booleans */
else if is_char(",", index)
then "unquote"
else ( parse_error("Internal error: Unknown quick modifier")
; "SOMETHING FUCKED UP")
; "PARSING_ERROR")
var datum := ( index := index + 1
; if modifier = "unquote-splicing"
then index := index + 1
@ -2035,17 +2035,17 @@ let /* Booleans */
, ast)
; TRIGGERED_EXIT := true
; nil )
else let var derp: scheme_value := nil
else let var stack_top: scheme_value := nil
in vm_run(macro_tape, fun.val_i, stack, fun.val_car, "", env_global)
; /* TODO: Assert that there is something on the stack */
derp := stack_pop(stack)
stack_top := stack_pop(stack)
; if DEBUG_PRINT_MACRO
then ( print("Macro \"")
; print(ast.val_car.val_s )
; print("\" expanded to: ")
; print(value_to_string(derp))
; print(value_to_string(stack_top))
; print("\n") )
; compile_rec(derp, can_tail_call, type_any)
; compile_rec(stack_top, can_tail_call, type_any)
end
end