Commit Graph

8 Commits (894c10903c45331370e3d0d004cb9c4957bad12f)

Author SHA1 Message Date
James T. Martin 894c10903c
Old, incomplete, broken stuff from a month ago. 2022-11-30 13:04:03 -08:00
James T. Martin 68ce32a6df
Slightly unfuck codegen for relative jumps and blocks.
Still pretty horribly broken. I was generating dispacements
backwards, failing to emit stuff like the beginning of
loops, the logic for `if` jumps was backwards, etc.
I was also completely forgetting to increment file_here
for appends. I don't remember what all I did; check the diff.
2022-10-19 12:21:46 -07:00
James T. Martin 1383484e06
No assertions fail during codegen (lang.c) for test file.
The generated executable is still incorrect
for reasons which I have not yet investigated,
but this is still a step forward.
2022-10-17 11:45:38 -07:00
James T. Martin fcd61f6c5f
Wrote IR gen!! (Literally untested, though.)
Next stages are to wire it into the parser so I can test it,
to implement operator precedence so exprs actually exist,
and then implement operators and builtins until I can
start writing basic programs.
2022-09-08 21:07:40 -07:00
James T. Martin d7c0eef7ae
Implemented parser! Recognition only, no output.
Also no top-level declarations or operator precedence.

The syntax is LL(1). LL syntax seems necessary because
our codegen requires emitting certain code (e.g. entering control)
prior to any codegen inside that context, whereas something like
LR would presumably parse the inner expression before recognizing
the control structure. There may be some way to work around this;
I don't know, I'm not a parsing expert.

Certain parts of the syntax are wonky, e.g. juxtaposition as
function application means a missing semicolon can give confusing
results. I suspect indentation-sensitive syntax would work
more nicely, and intend to implement it some time in the future.
2022-09-07 20:42:37 -07:00
James T. Martin 57aa667000
Completely rewrite stack management.
Now we always use the stack instead of keeping a TOS register.
This is very inefficient, but I'll worry about register
allocation later.

The new block model is inspired by x86's `enter` and `leave`
instructions. I intend to support nested procedures at some point
in the future.
2022-09-06 19:47:46 -07:00
James T. Martin 4e06f8d00f
Separate instruction encoding into a separate file.
I describe the intended file structure in comments
at the top of each file.
2022-09-06 02:20:10 -07:00
James T. Martin b5667c61ec
Initial commit. 2022-09-05 23:48:56 -07:00