Commit Graph

238 Commits (1b6570df84c5429113b73e11f3451bdb42d39ee2)
 

Author SHA1 Message Date
Jonathan Arnett 12a4daa54c Label function bodies 2022-01-02 15:25:18 +07:00
Jonathan Arnett 7a8f36bc24 Add gotcha note about function_call node 2022-01-02 14:36:30 +07:00
Jonathan Arnett ce51b9514f Make custom type examples valid gleam 2022-01-02 14:23:39 +07:00
Jonathan Arnett b27cc2673b Document a few gotchas 2022-01-02 13:46:52 +07:00
Jonathan Arnett 4648a013e7 Fix test
I don't really like the format of this error, but I'm not sure how much
I can do about that.
2022-01-02 13:46:52 +07:00
Jonathan Arnett 9f7e80875b Add constant tests for non-decimal integers 2022-01-02 13:30:29 +07:00
Jonathan Arnett 0e2c6951fe "labeled" only has two 'l's and y'all never told me 2022-01-02 03:38:05 +07:00
Jonathan Arnett 35cd8b2dfd A great big update
Highlights:
- Give "_upname" the visible name "type_identifier". Name stolen
shamelessly from tree-sitter-rust.
- Remove "record_name" in favor of "type_identifier".
- Remote "function_name" in favor of "identifier".
- Surface names for several nodes, mostly using "type_identifier".
- Remove "remote_" variants of several nodes. Essentially we needed to
give these nodes "names" anyhow, and having the name encapsulate the
local vs remote information proved wildly efficient.
2022-01-02 03:35:30 +07:00
Jonathan Arnett e5b283e41a Add or re-add encapsulating nodes
In a previous commit, I removed several encapsulating nodes such as
"parameters" or "arguments" where they were not absolutely necessary.
While reviewing tree-sitter-rust, I noticed that they always
incorporated these encapsulating nodes. This likely helps with AST-based
code navigation, and so I introduced or re-introduced them here.
2022-01-02 01:56:30 +07:00
Jonathan Arnett d22ce5f6ae Fix unlabeled constant record argument bug 2022-01-01 20:54:54 +07:00
Jonathan Arnett 0802930958 Better the type annotation format for constants 2022-01-01 20:20:17 +07:00
Jonathan Arnett dbf9063de1 "Finish" parsing
This commit primarily introduces the ability to parse custom types and
type aliases. The tests for these constructs are contained in the
subsequent commit, because they were written against the "cleaned up"
AST.
2022-01-01 19:57:20 +07:00
Jonathan Arnett ad88927358 AST "cleanup"
- Combine "type" and "type_constructor" across the board into
"type". These two had represented the same thing for a while, with the
latter simply being a "generic" type that has parameters, but now the
difference is exactly that; the presence of parameters. Also the name
"type_constructor" was needed for inside custom type definitions.
- Remove the "parameter" field for functions that do not have them.
- Correct mistaken usages of "type" when "type_name" was meant.
- Correct mistaken usages of "type_argument" when "type_parameter" was
meant.
2022-01-01 19:57:20 +07:00
Jonathan Arnett 7c1ce5e840 Finished first pass at function parsing 2021-12-31 03:08:48 +07:00
Jonathan Arnett cc1c8d6956 Add fairly comprehensive `case` tests 2021-12-29 16:13:26 +07:00
Jonathan Arnett 58ae4730ee '_' isn't an integer and octal, hex, and binary values are 2021-12-29 14:57:06 +07:00
Jonathan Arnett 12ab1ee0f9 Added more function tests and improved case AST 2021-12-29 14:20:18 +07:00
Jonathan Arnett 99e0b3b0ae More function work; got some good tests 2021-12-29 02:47:33 +07:00
Jonathan Arnett 2bb02b1278 Started investigation into parsing expressions
Mostly just left comments about how I'll need to revise the Gleam
parser's "expression unit" parsing approach.
2021-12-21 01:00:44 +07:00
Jonathan Arnett bd3a92b58c Pretty good pattern support, I'd say 2021-12-20 00:43:08 +07:00
Jonathan Arnett e691cc44f7 Finally replicate parse_bit_string_segment in tree-sitter
The Gleam parser contains a function called `parse_bit_string_segment`
that contains the logic for how to parse bit_strings for constants,
patterns, and expression units by allowing callers to pass functions to
parse the values and arguments. After much trial-and-error, I managed to
functionally replicate this function within the tree-sitter grammar.
2021-12-19 23:37:07 +07:00
Jonathan Arnett 4f1cee304c WIP: Most of "patterns" 2021-12-19 22:14:44 +07:00
Jonathan Arnett fd348b11c3 Improve generated AST. Fixed a few "empty" bugs. 2021-12-17 02:41:40 +07:00
Jonathan Arnett 71c1660942 Differentiate concrete types from type constructors 2021-12-17 01:53:33 +07:00
Jonathan Arnett 62672649b0 Small formatting change 2021-12-17 01:36:43 +07:00
Jonathan Arnett a77d3f5785 Add support for parsing function declarations 2021-12-14 23:35:37 +07:00
Jonathan Arnett 94861e0161
Apply some formatting changes to README 2021-12-14 11:46:47 +07:00
Jonathan Arnett 83bad86c24 Add support for public external functions and public external types 2021-12-14 01:46:23 +07:00
Jonathan Arnett 068ae5178f Add support for external function statements 2021-12-14 01:35:59 +07:00
Jonathan Arnett eaa2cc2026 Update the TODO and TODONE lists 2021-12-14 00:11:41 +07:00
Jonathan Arnett 2f1624e1dd Add ability to parse external types 2021-12-14 00:00:17 +07:00
Jonathan Arnett 3cb2569f12 OK, I swear I actually finished constants this time 2021-12-13 23:40:39 +07:00
Jonathan Arnett 25c5af2aa7 Better constant type parsing, still not my favorite
Types for constants are more restricted than types for other parts of
the language. The way that the Gleam parser handles this is by having
the `parse_type` function pass along a `for_const` boolean, which is
used to limit valid subnodes. I tried replicating this functionality in
tree-sitter by creating a `parse_type($, for_const)` function, and
calling that instead of `$.type`. tree-sitter did not like this, saying
that the call stack became too deep.

Thus, I arrived at my current solution, which is simply to have
largely duplicate type rules for constants vs not-constants.

Another possible approach would be to _generate_ the type rules via a
`gen_types($, for_const)` function, which could be embedded into the
rules list like so:

```
/* Special constant types */
...gen_types($, true),

// other stuff

/* Types */
...types($, false),
```

I may try that later.
2021-12-13 17:18:55 +07:00
Jonathan Arnett 6f67643edf
Update README with notes about constants 2021-12-13 11:16:11 +07:00
Jonathan Arnett 8aecfc0617 Rudimentary constant support 2021-12-13 01:24:34 +07:00
Jonathan Arnett f2e9085848 Update targets tests 2021-12-13 01:07:55 +07:00
Jonathan Arnett eeca1c2730 Add convenient "generate" script 2021-12-12 19:14:02 +07:00
Jonathan Arnett 7a820c581f Initial commit 2021-12-12 04:53:43 +07:00