Commit Graph
313 Commits
Author SHA1 Message Date
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
Richard Smith 09763653b7 Add operator precedence parser. (#464) 2021-04-15 18:23:36 -07:00
Richard Smith 82d5a25caa Initial support for expression parsing. (#455) 2021-04-14 16:02:20 -07:00
Jon Meow 7a6c46dc1a Merge rationale and open question answers into proposals (#461)
In support of #426. There's still a little bit of surrounding framework that expects these decision files, but I'm trying to split out changes.

Note I'm dropping affirming/abstaining, as well as the accepted date -- I'd be happy to copy-paste decisions into comments on PRs if it'd be helpful, but I thought maybe we could drop those from the repo given they aren't asked for in on new proposals. If we change our minds, we can always look at git history too.
2021-04-14 15:23:25 -07:00
Jon Meow 6c3b50ad5e Move rationale to the proposal template (#459)
In support of #426. The decisions need to be merged into proposals, but I want to handle that separately.
2021-04-14 15:15:07 -07:00
Jon Meow d60389babd Stop generating decisions into the proposal index (#462) 2021-04-14 15:14:43 -07:00
Jon Meow f2c3f68813 Fix repo/respository (#452) 2021-04-14 14:46:51 -07:00
Jon Meow fa984743bf Update CODEOWNERS for the carbon-leads switch (#458) 2021-04-13 20:58:10 -07:00
dbf59bff6f Governance & evolution revamp (#426)
This proposal revamps Carbon's governance structure and evolution
process to try to make it significantly more efficient, friendly,
welcoming, and effective. Proposal process and RFCs are structured much
closer to a traditional code review. The review is driven by a Carbon
lead, although they may delegate some aspects and anyone in the
community is encouraged to participate. Resolving issues in order to
make a decision is handled with GitHub issues and through consensus
among a very small, focused team of leads. It also tries to encourage
explicitly showing interest and enthusiasm in Carbon proposals.

See the proposal text for all the details!

Many thanks to @KateGregory, @jonmeow, @mmdriley, and @zygoloid for
their early ideas and suggestions that ended leading to the direction of
this proposal. I also want to specifically thank them for challenging my
initial direction. 🙂

My plan is to update documentation, `CODEOWNERS`, and other
implementation details in follow-up PRs, but I'm happy to roll any of
them into this one where useful.

Landing as this was accepted by the core team, and reviewed by both a
Carbon lead and review manager so is covered in both processes.

Co-authored-by: josh11b <josh11b@users.noreply.github.com>
Co-authored-by: Jon Meow <46229924+jonmeow@users.noreply.github.com>
2021-04-13 20:57:17 -07:00
Richard Smith e96a42bd09 Add terser matching support for parse trees. (#454) 2021-04-13 15:23:05 -07:00
josh11b 160c5d06d3 Update new_proposal script with --branch-start-point (#450)
* Allow configuration of start point.

* Use git switch --create.

* Maybe fix string type.

* Fix wrong flag.

* Add --dry_run flag.

* Not sure if this is needed.

* Dry run should be safe even with uncommitted changes.

* Remove side effects with --dry_run.

* Checkpoint progress.

* Make `dry_run` parameter optional so tests pass.

* Implement suggestions from code review.

* Checkpoint progress.

* Remove new dry_run_pr_number option.

* Rename --start_point to --branch_start_point.
2021-04-12 19:46:33 -07:00
Geoff Romer cf7c97bf28 Unify tuple types with tuples-of-types in the interpreter (#442) 2021-04-12 16:13:00 -07:00
Geoff Romer 22656c8e09 Remove unused code from ValueEqual, and make unsupported cases explicit. (#434) 2021-04-09 15:09:37 -07:00
Chandler Carruth 7a00f6e15b Add ASan config and enable it in fastbuild. (#437)
Adds all the necessary machinery to our toolchain and Bazel
configuration to support ASan. This includes ensuring sufficient debug
information is available for backtraces, etc.

As part of ASan, it enables UBSan to catch more basic undefined behavior
in C++. It also enables more complete checking in ASan for lifetime
bugs.

These configs can be enabled in any build mode with `--config=asan`.
They are also enabled by default in `-c fastbuild` where asserts are
also enabled. The goal is to have a single build mode that catches the
overwhelming majority of correctness issues.

Leak checking is part of ASan and finds leaks in `executable_semantics`
code that probably aren't interesting to fix right now. I've disabled
leak checking in the `BUILD` file for the test that showed this --
everything else passed. If more things need this disabled, the same
`BUILD` change should be easily replicated.

If you see unsymbolized backtraces, you may need to either put
`llvm-symbolizer` on your path, or point the `ASAN_SYMBOLIZER_PATH`
environment variable at it. For example, in the project root you could
do something like the following to use the downloaded toolchain's
symbolizer:
```bash export
ASAN_SYMBOLIZER_PATH=$PWD/bazel-clang-toolchain/bin/llvm-symbolizer
```
I'll try to update documentation soon with this as well.
2021-04-08 12:42:13 -07:00
Chandler Carruth eb85d3dce9 Add back synchronize events for deps. (#440)
This probably isn't exactly right, but it at least gives *some* low
latency way to update when all the dependencies have been addressed.
Right now, I think only the cron run will unblock dependent PRs.
2021-04-08 09:41:55 -07:00
Chandler Carruth b414e71182 Bazel handles python modules now. (#441)
Remove them from our test CI workflow.
2021-04-08 09:38:49 -07:00
Jon Meow 7716ac6784 Update pre-commit (#439) 2021-04-08 09:01:35 -07:00
Chandler Carruth 1aeb559a51 Cleanup and condense the toolchain configuration. (#436)
There was a lot of redundant noise in the older form. It also had
several issues that made the ordering and mixing together of different
flags much less obvious.

With this change, the user-provided flags are reliably placed in
a useful position, along with fundamental flags like the source file and
output.

All of this is largely in preparation for trying to add the first
sanitizer configurations (as well as enabling them by default).
2021-04-07 11:03:35 -07:00
Jon Meow b4593f5133 Add pip_install to the build. (#435)
Updates corresponding tool instructions.
2021-04-07 09:08:02 -07:00
Geoff Romer e324935139 Miscellaneous parser cleanup (#429)
- Give unary `-` and `not` the same precedence as in C++
- Add detail to parse error messages, and make the --trace flag also enable parser debug tracing
- Make any new shift-reduce conflicts into build errors
- Use `%precedence` rather than `%nonassoc` where possible, in order to catch more grammar bugs at build time
2021-04-06 10:09:03 -07:00
Chandler Carruth 2606046477 Switch to the dependent-issues action. (#432)
This supports tracking PR-to-issue and issue-to-issue dependencies in
addition to PR-to-PR, and this seems likely to be increasingly important
as we have decisions being made via issues.
2021-04-06 01:50:01 -07:00
Geoff Romer 80f035874d Restructure handling of paren expressions (#417)
* Move nontrivial logic out of `parser.ypp` into `FieldList`, rename it to `ParenContents`, make it a class, and add tests
* Use a `FieldInitializer` struct instead of `std::pair<std::string, Expression*>` to represent the fields of a tuple
2021-04-05 10:49:25 -07:00
Geoff RomerandDave Abrahams 98a6477233 Change Doxygen-style /// comments to // (see https://google.github.io/styleguide/cppguide.html#Comment_Style) (#330)
Co-authored-by: Dave Abrahams <dabrahams@google.com>
2021-04-05 10:11:48 -07:00
Jeremy G. Siek 3d02412f2f rename env and ct_env (#419)
* change env to types, ct_env to values in type checker, change env to values in interpreter

* fix bazeliskrc, change to use latest (#420)
2021-03-30 13:41:24 -04:00
josh11b c7b93c4477 gitignore emacs temp files (#421) 2021-03-29 11:55:29 -07:00
Jeremy G. Siek 66de1981e4 fix bazeliskrc, change to use latest (#420) 2021-03-28 12:49:00 -04:00
3fa72d2984 Experimental control-flow operator (#368)
* AST and syntax for delimited control

* stashing for later

* a little more progress

* progress on delimited continuations

* delimit, suspend, and resume implemented (draft)

* example that generates the natural numbers

* fixes

* tinkering

* changed demo to experimental

* comments and name changes

* describe delimited continuations in the README

* renamed Snapshot to Continuation, edits to comments

* Update executable_semantics/ast/statement.h

improve comment for MakeDelimitStmt

Co-authored-by: Dave Abrahams <dabrahams@google.com>

* Update executable_semantics/interpreter/interpreter.cpp

remove snake_case

Co-authored-by: Dave Abrahams <dabrahams@google.com>

* edits to comments, change name of variable

* updates to handle review edits

* trailing whitespace

* fixes to delimited continuations, added more tests, also fixed assignment to do a copy

* improvements from Geoffrey

* new test from Geoffrey, fix for empty blocks

* more suggestions from Geoffrey

* more tests for delimited continuations, renaming some of them

* renamed test files

* improve a comment

* sketch of creating continuation

* initial implementation of shift/reset style continuations

* more documentation

* fix some camel case

* implemented deep copy of continuations, added a test case for it

* fixed a bug and got the recursive test case working

* removed __delimit, polished up __continuation

* back to shallow copy for continuations

* suggestions from Geoffrey

* removed structured binding (for now)

* Update executable_semantics/ast/expression.cpp

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

* responses to Geoffrey

Co-authored-by: Dave Abrahams <dabrahams@google.com>
Co-authored-by: Geoff Romer <gromer@google.com>
2021-03-26 11:22:48 -04:00
Jon Meow 6df0d51516 if/else (#285) 2021-03-24 16:02:22 -07:00
Geoff Romer 5fbad1089c Add bazel query flag to work around bug (#414)
Add Bazel query flag to work around https://github.com/bazelbuild/bazel/issues/8900
2021-03-24 12:14:34 -07:00
Richard Smith 9325b50cfe Make numeric literal parsing interface more value-oriented. (#407)
Instead of exposing a stateful Parser type, expose only the result of
its parsing action. This also makes the numeric literal code better
mirror the string literal code.
2021-03-22 15:39:44 -07:00
Richard Smith 9400c1c8ae Switch from manually tracking whether we've emitted any errors to asking the diagnostics machinery. (#406) 2021-03-22 14:01:01 -07:00
Matthew Riley cfe52b5705 Decision for #253 (#374) 2021-03-22 12:09:19 -07:00
Dave Abrahams dd4e37e761 const-ify Value*s in preparation for value semantic transformation (#409)
Making Values const allows us to separate the actual mutations (search for "*&" in this change) from places where the Value is effectively passed by-value.
2021-03-21 09:00:00 -07:00
Jeremy G. SiekandDave Abrahams 1da97fc9cf Separate alive flag from the Value class (#408)
* separate the alive flag from the Value class

* restored KillValue, added KillAddress

* added comments

* Update executable_semantics/interpreter/interpreter.cpp

Co-authored-by: Dave Abrahams <dabrahams@google.com>

* Update executable_semantics/interpreter/interpreter.cpp

Co-authored-by: Dave Abrahams <dabrahams@google.com>

* Update executable_semantics/interpreter/interpreter.cpp

Co-authored-by: Dave Abrahams <dabrahams@google.com>

* finish edits from Dave

Co-authored-by: Dave Abrahams <dabrahams@google.com>
2021-03-20 16:14:31 -04:00