Commit Graph
496 Commits
Author SHA1 Message Date
66e5083b4b Add C++-like for loops (#353)
Add C++-like `for` loops

-  Omits `for (;;)` syntax for now.

Co-authored-by: Dmitri Gribenko <gribozavr@gmail.com>
Co-authored-by: Richard Smith <richard@metafoo.co.uk>
Co-authored-by: austern <austern@google.com>
2021-05-14 15:38:45 -07:00
Jon Meow 82f5c4224b Small fixes from #530 (#537) 2021-05-14 13:23:10 -07:00
Jon MeowandChandler Carruth c72c201133 Copy roadmap from proposal #253 (#533)
Co-authored-by: Chandler Carruth <chandlerc@gmail.com>
2021-05-14 09:52:16 -07:00
Jon Meow 6f544494b3 Use AST to start inserting fn (#530) 2021-05-13 14:58:32 -07:00
Jon Meow 2942c97424 Exclude migrate_cpp from GH testing action due to build overhead (#532) 2021-05-13 14:36:56 -07:00
Jon MeowandMatthew Riley 88a9d244b7 Initial migration framework (#525)
What this does:

- Sets up a `migrate_cpp` tool which currently only runs `clang-tidy`.
  - This is intended to have more transformations in the future.
- Sets up a `migrate_cpp.sh` script.
  - This copies the original woff2 code into a `carbon` directory and runs the `migrate_cpp` tool on it there.
- Adds the initial `carbon` directory of woff2
  - To be clear, this is currently only updated via `clang-tidy`.
  - More transformations should be expected in the future.
- Minor related edits. For example:
  - Adjust pre-commit to skip the `carbon` directory, because it's third-party code and shouldn't be edited in the same way.
  - Adds `@brotli_carbon` as a local repository so that we can "build" outputs.
  - Makes clang-tidy from the bootstrap toolchain accessible for BUILD dependencies, as it's then used for `migrate_cpp`.

What this does not do:

- Any actual transformation of C++ code to Carbon

Co-authored-by: Matthew Riley <mdriley@gmail.com>
2021-05-11 10:13:47 -07:00
Jon Meow e6d5efe7d9 Copy woff2 code for migration (#527) 2021-05-11 08:35:14 -07:00
josh11bandRichard Smith fdb1893544 Generics terminology (#447)
To talk about generics as a programming language feature, you need a lot of
specialized terminology. We need to agree on the words we are using and their
meaning before we can meaningfully talk about the design of the feature itself.

There a number of problems a glossary solves:

Not everyone knows every term, so having a single place to look them up will
improve the ease of understanding, ease of contributing, and accessibility
of the project.
There may not be widespread agreement on the meaning of some terms. In
particular, individual programming languages tend to assign very specific
meanings to terms used within their ecosystem.
Some terms may be used in multiple ways, but we only use the term with one
specific meaning.
Some terms are our invention and we need to introduce them.


Co-authored-by: Richard Smith <richard@metafoo.co.uk>
2021-05-10 16:42:01 -07:00
Matthew Riley cd8cc97185 return (#415)
Define syntax for `return` in Carbon.
2021-05-07 14:27:21 -07:00
Jon MeowandGeoff Romer 05663633d3 Remove : from vars in exec semantics (#504)
Going through tests, funptr1.6c is the main spot I see a real change, I added parens to get around an issue parsing fnty.

Co-authored-by: Geoff Romer <gromer@google.com>
2021-05-06 14:21:31 -07:00
Jeremy G. Siek 56b47bcfa9 Type computation tests (#511)
* test of a little type computation

* another test and some bug fixes
2021-05-05 14:46:10 -04:00
Jon Meow 190fab9530 Add missing clang includes to compile_flags.txt (#522)
This is needed to fix issues like:

```
bazel-clang-toolchain/include/c++/v1/cstddef:44:15: fatal error: 'stddef.h' file not found
#include_next <stddef.h>
              ^~~~~~~~~~
```
2021-05-05 10:48:28 -07:00
Jon Meow b88586d3fe Disable ubsan vptr checks due to clang AST (#513) 2021-05-03 12:09:41 -07:00
9d1863efb7 Add var <type> <identifier> [ = <value> ]; syntax for variables (#339)
Co-authored-by: Geoff Romer <gromer@google.com>
Co-authored-by: austern <austern@google.com>
2021-04-28 13:46:26 -07:00
Richard Smith a3614f153b Rename StartSubtree -> GetSubtreeStartPosition.
This function doesn't actually start a subtree, it just remembers a
position from which we could start a subtree.
2021-04-27 13:05:28 -07:00
Richard Smith 857a7e5cc6 Add convenience functions to inspect the kind of the next token. 2021-04-27 13:05:28 -07:00
Jeremy G. Siek 8924f5620b Private unions (#492)
* changed union of Statement to be private

* changed the union in Expression to be private

* changed union in Value to be private

* changed AST constructors to be static methods

* updates to syntax unit tests
2021-04-27 14:29:13 -04:00
Geoff Romer 1933cfeeeb Stop using std::pair in the implementation of tuples (#479) 2021-04-26 11:43:06 -07:00
Jon Meow 3ff01fa60d Remove ready for review action (#501)
I tried what I could, but I don't think this action will work while Carbon is private.

"Error: Resource not accessible by integration"
https://github.com/carbon-language/carbon-lang/runs/2441129284?check_suite_focus=true

I'd seen this mentioned on some actions:
https://github.com/marketplace/actions/github-project-automation#personal-access-token-secretsgithub_token

However, I thought it might've been a side-effect of the APIs they were using (I did have this running on a local repo), but I think fork PRs are where the problem lies...
2021-04-26 11:28:12 -07:00
Jon Meow e82cc5f73f Needs public repo (#500)
Using `jonmeow` was how #496 was originally set up, but I tested with `carbon-language`. I assume we do not want a public repo under `carbon-language`, and so I've already transferred ownership back to `jonmeow` in order to have a public repo again.

https://github.com/carbon-language/carbon-lang/runs/2440951027?check_suite_focus=true
2021-04-26 11:04:02 -07:00
Jon Meow 2b58192ffa Try automating 'ready for review' on proposals. (#496) 2021-04-26 10:46:57 -07:00
a6ddc03aa6 Generics goals (#24)
The "generics" feature of Carbon is a large design effort that needs to be broken up into manageable steps. The first thing we need is a high-level goals document. The goals here reflect the desirable properties that we have discovered as part of considering several alternative generics designs:

-   Use cases:
    -   Generic programming
    -   Upgrade path from C++ abstract interfaces
    -   Dependency injection
     -   Generics instead of open overloading and ADL
-   Performance
-   Better compiler experience
-   Encapsulation
-   Predictability
-   Dispatch control
-   Upgrade path from templates
-   Coherence
-   No novel name lookup
-   Learn from others
-   Interfaces are nominal
-   Interop and evolution
-   Bridge for C++ customization points

Goals are summarized in [this presentation](https://docs.google.com/presentation/d/12yGyu5Pvdag7CJp-_yLVkmbhyvuRIilBTNlkO0LKaHo/edit?usp=sharing&resourcekey=0-JB9yrUO4-6J8-zzGhnIyNg).

Co-authored-by: Chandler Carruth <chandlerc@gmail.com>
Co-authored-by: Jon Meow <46229924+jonmeow@users.noreply.github.com>
Co-authored-by: Matthew Riley <mdriley@gmail.com>
Co-authored-by: austern <austern@google.com>
Co-authored-by: Dmitri Gribenko <gribozavr@gmail.com>
2021-04-23 17:19:23 -07:00
Geoff Romer e022ff106f Factor Heap class out of State (#491)
Additional miscellaneous cleanup:

- Use the term "deallocate" instead of "kill" in function names, for symmetry with "allocate".
- Drop an unnecessary memory allocation in `AllocateValue`.
- Implement `PrintHeap` in terms of `PrintAddress`, so that dead values are flagged with `!!`.
2021-04-23 13:25:51 -07:00
Jon MeowandMatthew Riley a13cecccc6 Updates docs for community changes (#489)
- Generally replace Discourse mentions with GitHub Discussions, per #444 
- Switch from "Discord Chat" to just "Discord" because there's no more ambiguity, and "Discord" is the more common term.
- Fix mentions of "core team" to "Carbon leads" (because the touched docs overlap a lot).

Co-authored-by: Matthew Riley <mdriley@gmail.com>
2021-04-23 09:06:52 -07:00
Jeremy G. Siek 5946d9c033 Tuple restrictions (#486)
* implement tuple restrictions: (1) named fields after positional, (2) order matters

* after_named_member => seen_named_member
2021-04-22 17:51:43 -04:00
Jon Meow 8b78a85276 Action to label proposals based on project column (#484)
Note there's a roughly minute delay due to action latency.
2021-04-22 14:43:38 -07:00
Jon Meow f4ce5eafef Delete commenting guidelines, let code_review.md stand alone (#490)
Mainly I don't think this doc has been useful, and I think links that used to be there have drifted more towards code_review.md
2021-04-22 14:42:59 -07:00
Jon MeowandChandler Carruth 5a2db81039 Switch from Discourse Forums to GitHub Discussions (#444)
Switch from Discourse Forums to GitHub Discussions

For use of https://github.com/carbon-language/carbon-lang/discussions

Co-authored-by: Chandler Carruth <chandlerc@gmail.com>
2021-04-22 09:56:26 -07:00
Richard Smith e3b732e564 Parsing support for return statements. 2021-04-21 17:53:54 -07:00
Richard Smith 7a74ac18a7 Parsing support for function return types. 2021-04-21 17:53:54 -07:00
Richard Smith 2726865940 Parse parameters in function declarations. 2021-04-21 17:53:54 -07:00
Jeremy G. Siek 928b92a428 a raw access to the heap field slipped through somehow, fixing that (#483) 2021-04-21 19:11:13 -04:00
Jeremy G. SiekandGeoff Romer e89b8daad7 more tests of tuples, mixing positional and explicit field names (#480)
* more tests of tuples, especially mixing positional and explicit field names

* test of match with nested tuple

* Update executable_semantics/testdata/fun_named_params2.6c

Co-authored-by: Geoff Romer <gromer@google.com>

Co-authored-by: Geoff Romer <gromer@google.com>
2021-04-21 17:23:16 -04:00
Jeremy G. SiekandGeoff Romer c1d651fc15 Fix equality for tuples (#446)
* fix tuple equality, added test cases

* added a comment to an old function

* Update executable_semantics/interpreter/value.cpp

Co-authored-by: Geoff Romer <gromer@google.com>

* fix error in Geoffrey's edit

Co-authored-by: Geoff Romer <gromer@google.com>
2021-04-21 17:12:10 -04:00
Geoff Romerandjosh11b 6639a915dc Principle: Errors are values (#301)
A Carbon function that needs to report recoverable failures should return a sum type whose alternatives represent the success case and failure cases, such as Optional(T), Result(T, Error), or Bool. The function's successful return
value, and any metadata about the failure, should be embedded in the alternatives of the sum type, rather than reported by way of output parameters or other side channels. Carbon's design will prioritize making this form of error handling efficient and ergonomic.

Co-authored-by: josh11b <josh11b@users.noreply.github.com>
2021-04-21 13:00:03 -07:00
Jeremy G. SiekandGeoff Romer 27fd9de5bf improved checking for liveness when reading and writing memory (#448)
* improved checking for liveness when reading and writing memory

* moving some functions to be methods of State

* finished moving functions into State

* Update executable_semantics/interpreter/interpreter.h

Co-authored-by: Geoff Romer <gromer@google.com>

* moved some comments, other minor edits

Co-authored-by: Geoff Romer <gromer@google.com>
2021-04-21 14:10:42 -04:00
Jon Meow 7e81fb9c62 Add C++-like while loops (#340)
Add C++-like `while` loops

- Omits variable declarations in condition syntax (`while (auto x = DoSomething())`).
2021-04-21 10:06:44 -07:00
Richard Smith 04a5d6dca7 Avoid performing copies of ExpectedNode objects.
These contain `vector<ExpectedNode>`s, resulting in deep copies of
potentially large trees.
2021-04-20 23:43:25 -07:00
Richard Smith c0e83206be Add helpers for matching common subtrees in parse tests. 2021-04-20 23:43:25 -07:00
Richard Smith 4a92c41673 Add a synonym for ParseExpression to use when parsing a type, to make
parsing code a little more readable.
2021-04-20 23:43:25 -07:00
Jeremy G. Siek 34f1a03f7b change all expression and statement pointers to be const (#449)
* change all expression and statement pointers to be const

* const in paren tests
2021-04-19 21:47:19 -04:00
Richard Smith 153d92b390 Parsing for while, break, and continue statements, following #340. 2021-04-19 17:09:54 -07:00
Richard Smith 146d995995 Factor out parsing a ), including skipping to a matching one if
necessary.
2021-04-19 17:09:54 -07:00
Richard Smith 5d6947186d Parsing for if-statements, following #285. 2021-04-19 17:09:54 -07:00
Richard Smith 8280be1c36 Factor statement parsing out of code block parsing. 2021-04-19 17:09:54 -07:00
Jon Meow acd10c01ef Add submodule entries for brotli and woff2 (#453)
This is to support converting the code to Carbon. My theory with the setup is:

- Have the code available to build in C++ under `third_party/<project>/original`.
- Created a `third_party/<project>/carbon` for the converted version.

Having the existing code building should, I think, make it easier to run analysis on said code. Using a submodule means we should be aiming to keep it pristine, for easy comparison / updates.
2021-04-19 16:49:09 -07:00
Jon Meow 33360a30bc Shift new proposal setup to the new process. (#468) 2021-04-19 16:43:01 -07:00
Jon Meow 37f94c964d Update evolution doc for #426 (#469)
A lot of text is mirrored over, but also some nuanced adjustments. @chandlerc and I have been working on this [in Docs](https://docs.google.com/document/d/1n6xVPKQDuTpMuMoK0BnQ8jtEaBhDo9Y50gYb1zyG-_s/edit).
2021-04-19 16:42:44 -07:00
Richard Smith d8c724045e Implement parsing for variable declarations. (#466)
Following the rules proposed in #339.
2021-04-19 12:55:35 -07:00
Richard Smith 1ee826268c Add sentinel precedence levels for the top-level expression context and (#465)
for an expression with no operators.
2021-04-15 18:57:28 -07:00