Commit graph

160 commits

Author SHA1 Message Date
46770419e6 Dumb harness for working with wrapping
It's pretty manual but I want to see how bad it is.
2024-09-13 15:29:18 -07:00
8845bcfdab Fix accidental group duplication
Leading to unnecessary ambiguities
2024-09-13 15:28:50 -07:00
ca240906c9 Remove the text follow stuff
I think we have a good solution to the problem.
2024-09-13 12:02:44 -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
443bf8bd33 Move formatting meta around, actually mark stuff up 2024-09-10 11:47:22 -07:00
7edf5e06bf Rebuild the matcher on grammars
Well that wasn't so bad now was it? Eh? Nice to have a parser
generator lying around. Let's keep working to see if I can actually
finish it.
2024-09-09 11:40:14 -07:00
1d28c82007 Saving this for posterity, but it is doomed
Remember that tree levels are generated by context free languages, not
regular languages, and so they can only be recognized by push-down
automatons, not finite state machines.

What happened was that I failed to account for transparent rules.
Without transparent rules the children of a tree node do not have any
recursion in them (by definition!) and so therefore *are* a regular
language. But transparent rules change that: there *can be* recursion
hidden on the same tree level, and it should have been clear from a
moment's reflection that the recursion there meant that tree levels
were once again a context free language.

Fortunately we have a recognizer for context free languages lying
around, so we can just use that I guess.
2024-09-09 06:23:25 -07:00
0cbf696303 The start rule cannot be transparent 2024-09-09 06:23:11 -07:00
49b76b9bcc Teach trees to format themselves. 2024-09-09 06:22:56 -07:00
a2c6390c23 Start to work on a prettier system.
Still very garbage but I think the "hard" part of building a Wadler
document from a parse tree might be there. It's a backtracking matcher
which might turn out to be too slow for alternatives but maybe will be
fine?

Still needs lots of tests.
2024-09-07 13:02:09 -07:00
677e60bd27 Dumb tweaks 2024-09-07 07:39:13 -07:00
00b4cd4702 Starting to look at pretty-printing with the idea of auto-indentation
I wonder if it will work?
2024-09-06 16:23:14 -07:00
d7dfd556ec Emit an emacs major mode
With coloring! Next up: formatting but that might be hard.
2024-09-06 11:51:09 -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
0243b0bf77 Refactor grammar to make "nicer" trees (I guess) 2024-09-06 10:21:00 -07:00
23981f82ce Start working on emacs mode generation 2024-09-06 10:20:34 -07:00
501c2e3fbe Teach the highlight meta about emacs face names 2024-09-06 10:20:17 -07:00
676ddedbaf Add the language name to the end of generated scopes 2024-09-05 15:12:55 -07:00
dbf893e48b Generate queries a little better 2024-09-05 15:03:44 -07:00
51c4f14c26 Emit highlight queries for tree-sitter
Now we're starting to get somewhere!
2024-09-05 14:52:35 -07:00
d466f5d173 Ignore the tree-sitter directory for tests 2024-09-05 14:52:10 -07:00
ea5fab4e4e Tree-sitter regexps are structured
Instead of trying to build a regular expression string, just build a
structured thing with seq() and choice() and whatnot. This is
technically uglier but fixes a problem I found with comment regular
expressions so you know, it works, which is better than not working.

Also now tokens get named and maybe that's good? It's so hard to say.
2024-09-05 11:51:29 -07:00
5e12af9f31 Extra marks, fields, whatnot 2024-09-05 06:32:28 -07:00
be8e017fd9 Fix regex generation, extras 2024-09-05 06:32:28 -07:00
94f5958087 Field propagation 2024-09-05 06:30:55 -07:00
591da0c971 Rework highlighting metadata GOD 2024-09-02 08:50:36 -07:00
e4a8ad7b76 Trailing thing 2024-09-01 11:30:59 -07:00
a99b3ecb70 Interpret precedence the way tree-sitter does, kinda
This allows most of our precedence to be re-used. There are some cases
still where tree-sitter gets confused (and we don't), see the
corresponding change to grammar.py. I wish I knew how to fix this but
I don't. :(
2024-09-01 07:38:46 -07:00
0354fbf4a4 More ways of writing
Sometimes prettier
2024-09-01 06:52:13 -07:00
3012df4ac6 Precedence but it doesn't work
Tree sitter doesn't let me do token-based precedence? I don't like
tree-sitter's "make it inline but give it a number" system- seems like
a bug farm to me.
2024-08-31 07:22:49 -07:00
98c4bb950f Fix bugs but still doesn't work for Fine 2024-08-30 09:14:01 -07:00
066d2d8439 A converter from grammars to tree-sitter grammars
Hmm, isn't this fine!
2024-08-30 09:04:32 -07:00
2d87207b54 Some small tweaks 2024-08-30 09:04:18 -07:00
80d932b36a Refactor to use non_terminals() 2024-08-29 08:23:55 -07:00
f8b62bf4a4 Terminal 'value' is 'name', compile_lexer is method 2024-08-29 08:22:23 -07:00
344dde51be Grammar start symbol is public 2024-08-29 08:12:08 -07:00
dc03bf7373 Grammars can be named 2024-08-29 08:00:40 -07:00
abcb0e516a OptionalRule is not required but MetatdataRule is 2024-08-28 08:33:32 -07:00
e07f2be3fa Something wrong with this, need to understand more 2024-08-28 08:29:09 -07:00
02c1aa507e Muck around with usability 2024-08-28 08:27:46 -07:00
cd62b65789 Remove the old hand-lexer
The machine lexer is working now
2024-08-27 16:49:03 -07:00
d62076f3c4 Fix a bug in terminal declaration
whoops. now it parses correctly
2024-08-27 16:47:58 -07:00
d03dc6e3d9 Harness uses grammar-generated token stream 2024-08-27 16:47:42 -07:00