Minor cleanup.
Remove the pass0//2 DCG rule and unfold it in compile_program//2 rule. Move init//0 to be with the rest of the state DCG code.
This commit is contained in:
parent
fe795704a6
commit
4e70fdd67b
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
|
||||
Copyright © 2018 Simon Forman
|
||||
Copyright © 2018-2019 Simon Forman
|
||||
|
||||
This file is part of Thun
|
||||
|
||||
|
|
@ -43,12 +43,6 @@ write_binary('joy_asm.bin', Binary).
|
|||
% phrase(linker(IR), ASM),
|
||||
% write_canonical(ASM).
|
||||
|
||||
pass0(Code, Program) --> init, ⦾(Code, Program).
|
||||
|
||||
init, [Context] -->
|
||||
{empty_assoc(C), empty_assoc(Dictionary),
|
||||
put_assoc(dictionary, C, Dictionary, Context)}.
|
||||
|
||||
⦾([], []) --> [].
|
||||
|
||||
⦾([Body, ≡(NameAtom)|Terms], [defi(Name, B, Prev, I, SP, TOS)|Ts]) -->
|
||||
|
|
@ -142,6 +136,10 @@ init, [Context] -->
|
|||
⦾(ナ, low_half(TEMP0, TOS)) --> get(temp0, TEMP0), get(tos, TOS).
|
||||
⦾(ヶ, low_half(TOS, SP)) --> get(sp, SP), get(tos, TOS).
|
||||
|
||||
init, [Context] -->
|
||||
{empty_assoc(C), empty_assoc(Dictionary),
|
||||
put_assoc(dictionary, C, Dictionary, Context)}.
|
||||
|
||||
get(Key, Value) --> state(Context), {get_assoc(Key, Context, Value)}.
|
||||
set(Key, Value) --> state(ContextIn, ContextOut),
|
||||
{put_assoc(Key, ContextIn, Value, ContextOut)}.
|
||||
|
|
@ -284,7 +282,7 @@ high_half_word(I, HighHalf) :- HighHalf is I >> 16 /\ 0xFFFF.
|
|||
low_half_word( I, LowHalf) :- LowHalf is I /\ 0xFFFF.
|
||||
|
||||
compile_program(Program, Binary) :-
|
||||
phrase(pass0(Program, IR), [], _),
|
||||
phrase((init, ⦾(Program, IR)), [], _),
|
||||
phrase(⟐(IR), ASM),
|
||||
phrase(linker(ASM), EnumeratedASM),
|
||||
phrase(asm(EnumeratedASM), Binary).
|
||||
|
|
|
|||
Loading…
Reference in New Issue