Commit Graph
496 Commits
Author SHA1 Message Date
Chandler Carruth 80f87f89a1 Exclude our build and test action from doc-only changes. (#390)
No since spending the GitHub action minutes (or waiting to merge) on
Bazel when only changing markdown or other files that aren't part of the
build and test.
2021-03-12 19:59:32 -08:00
Chandler CarruthandDave Abrahams fa099f527e Proposed Carbon roadmap for 2021 (#253)
This document tries to lay out a high-level roadmap for Carbon in 2021
following the [roadmap process](/docs/project/roadmap_process.md).

Co-authored-by: Dave Abrahams <dabrahams@google.com>
2021-03-12 19:28:01 -08:00
Matthew Riley e0a9529882 Add extra parens to avoid clang-format divergence (#386)
`clang-format-11` formats this multiple-ternary-operator expression differently than `clang-format-10` and `clang-format` at (current) trunk. Adding an extra set of parentheses brings them all in agreement, avoiding oscillation as folks check the file locally then submit to CI.
2021-03-12 02:05:14 -08:00
Matthew Riley c38a027368 Update proposals list
PR #280 committed the decision for #199. #199 had the proposal and no decision
and modified `README.md`. #280 had a decision but no proposal, and *didn't*
update `README.md`. However, in a tree with both the proposal *and* its
decision, another modification is necessary.

Since only one PR modified `README.md`, there wasn't a merge conflict that
required a rebase. And since there was no rebase, each PR ran its own CI
blissfully unaware of the other.

For now, committing the results of `pre-commit run --all-files` on trunk.
Later, will look into ways to make the proposal+decision workflow less likely
to break trunk.
2021-03-10 12:10:24 -08:00
Jon Meow 0f2fa97834 Decision for String literals #199 2021-03-10 02:45:58 -08:00
Dave Abrahams 120e0145ce [executable semantics] Use type-safe variant in C++ parser (#364)
We're now one step away from eliminating bare pointers in semantic actions.

There are plenty of other cleanups and modernizations that can be made in the
parser, but the elimination of bare pointers is the one that has the highest
impact for the codebase.
2021-03-09 21:17:06 -08:00
Dave Abrahams 436a9dda79 [executable semantics] Minimal cxx parser (#363)
Makes a minimal transition to using C++ in the parser.
2021-03-09 20:46:52 -08:00
Dave AbrahamsandGeoff Romer 07a37933c6 [executable semantics] Add Syntax driver (#362)
Slowly bringing this into line with Bison's C++ example parser
so we can use strong semantic values for symbols rather than
leaking pointers.  First step is to thread a `ParseAndLexContext` 
object through the whole syntactic analysis state, like the 
example has.  In the example, it's called `driver`.

Co-authored-by: Geoff Romer <gromer@google.com>
2021-03-09 19:46:30 -08:00
Richard Smith 5375c01056 Add dedicated fuzzer for string literals. (#372) 2021-03-09 15:45:21 -08:00
Richard Smith 9fafda408d Add dedicated fuzzer for numeric literals. (#367) 2021-03-09 15:19:37 -08:00
Dave Abrahams de6995c8c3 [Infrastructure] Set up a dependent PR check (#343)
https://github.com/marketplace/actions/pr-dependency-check

Fixes #337
2021-03-09 15:11:09 -08:00
Richard Smith df6f33c545 clang-format source files. (#370)
Add some trailing `//`s to prevent clang-format from making some tests
unreadable.
2021-03-09 13:27:53 -08:00
Richard Smith 97bb6f4e80 Factor out character set handling into a separate file. (#352) 2021-03-09 12:38:46 -08:00
Richard Smith 67ee1fcaa7 Initial support for string literals, following #199 (#309) 2021-03-08 20:33:40 -08:00
Richard Smith 62ae0e08cf Merge type of diagnostic and its substitutions. (#366) 2021-03-08 15:17:21 -08:00
Dave Abrahams f61b1b18ca Revert "Merge type of diagnostic and its substitutions. (#351)"
This reverts commit 33fdabf462.
2021-03-07 18:47:38 -08:00
Richard Smith 33fdabf462 Merge type of diagnostic and its substitutions. (#351) 2021-03-07 10:11:45 -08:00
05db2012ab replace uses of AssocList with Dictionary (#344)
Co-authored-by: Geoff Romer <gromer@google.com>
Co-authored-by: Dave Abrahams <dabrahams@google.com>
2021-03-06 08:06:05 -08:00
Chandler Carruth 5d6593ee39 Speed up and simplify the configuration of testing CI. (#335)
This is primarily using the configuration matrix facilities of GitHub
actions to consolidate the overall configuration. Beyond avoiding
duplication, this also allows the default and release builds to run in
parallel. The checkout time is duplicated between these, but the rest of
the time is nicely parallelized. This has the most dramatic effect on
macOS builds. Overall, this should reduce the latency on testing from
22-28 minutes to 15-20 minutes from what I've seen which seems
worthwhile.

This does reduce the detail provided in the names of the different
configurations. However, the Bazel build mode is preserved. That seems
like the most critical pieces of information.

Much of this started with me just trying to learn more about GitHub
actions, but once understanding how the job matrix worked, it seemed
worthwhile to send out as an actual change.
2021-03-05 18:35:30 -08:00
Dave Abrahams 2f83c4be48 Separate parsing from type-checking and evaluation. (#345)
This change caused the syntax error in undef2.6c ("fun" instead of "fn") to be
detected as one would expect, thus the changed golden file.
2021-03-05 15:00:44 -08:00
Richard Smith 62ff5597e4 Cleanups from review of #326. (#346) 2021-03-05 14:37:13 -08:00
Richard Smith 9a873b46de Move numeric literal parsing out into its own files. (#326) 2021-03-04 19:33:08 -08:00
Dave Abrahams 5884aa1a5c Give syntax files more useful and mnemonic names.
Distinguishes parts that come from the parser and lexer. It used to be that all
the files were called "syntax*", but lexing and parsing are distinct phases that
are easier to keep track of when distinguished.  syntax.yy.cpp being the source
file generated by flex, containing the lexer was particularly confusing, because
the yy tends to indicate it is a yacc/Bison product, and the ".tab." substring,
indicating "tables" is not really useful to the developer.

These names also match up with what Bison's C++ example uses, which will make
the transition easier.
2021-03-04 18:45:54 -08:00
Dave Abrahams 45c487de70 executable semantics/syntax: move to a subpackage. 2021-03-04 18:45:54 -08:00
Dave Abrahams 18690b43bb Bison/Flex are now installed and built by bazel. 2021-03-04 10:12:18 -08:00
Dave Abrahams 3078f34f5e Shallow clone submodules. 2021-03-04 10:09:29 -08:00
Dave Abrahams 81dc56b312 [executable semantics] Trivial lexer cleanup (#341)
- turn off unneeded legacy flex parts.
- a couple of comments
2021-03-04 09:49:52 -08:00
Chandler Carruth d2c1aa5701 Move back to continuously updating Bazel. (#302)
We switched to the released version to minimize rebuildds of the
toolchain, but with downloading the toolchain this isn't a significant
issue any more. And without this, Bazel doesn't run on ARM macOS.

This may hit issues with broken Bazel builds and have to be reverted.
Added a TODO to reverse this as soon as we can anyways.

Also cleans up the old `.bazelversion` in favor of just using
`.bazeliskrc`. They both work, but the RC file comes first in the
sequence so happy to prefer it here.
2021-03-04 02:18:34 -08:00
Dave Abrahams 5ea7fd44c1 Don't recursively fetch submodules in CI. (#338) 2021-03-03 17:15:32 -08:00
Jon Meow 1edfb1786e Language-level safety strategy (#196)
-   Based on [#130](https://github.com/carbon-language/carbon-lang/pull/130) from chandlerc
-   [RFC](https://forums.carbon-lang.dev/t/rfc-language-level-safety-strategy-196/182)
-   [Decision](https://forums.carbon-lang.dev/t/request-for-decision-language-level-safety-strategy/196)
-   [Approval annnouncement](https://forums.carbon-lang.dev/t/accepted-language-level-safety-strategy/201)
2021-03-03 15:00:23 -08:00
fd96e0e630 add command-line flag to enable/disable tracing output (#325)
* add command-line flag to enable/disable tracing output

* adding missing exit for pattern variable in wrong context and a test case for it (#324)

* Update executable_semantics/interpreter/interpreter.cpp

comment on separate line as code

Co-authored-by: Jon Meow <46229924+jonmeow@users.noreply.github.com>

* fix interpreter's handling of optional else of if statement (#323)

* Update pattern_variable_fail.golden due to error (#334)

* Use llvm's CommandLine for parsing (#332)

* GitHub testing action (#331)

Co-authored-by: Chandler Carruth <chandlerc@gmail.com>

* add copyright

* Create a Dictionary abstraction over the raw Cons list. (#327)

* Create a Dictionary abstraction over the raw Cons list.

* renamed Cons and some methods of Dictionary, various other cleanup

* Update executable_semantics/tracing_flag.cpp

added namespace comment

Co-authored-by: Jon Meow <46229924+jonmeow@users.noreply.github.com>

* added a comment to cpp file

Co-authored-by: Jon Meow <46229924+jonmeow@users.noreply.github.com>
Co-authored-by: Dave Abrahams <dabrahams@google.com>
Co-authored-by: Chandler Carruth <chandlerc@gmail.com>
2021-03-03 16:01:59 -05:00
Jeremy G. Siek cd18e24176 Create a Dictionary abstraction over the raw Cons list. (#327)
* Create a Dictionary abstraction over the raw Cons list.

* renamed Cons and some methods of Dictionary, various other cleanup
2021-03-03 13:03:23 -05:00
Dave AbrahamsandChandler Carruth 1204f2bdcc GitHub testing action (#331)
Co-authored-by: Chandler Carruth <chandlerc@gmail.com>
2021-03-02 19:22:33 -08:00
Jon Meow 30648724c9 Use llvm's CommandLine for parsing (#332) 2021-03-02 15:16:17 -08:00
Jon Meow d48b17adc7 Update pattern_variable_fail.golden due to error (#334) 2021-03-02 15:09:54 -08:00
Jeremy G. Siek 5457916abb fix interpreter's handling of optional else of if statement (#323) 2021-03-02 13:04:49 -05:00
Jeremy G. Siek b2c9203143 adding missing exit for pattern variable in wrong context and a test case for it (#324) 2021-03-02 12:51:03 -05:00
Geoff Romer 9d0b48478f Fix compilation errors in choice1.6c (#322) 2021-03-01 15:50:50 -08:00
Richard Smith 6a2f7c9984 Comments proposal (#198)
Proposal as accepted by core team on 2021-02-19.
2021-03-01 15:32:38 -08:00
Jeremy G. Siek 675c1056bf update goldens to match fixes in PR #308 (#321) 2021-03-01 17:21:21 -05:00
Richard Smith ec6fde4d61 String literals proposal (#199)
Proposal as accepted by core team on 2021-02-23.
2021-03-01 12:10:55 -08:00
Geoff Romer fe328b2a7b Add test coverage for a trailing comma in the alternatives list, and empty parentheses in an alternative declaration. (#305) 2021-03-01 10:34:50 -08:00
Dave Abrahams f5300a84e5 Revert "improve abstraction for AssocList, fix bug in optional else (#315)" (#320)
This reverts commit bf6bb800c4.
2021-03-01 12:26:56 -05:00
Geoff RomerandJeremy G. Siek 8b3bb7c5e9 Fix type errors in function calls (#308)
* Make `field_list` always a list.

* Create separate `paren_expression` and `tuple` nonterminals

* Rename expression_or_field_list.* to field_list.*

Co-authored-by: Jeremy G. Siek <jsiek@indiana.edu>
2021-03-01 10:13:53 -05:00
Jeremy G. Siek bf6bb800c4 improve abstraction for AssocList, fix bug in optional else (#315)
* improve abstraction for AssocList, fix bug in optional else

* add flag for tracing output, clean up code for output

* turned off tracing by default, updated goldens, removed two examples that use pointers, shouldn't have been there yet
2021-03-01 10:00:02 -05:00
Dave Abrahams 102ea3ccaf Value semantics for Declaration. (#313)
This change creates an unpleasant amount of boilerplate where `Declaration` is declared, in exchange for being able to—very pleasantly—treat it as a simple value that composes with other values everywhere it is used. Applying this technique broadly will pay off in code comprehensibility; once it has been done for all things being new'd, pointers disappear and references are only needed as an idiomatic approximation of inout. The unpleasant code grows only when new polymorphic operations are added, and then only a bit, and is an idiom whose details can readily be ignored once in place. The pleasant code pervades the codebase.

Too bad we don't have existential types in C++ ;-)
2021-02-28 11:29:38 -08:00
Dave Abrahams 2afbfd6146 [executable semantics] silence known, and detect new, crashes (#312)
* Add assertion to detect UB in interpreter.cpp

This change, applied to 6e5070d ("Adapting jsiek's executable semantics tooling
for commit. (#237)"), causes the if2.6c test to segfault.  Becase the assertion
fires only when `stmt == nullptr` and no code has permission to change `stmt`
(it is `const`) before it is dereferenced in the `switch`, and nothiing in
`PrintStatement` is supposed to exit the program, the assertion is a valid
change that detects a bug.

The crash was originally manifest in 29a5994 ("Executable Semantics: 1st-class
stacks (#296)").

* Temporarily disable the if2 test pending #311

See https://github.com/carbon-language/carbon-lang/issues/311

* [executable semantics] Record exit code on expected error.

This will prevent a final segfault from sneaking by, detected as a passing test.
A more principled follow-up commit would bottleneck detected error exit
reporting and have it write something to std::cerr that can be recognized.
2021-02-27 18:52:22 -08:00
Dave Abrahams 2205fd52ce [executable semantics] class-ify Declaration (#307)
* [executable semantics] class-ify Declaration

NFC (no functional change).

Proof of concept that we can simplify code by replacing unions with safer, more
regular types.  Hand-rolled existentials (type-erasing CoW wrappers) are a follow-on
step that will further simplify usage.

Began adding `const` where possible, and replacing `std::string*` with
`std::string`.  Most `const`s can disappear as we replace reference semantics
with value semantics, but in the meantime it's an important step in the right
direction.
2021-02-27 13:32:03 -08:00
Chandler Carruth cd57024042 Clean up more issues after running clang-format. (#310) 2021-02-26 19:18:40 -08:00
Richard Smith e5335efb44 Simplify error reporting interface (#291) 2021-02-26 18:04:53 -08:00