Commit Graph
20 Commits
Author SHA1 Message Date
Jon Ross-Perkins 733965704a Start building some checking of diagnostic use. (#2487)
In theory we're doing a central registry so that we can ensure there's at least one test for each. This isn't doing that, but I'm trying to validate that the central registry isn't leading to duplicates or abandoned checks (and catching a couple of each).
2022-12-27 08:43:58 -08:00
Jon Ross-Perkins 5d123189c3 Small cleanups in toolchain code (#2474)
Doing some sorting of functions / enums (generally speaking, I've been trying to keep these loosely lexically sorted for lack of a better ordering).

Also removes some code that seems to be dead, and a minor TODO comment fix.
2022-12-16 15:46:53 -08:00
Kareem Ergawy c74e39dbb3 [parser] More support for interfaces: methods and self deduced param. (#2427)
Summary:

Extends the current support for parsing `interface`s. In particular, adds support for parsing functions and `me` params.
2022-12-16 11:23:02 -08:00
Jon Ross-Perkins d42d864e82 Make TokenKind's API closer to toolchain's typical API setup. (#2456)
This is somewhat based on the name vs Name difference, but I figured I'd split it out and just sweep up the API on the whole while looking at a different approach to #2453
2022-12-08 15:31:04 -08:00
Jon Ross-Perkins 60eb06ce94 Move trace banners to driver and trace intermediate state. (#2443)
Printing intermediate state should be helpful to be able to examine the input when debugging later steps.

Intermediate state is hard to trace from the individual libraries since they don't know whether `dump` is going to print the state, so this moves some trace logic into the driver which is better equipped to make the decision.
2022-12-07 09:17:54 -08:00
Chandler CarruthandJon Ross-Perkins 94cf343b05 Update LLVM and switch to std::optional. (#2424)
LLVM's bazel build has changed a bit, so this updates the tree for that.

LLVM is also moving `llvm::Optional` to match the standard API, but it seemed simpler to just switch to `std::optional`.

Co-authored-by: Jon Ross-Perkins <jperkins@google.com>
2022-12-01 09:22:43 -08:00
Jon Ross-Perkins 16bbdbbdb8 Add vlog output to the parser. (#2435)
Might eventually want to change this further, but I'm just adding the quick framework for it.
2022-11-30 17:28:49 -08:00
Jon Ross-Perkins 6bfd202f4e Finish bracketing of parse nodes. (#2430)
- Finishes remaining "todo" parse nodes.
- Improving error recovery for invalid designators and structs, so that the parse tree still looks similar to a valid parse tree.
- Call expressions now have the thing being called as a child (of the start) instead of a sibling.
- Use of Start is replacing use of End in several parse nodes, like structs and call expressions.
- Adjusting documentation of parse node structures in an attempt to make it more consistent and understandable.
- The current state for interfaces and if/else is mostly being documented, not altered.
2022-11-30 09:14:07 -08:00
Jon Ross-PerkinsandChandler Carruth 84deb62aef Work on ParseTree structure to use more bracketed structures. (#2416)
This works on multiple statements to make them better for the bracketing model. Stub nodes are added in more cases of invalid syntax, simply so that the semantics has reliably structured input. Comments in parse_node_kind.def now try to show the expected parse tree structure in postorder form.

This labels If, While, and For a little differently in parse nodes so that at the start of the postorder traversal, it'll already be available to semantics which structure is being processed. I need to do a little more with If in particular, but this felt like a reasonable stopping point.

While this makes significant parser changes, the changes to parser_state.def are minimal, mostly naming-related. The actual flow isn't substantively changed, just a couple minor names and the new As(If|While) state which allows distinguishing IfCondition and WhileCondition.

Co-authored-by: Chandler Carruth <chandlerc@gmail.com>
2022-11-28 15:02:59 -08:00
Kareem Ergawyandergawy a508390423 [parser] Start re-implementing interfaces using the stack parser. (#2412)
First change towards re-implementing interfaces using the new parser. I kept it small to make sure we are on the same page regarding stack states and how the parse tree should look like.

Co-authored-by: ergawy <kareem.ergawy@guardsquare.com>
2022-11-28 12:58:41 -08:00
Jon Ross-Perkins d9ce1827c8 Adjust how invalid declarations pass errors. (#2413)
When there's no semicolon for an invalid EmptyDeclaration, rather than producing nothing, produce an EmptyDeclaration with the original location that led to the error.

Note this removes a direct edit (the only one) of the parse tree's error state. Elsewhere it's an indirection from adding an error node.
2022-11-18 08:02:07 -08:00
Jon Ross-Perkins adac572430 Replace some reference members with pointer members. (#2408)
I'd noted this while rewriting the parser and, while I kept it there during conversion, I think switching is consistent with the higher-level desire and the use of references therein was just an oversight.

Discussed at:
https://discord.com/channels/655572317891461132/655578254970716160/1042551242813083840
2022-11-17 08:58:43 -08:00
Jon Ross-Perkins fbed1398fe Change ParameterList to use a Start that brackets params (#2403)
The code change is small here. I'm breaking this out because it has a lot of test churn, and semantics doesn't have significant logic around it yet.
2022-11-17 08:57:22 -08:00
Jon Ross-Perkins 5da32bd560 Rename to StructLiteralOrStructTypeLiteralStart (#2404)
As requested
2022-11-17 08:56:48 -08:00
Jon Ross-Perkins dc23f6305d Use Consume() more where possible. (#2397)
Just trying to standardize the use in a few spots; no behavioral change.
2022-11-15 22:45:47 -08:00
Jon Ross-Perkins c165ab6c2b Change StructLiteral and StructTypeLiteral parsing to use an ambiguous start. (#2396)
This is necessary in order to use a bracketing approach; parsing doesn't know the contained format until it parses the first element, which we don't want to do look-ahead for. I think the bracketing is higher value than knowing the format before adding the node.
2022-11-15 22:44:57 -08:00
Jon Ross-Perkins b914f46ec5 Change keyword statements to bracket arguments. (#2394)
This changes `return`, `break`, and `continue` to treat the keyword as the "start" and semicolon as the "parent", essentially bracketing the keyword.

Pragmatically this is focusing on making `return` work with only one ParseNodeKind: because `return` and `;` now bracket the expression, we can tightly determine whether the `return` has arguments without looking at subtree size. However, it's possible that `break` and `continue` may in the future take some kind of label as an argument, so the consistency seems beneficial there too.

Note this eliminates the StatementEnd ParseNodeKind, as it's obsolete with this change.
2022-11-15 22:42:54 -08:00
Jon Ross-Perkins 310cf0d2f9 Refactor Pattern and FunctionParameter handling for Parser consistency (#2385)
While the Parser has similar divergent states, lists of Expressions tend to be handled more like this. I'm keeping the divergent start state in order to continue support of a distinct error, but I think this organization of FunctionParameter/FunctionParameterFinish will be less surprising.
2022-11-15 22:36:52 -08:00
Jon Ross-Perkins b163aaaf74 Add a ForIn node for a , move the error (#2387)
This is to keep the tree consistent with the error-free state. It also more precisely locates the error.
2022-11-14 13:17:58 -08:00
Jon Ross-Perkins 6433a1bab6 Rename Parser2 to Parser, and delete the original (#2383) 2022-11-11 13:35:45 -08:00