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>
* 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
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 `!!`.
* 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>
* 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>
* 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>
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.
- 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
* 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
* 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>
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.
* 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>
* 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
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.
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>
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.
* 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>
* 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>
* 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
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++ ;-)