Commit Graph
261 Commits
Author SHA1 Message Date
Chandler Carruth 8f1f9b9fc2 Remove unused bits from our WORKSPACE. (#402)
Originally, I experimented with special rules for C++ builds of LLVM but
we ended up with a native build of it instead. Loading and using this
was completely unnecessary now and would have needed an update. Just
remove it.

Fixes #400
2021-03-19 01:00:26 -07:00
Chandler CarruthandJon Meow 251402ceb7 Make Python 3.6 our minimum version and fix tests. (#401)
This matches the version on Ubuntu LTS and other OSes. The only problem
I found with it in our testing is that Bazel confusingly sets the locale
to use `LANG=en_US` by default which breaks UTF-8 support. We may need
to shift this on Windows, but this seems like a reasonable first step.

Co-authored-by: Jon Meow <46229924+jonmeow@users.noreply.github.com>
2021-03-19 00:58:46 -07:00
Richard Smith 426c789d6e Convert parser diagnostics to use the diagnostic emitter. (#389) 2021-03-18 22:09:06 -07:00
Richard Smith 1e6c7e3963 Add sentinel Eof token at the end of the tokenized buffer. (#388)
This has two goals:

1) It allows us to simplify and remove special cases from the parser:
   when we expect a particular token next, we can just check for it
   without needing a special case for end-of-file.

2) It gives us a token to use as a position when emitting diagnostics at
   the end of the file.

Centralize all updating of `position` to `Consume` and `SkipTo`, so that we can in a single place ensure that we never go past the EOF token.
2021-03-18 21:39:10 -07:00
Richard Smith d1757d9979 Add location information to diagnostics. (#385)
Add simple mocking and testing of diagnostic emission to ensure this
works.
2021-03-18 21:05:54 -07:00
Jeremy G. Siek b2455d8dba renames ExecutionEnvironment, fixes #394 (#395) 2021-03-18 22:19:31 -04:00
Chandler CarruthandGeoffrey Romer e440b07eb3 Improve correctness of our Clang tooling infrastructure. (#392)
This restructures the `compile_flags.txt` to use the downloaded libc++ system
headers and avoid needing a virtual include directory to be built. It still
needs _some_ Bazel build to complete before working in order to have the libc++
system headers downloaded and the symlink to the Bazel tree created.

One (very) tricky part of making this work is to work around bugs in Clang's
tooling layer that incorrectly handle `..` path components after traversing
symlinks. To avoid this, we add a custom symlinks (`bazel-execroot` and
`bazel-clang-toolchain`) that hide the relevant traversal of the Bazel layout to
find build artifacts and the downloaded toolchain. These symlinks will be broken
until a build with Bazel downloads the toolchain and creates the basic output
tree structure.

It also adds a `create_compdb.py` script. Running this script improves the
tooling fidelity by taking a few steps:

1. It queries Bazel to find all the relevant files and adds them to a
   `compile_commands.json` database that allows `clangd` and other tools to
   index the entire project for improved cross-references, etc.
2. It builds all the generated files with Bazel so that they can be included
   successfully. This is very fast in my testing, taking only 10s of seconds. It
   is also very likely to be cached effectively.
3. It translates the arguments from `compile_flags.txt` to make them
   persistently use the built generated files include paths so that nothing
   breaks even as different targets are built potentially with different
   configurations.

There are still some limitations.

- It still requires running Bazel before anything works, even if a fast run.
- It will require re-running if new generated files are added and needed but not
  built.
- It assumes that the standard Bazel symlink names are used and available.

Much of the Python here was written by @geoffromer in #384 -- I've adapted it
here after discussing to try to fill in some of the blanks and use a slightly
different approach to querying Bazel. I use the normal `bazel query` rather than
`bazel aquery`. This, for example, allows the index to reliably cover header
files in header-only libraries more directly (rather than relying on transitive
inclusion). It also seems a bit simpler too parse, but that is a pretty minor
difference.

Co-authored-by: Geoffrey Romer <gromer@google.com>
2021-03-18 02:29:49 -07:00
Dave Abrahams 7e1721dc01 lowerCamelCase => snake_case (#396) 2021-03-17 13:09:58 -07:00
Dave Abrahams 71a8d072b4 Remove unused bazel rule (#376) 2021-03-17 10:51:16 -07:00
Dave Abrahams c4252d1c6d Remove obsolete TODO (#375) 2021-03-17 10:27:33 -07:00
Dave Abrahams 5ca6e21e11 Remove an unused function (#380) 2021-03-17 09:58:34 -07:00
Richard Smith ae9ca945b9 Rename {String,Numeric}LiteralToken -> Lexed{String,Numeric}Literal. (#373)
This avoids using a name too similar to Token::StringLiteral (the token
kind) and TokenizedBuffer::Token (which is not related to these
classes).
2021-03-16 12:42:52 -07:00
Jeremy G. SiekandJon Meow 7c4fcd3fa5 turn off tracing by default, change golden (#381)
* turn off tracing by default, change golden

* Update executable_semantics/main.cpp

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

* Update executable_semantics/main.cpp

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

* merge with trunk, update goldens

Co-authored-by: Jon Meow <46229924+jonmeow@users.noreply.github.com>
2021-03-16 09:03:10 -04:00
Jeremy G. Siek ced98ef021 Global variables (#378)
* global variables

* implemented type checking of global variable, added test case

* added a comment

* improvements based on Dave's suggestions

* improvements based on Jon's suggestions

* added test cases about global variable ordering
2021-03-15 16:06:27 -04:00
Jon Meow 41786eae25 Decision for Comments #198 (#275) 2021-03-15 09:53:15 -07:00
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