Commit graph

118 commits

Author SHA1 Message Date
e3fa3500d4 Switch TableLit and Program to BoundedSeparated 2022-11-21 23:54:30 +01:00
a1867fdc4e Add BoundedSeparated with parser and printer
This type should be able to replace Separated (with a bit of effort).

The hope is that this type is a better representation for table-like
syntax with optional trailing delimiter that will let me remove_map
elements without too much difficulty. This is necessary for desugaring
table constructors.
2022-11-21 22:56:50 +01:00
9591b23082 Fix span of field ident string expression 2022-11-21 15:14:28 +01:00
ca979edd7c Desugar variable access and assignment 2022-11-21 15:14:18 +01:00
27ba13e8a2 Desugar field assignment via ident 2022-11-21 14:44:15 +01:00
621ea8f1d4 Desugar field access via ident 2022-11-21 14:38:45 +01:00
290cef06cb Desugar from the outside in 2022-11-21 14:35:10 +01:00
ebc48fff5a Desugar field assignment 2022-11-21 14:05:07 +01:00
3f8320941a Desugar field access 2022-11-21 13:49:37 +01:00
b84d5ae0c8 Create new objects with existing span
I've decided that attempting to create smaller spans is more difficult
and will also lead to worse error messages later on. It makes more sense
to just tag every newly created syntax tree element with the span of the
element it comes from.
2022-11-21 13:36:21 +01:00
5c8dd1969f Desugar function calls with argument 2022-11-21 13:35:36 +01:00
7bfaebc05f Desugar function calls with table constructor 2022-11-21 13:07:10 +01:00
29aa474b6a Use diff tool to visualize desugaring changes 2022-11-21 13:01:15 +01:00
a3d6efcaec Desugar function calls without args 2022-11-21 12:35:53 +01:00
52c1aeba35 Desugar literals 2022-11-21 12:05:24 +01:00
8278442d3f Expand expression desugaring 2022-11-21 11:43:31 +01:00
13b7db79b0 Desugar separated elements 2022-11-21 11:35:58 +01:00
8b21acac9e Add desugar command and desugar programs 2022-11-21 09:33:34 +01:00
6eee1ba930 Simplify pretty printing separated elements 2022-11-21 00:49:04 +01:00
9d6cd580d4 Pretty print module elems 2022-11-21 00:17:51 +01:00
b3eaa40902 Pretty print function definitions 2022-11-21 00:16:15 +01:00
c45a45f0b6 Rename parser::func_defs to parser::func_def 2022-11-21 00:08:59 +01:00
e7416fbc1e Pretty print table destructors 2022-11-21 00:07:57 +01:00
c7fc8584ff Pretty print variable accesses and assignments 2022-11-21 00:02:12 +01:00
5bd43ee37a Pretty print field accesses and assignments 2022-11-20 23:50:53 +01:00
81e2a28b06 Pretty print function calls 2022-11-20 23:45:28 +01:00
fc139c31f4 Pretty print table constructors 2022-11-20 23:41:39 +01:00
412eaffc07 Pretty print table literals 2022-11-20 23:33:39 +01:00
f91e8ac9a2 Pretty print string literals 2022-11-20 23:06:04 +01:00
e6bbb37323 Pretty print numeric literals 2022-11-20 22:59:20 +01:00
7833ef533d Place parentheses in expressions when necessary 2022-11-20 22:53:19 +01:00
4156006ada Pretty print literals partially 2022-11-20 22:22:36 +01:00
03e7f10739 Satisfy warnings 2022-11-20 22:16:10 +01:00
3ed3c4e8f8 Add warnings from cove 2022-11-20 22:16:10 +01:00
2ba56f0c92 Make code generic over allocator
This way, I can use the same code with any allocator I want. More
importantly, I can also use the nice DocBuilder-exclusive helper
functions!
2022-11-20 21:41:57 +01:00
1a3772e6f7 Pretty print expressions partially 2022-11-20 21:19:54 +01:00
23796e53a9 Pretty print program elements 2022-11-20 21:11:38 +01:00
200b653e61 Pretty print programs partially 2022-11-20 21:09:59 +01:00
1b364061e4 Make rule about consuming surrounding whitespace 2022-11-20 21:09:59 +01:00
6533c9dcf7 Handle things separated by things differently
I noticed that programs like '{} would parse correctly while '{ } would
expect an inner element. This was because the leading space was actually
part of the element parser, which is a violation of the (as of yet
unspoken) rule that parsers should not parse surrounding whitespace.

Because whitespace whas treated differently from everywhere else and
because this implementation was wrong, I decided to reimplement it,
abstracting the concept of things separated by other things with
optional trailing things. I did this in such a way that surrounding
whitespace is not touched.
2022-11-20 21:09:59 +01:00
407786b98c Add "pretty" subcommand 2022-11-20 18:27:25 +01:00
43d5b6d5ae Forbid underscores in unicode escapes 2022-11-20 18:17:19 +01:00
dfaa878820 Forbid escapable characters in string literals 2022-11-20 18:10:15 +01:00
3130736057 Parse program 2022-11-20 18:10:15 +01:00
2be47871da Add "module" program variant 2022-11-20 18:10:15 +01:00
9658907d76 Make string literal Debug more compact 2022-11-20 17:36:28 +01:00
82e5b589e1 Parse string literals 2022-11-20 17:36:16 +01:00
867595b5b9 Remove multiline string literals from ast 2022-11-20 17:14:43 +01:00
ea7518b183 Create each main parser only once 2022-11-19 20:56:10 +01:00
b291619d10 Remove unnecessary Clone bounds 2022-11-19 19:36:10 +01:00