Commit Graph

7 Commits (master)

Author SHA1 Message Date
James T. Martin 86fea958f4
(Algebraic language) Fibonacci sequence works. 2023-07-28 20:03:10 -07:00
James T. Martin 3fe367675a
Removed radix#int syntax, added keywords to lexer. 2022-09-10 14:58:22 -07:00
James T. Martin 4c4ebeecfc
Fixed bug: use references to mutate the stack instead of values. 2022-09-10 09:07:38 -07:00
James T. Martin 9b41081c71
Indentation-sensitive syntax! 2022-09-08 16:02:30 -07:00
James T. Martin bce39fdc22
Greatly simplify lexer thanks to new knowledge of lookahead.
Now I know that the parser is LL(1) and the lexer also only
needs one-character lookahead, which allows me to dramatically
simplify the interface for IO input, and improve the interface
to the lexer. Even if I did want unbounded peek, I'd want
the interface to be `peek(off)`, not that awful buffer.

I intend to use the new lexer interface to make the parser
states more stateful, and potentially read multiple tokens
in a row. Then, states would only be needed for recursive
structures, without the awkward intermediate states like
ST_LABEL which exists only to let me burn a token.

I also removed the nonsense related to base 64 parsing,
because it was unclear how to handle it, and the advantages
of having it weren't clear. I kept up to base 36, but honestly
I might want to consider getting rid of everything but decimal,
hex, and binary anyway. I'm not sure if I'd want to keep using
the current syntax for the radix either.
2022-09-07 23:02:15 -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 162683d63e
Hacked together a god-awful hand-written lexer. 2022-09-07 11:07:05 -07:00