Commit graph

37 commits

Author SHA1 Message Date
3bffe98df0 [parser] one_or_more
Finally making lists easier
2024-11-10 18:47:24 -08:00
5064a768e7 [all] A whole new style for grammars
Say good by to the sea of `self.`!
2024-11-09 11:21:30 -08:00
063584fb7e [runtime] Better error messages?
(Sometimes.)
2024-10-27 09:10:31 -07:00
27e6bb413c [parser] Remove Canonical LR1 generator
This is fine probably.
2024-10-26 07:25:37 -07:00
2d5c73f0b0 [parser] Remove LR0 and SLR1
Sorry, when this was educational it was nice to have the other
generators but as part of cleaning I'm just getting rid of them.
2024-10-15 07:43:52 -07:00
2656a1d328 [parser] Remove bad LALR implementation, start cleanup 2024-10-10 07:58:16 -07:00
474bbf6964 [test] Correct doc comment 2024-10-05 16:02:39 -07:00
eef1db72da [parser] Pager's algorithm. Faster.
As good as LALR but the implementation isn't embarassing. (Still
pretty bad though.)

Honestly the next thing to do is to delete LALR and just use Pager's
and also rebuild ConfigSet et al to be ItemSet so that Pager's alg
can go even faster. I think I want to keep LR1 just for completeness
so I might as well not delete SLR and LR0, although I *could* I
suppose.
2024-10-05 16:00:41 -07:00
ccdda886ff [parser] Actually add the new tests
Whoops, missed a file.
2024-09-22 08:49:33 -07:00
071cd29d8f [readme] Rewrite the readme and add a helper
The helper is nice actually.
2024-09-21 08:45:49 -07:00
1a3ce02d48 [wadler] Re-factor into multiple modules
Hard split between builder and runtime, as is proper.
2024-09-21 07:42:52 -07:00
1f84752538 [wadler] Refactor: data and runtime split
Now we convert the grammar into data for a pretty-printer, so in
theoryw e could write the pretty-printer in a different language.
2024-09-21 06:44:53 -07:00
e4585170d8 [wadler] Fixup EOF trivia
Trivia handling feels pretty good now actually.
2024-09-19 20:23:02 -07:00
8a17cfd586 [wadler] Prettier handling of trivia
Split the rules for pre- and post- trivia, understand when we want to
do either, handle multi-line-break (in an unsatisfying way, I guess)
but otherwise lay the groundwork for thinking about it better.

Also now we don't generate lazy "Text" nodes because I thought I might
want to actually look at the newlines in the source but I don't yet.
I *can* now, though. (I can also detect EOF so there's that.)
2024-09-19 16:39:32 -07:00
c31d527077 [wadler] Trivia escapes groups
This means that forced breaks from comments don't screw up the
following single-line things. But this still isn't right; we need to
fine tune how we represent trivia.
2024-09-15 08:51:18 -07:00
9d55588a35 [wadler] Cons has a list of documents in it
I think I want to start thinking about "leftmost" and "rightmost" and
it's just easier and faster if cons has an actual list in it instead
of dotted pairs.
2024-09-15 08:12:30 -07:00
d7a6891519 Finish annotating test grammar, forced breaks, fixes
Forced breaks force a newline in a spot, which is sometimes what we
want. (Like, this syntax should *never* be on a single line.)
2024-09-13 11:57:16 -07:00
938f0e5c69 Support newline replacements
This allows us to do maybe more complicated spacing.

Still unclear about identifier/punctuation spacing.
2024-09-12 11:09:14 -07:00
b3b2102864 Record trivia in tokens
This will make our formatting better I think.
2024-09-12 06:22:49 -07:00
8a80bcad64 Fix broken test
(Update snapshot to be correct.)
2024-09-11 11:28:53 -07:00
276449287d Allow for text to follow tokens in pretty-printing
It's weird that it counts against the line length though, like if you
were going to break you could ignore it right? At least, for the
grammar I'm working here....
2024-09-11 11:22:41 -07:00
d6dd54f4df Actual pretty-printing!
Now we're cooking with gas ALTHOUGH now we have to deal with the fact
that we're gluing everything together where there *should* be spaces.

Many more improvements to come.
2024-09-11 11:08:02 -07:00
5d88b459b9 Spiffy up the json parser with pretty-printing marks 2024-09-10 12:06:29 -07:00
667273369e A test for the printer, to get started 2024-09-10 11:57:10 -07:00
4941cd049c Helper routines for generating source code
This includes "signing" source to detect modifications, and
maintaining user-modified sections. Hooray!
2024-09-06 11:50:17 -07:00
f8b62bf4a4 Terminal 'value' is 'name', compile_lexer is method 2024-08-29 08:22:23 -07:00
dc03bf7373 Grammars can be named 2024-08-29 08:00:40 -07:00
2473ae713d Trivia tests 2024-08-24 15:09:08 -07:00
f29ec5072f Augment number pattern, tests
More robust testing. Error messages would be nice but.
2024-08-24 09:38:21 -07:00
0c952e4905 Correct NFA construction
There was a bug in the way that I was converting regular expressions
to NFAs. I'm still not entirely sure what was going on, but I
re-visited the construction and made it follow the literature more
closely and it fixed the problem.
2024-08-24 09:24:29 -07:00
c0b623bd6d Remove unused imports 2024-08-24 08:36:20 -07:00
72052645d6 Generated lexers actually kinda work
But regular expressions are underpowered and verbose
2024-08-23 15:32:35 -07:00
58c3004702 Move terminals into grammar definition
Starting to work on machine-generated lexers too
2024-08-23 07:24:30 -07:00
f6bc2ccea8 Move the examples into tests 2024-06-15 12:23:36 -07:00
e04aa1966e Start moving the examples into tests 2024-06-15 07:52:16 -07:00
c82f53c346 Document the decision 2024-06-15 06:18:04 -07:00
fb2dff51df Tests. Well, test. 2024-06-15 06:14:37 -07:00