Commit Graph

1209 Commits

Author SHA1 Message Date
Brian Huffman
6247faa2c8 Add '.' and ':' to the set of allowable operator symbols.
This fixes part of #368.
2016-09-19 11:50:30 -07:00
robdockins
7a4cbc8e03 Merge pull request #374 from thoughtpolice/fix-terminal-use
Fix up terminal title usage and color output
2016-09-15 09:51:58 -07:00
Brian Huffman
6d6a6ca90c Preserve parens when parsing list enumeration arguments.
List enumeration arguments are parsed as expressions and
then converted to types afterward. Previously parenthesis
productions were dropped; e.g. "[1..(2+2)*(3+3)]" was
parsed as "[1..2+2*3+3]" before resolving infix precedence.
This is now fixed.

Fixes #379.
2016-09-14 15:13:38 -07:00
Robert Dockins
a048690e3a Use more efficent algorithms based on barrel-shifters for implementing
shifts and rotates in the symbolic backend.
Fixes #376
2016-08-25 12:04:58 -07:00
Robert Dockins
14af3690c6 Update the SIV example to avoid issue #375. 2016-08-23 14:08:15 -07:00
Robert Dockins
cd9ffed00b Update examples to use (/\) instead of (&&) where appropriate,
and to squash other warnings related to the upcomming precedence change.
2016-08-22 18:14:44 -07:00
Robert Dockins
e9c8b6ccd1 Add regression test for bitshift operations 2016-08-22 15:36:16 -07:00
Robert Dockins
fd164aa1f9 Repair the implementation of the shift and rotate operations in the
symbolic simulator.  They were previously calculating incorrect
answers for certain bit sequences.
2016-08-22 14:41:23 -07:00
Robert Dockins
3c270cb5ce Fix a typo in the implementation of the (>>) primitive. This was causing
incorrect cacluations when applied to certain bit sequences.
2016-08-22 14:29:42 -07:00
Austin Seipp
1f4b9518a3 Add a --color command line option
This command has three options: 'auto', 'none', and 'always'. They're
fairly self explanatory. 'auto' is the default, and detects that the
terminal output is not equal to `dumb`, and that `stdout` is a
terminal handle.

The choice of option has no impact on whether the title sequence is
sent to the ANSI terminal. That is always detected automatically and
independently of this option.

Signed-off-by: Austin Seipp <aseipp@pobox.com>
2016-08-19 19:17:58 +00:00
Austin Seipp
c897575af5 Only set console terminal title when stdout supports ANSI sequences
In some environments, setting the terminal title does not work, like
Emacs. This results in very ugly output when using Cryptol as a REPL
inside emacs with cryptol-mode, because Emacs merely repeats the
escape sequences back to you, completely ruining the main REPL.

This patch only sets the terminal if the `stdout` handle is detected
to support ANSI escape sequences. This is an adequate check for
setting the title. Note the exact semantics are to check that the
output is a terminal, and that `TERM` is not set to `dumb`, which is
what Emacs sets it to. In the future, `shouldSetREPLTitle` may be
expanded to include other cases if that isn't enough.

Note a subtle point about this: the function to check this case is
very specifically named, because while we may not be able to support
certain terminal codes, we *can* support ANSI escape sequences in
places like Emacs, reliably.

Thus, this patch does not have any changes to the color output: that
should be handled by a follow up patch (that allows either autodetect,
or explicit enable/disable, on the command line). Then, Emacs will be
able to explicitly request color support for the REPL when invoked,
while the REPL code itself will reliably abstain from setting the
title in such environments automatically. There shouldn't ever be a
need to export some '--set-ansi-terminal-title' flag with this logic.

Signed-off-by: Austin Seipp <aseipp@pobox.com>
2016-08-19 18:52:54 +00:00
Robert Dockins
12bbfb5d7d Make parts of the lexer more strict. This squashes a minor space leak. 2016-08-18 16:05:23 -07:00
Robert Dockins
3becedd910 Update tests to remove spurious failures 2016-08-18 16:05:23 -07:00
Brian Huffman
c5f33ab478 Fix compiler warnings 2016-08-17 11:39:00 -07:00
Brian Huffman
fb9f4e2a56 Make fastTypeOf support tuple/record selectors on lists 2016-08-17 09:53:26 -07:00
Robert Dockins
a774bcca5b Begin issuing warnings whenever the fixity is used to disambiguate
parses involving (&&) and (||) relative to the comparison operators,
or between (&&) and (^).  These operators are scheduled to change
fixity levels. See issue #241.
2016-08-16 16:29:49 -07:00
Robert Dockins
7d8f0e2385 Fix an incorrect error message 2016-08-16 16:24:31 -07:00
Robert Dockins
28d4f1d3fe Modify 'updates' and 'updatesEnd' to take the indices and values
as separate vector arguments, rather than as a single vector
argument of pairs.
2016-08-16 14:36:46 -07:00
Robert Dockins
64267f51ac Add the short-cutting boolean operators (/\), (\/), and (==>)
to the Cryptol prelude.  This is in service of eventually addressing
issue #241.
2016-08-12 17:12:34 -07:00
Robert Dockins
f6f1d84770 Update the Cryptol documentation with the new 'update' primitives 2016-08-12 16:18:11 -07:00
Robert Dockins
af0db1af38 Fix minor typo in the Cryptol prelude that was messing up the
help text for (!!)
2016-08-12 16:13:32 -07:00
Robert Dockins
f746ef0d66 Fix test suite after changes to Cryptol prelude altered output 2016-08-12 12:22:58 -07:00
Robert Dockins
dae3ab11b1 Change the representation and caching of sequences for better performance.
There are two major changes in this patch.  The first is that sequence maps
now have special representations for point updates, of the sort produced by
the 'update' and 'updateEnd' primtives.  These updates are stored in a
finite map, rather than as a functional-update thunk using lambdas; this
reduces memory usage and improves time efficecy of sequences defined by
sequences of updates.

The second change is that the caching policy for sequences is changed
to retain all previously-calculated values.  This is a change from the
previous LRU policy, which retained only a small finite number of previous
values.  Benchmarking showed that unbounded memoization was better for
performance in essentially all cases over both an LRU and an adaptive
caching strategy.  The potential downside is that we may retain values
longer than necessary.  If this becomes a problem, we may need to revisit
this decision.
2016-08-12 12:10:49 -07:00
Robert Dockins
c484a8c253 Implement 'update' primitives for the symbolic simulator 2016-08-12 12:10:49 -07:00
Robert Dockins
785687a67f Add new vector update primitives 'update' and 'updateEnd' which update
vectors at indices starting from the beginning/end of the vector,
respectively.

Included in this patch are implementations of these primitives
for the concrete evaluator.  Symbolic primitives are TODO.
2016-08-12 12:10:48 -07:00
Trevor Elliott
b16a1b8909 Fix name introduction for newtypes
The newtype doesn't introduce two distinct names, but just one that is re-used
at the type and expression level. This is OK, as the two namespaces are
distinct, thus there is no ambiguity.

Fixes #369
2016-08-12 11:44:16 -07:00
Brian Huffman
46793ade99 Rename test "issue289" to "trac289"
Renamed because this test does not correspond
to github issue number 289.
2016-08-10 14:07:11 -04:00
Brian Huffman
d53edee9f1 With :set ascii=on, print quotation marks around strings 2016-08-10 14:02:14 -04:00
Robert Dockins
b5a25f4f47 Fix an issue where literal sequences of bit values were being
incorrectly reversed.
2016-08-10 13:55:54 -04:00
Brian Huffman
0024dd0300 Update test output 2016-08-10 13:49:09 -04:00
Adam C. Foltzer
2f64119440 split benchmark XML into separate files
This will hopefully yield better scale in the graphs on the Jenkins job
2016-08-09 14:05:30 -04:00
Adam C. Foltzer
1a68b4f640 add benchmarks for Extras
There are separate benchmarks for the Extras.cry module and the combined
Prelude + Extras module because the performance characteristics are nonlinear.
2016-08-09 13:47:25 -04:00
Adam C. Foltzer
9ad1ff98c6 fixes #363 2016-08-09 11:42:53 -04:00
Brian Huffman
5b63ea2ad0 Add infix precedence declaration for (%). Fixes #362. 2016-08-09 08:25:26 -07:00
Brian Huffman
a8eccb9db7 Fix some incorrect syntax in Programming Cryptol appendix 2016-08-04 14:36:33 -07:00
Brian Huffman
e868e78601 Update precedence table to match Cryptol prelude 2016-08-04 14:33:41 -07:00
Iavor S. Diatchki
20e90c2194 Merge branch 'master' of github.com:GaloisInc/cryptol 2016-08-04 10:55:51 -07:00
Iavor S. Diatchki
aa0d3ad399 Fixes #361 2016-08-04 10:55:45 -07:00
Brian Huffman
c537b5a1cd Small fixes for "Programming Cryptol" appendices 2016-08-04 10:54:11 -07:00
Brian Huffman
5bca2a5560 Fix lots of wrong types for primitives in appendix B 2016-08-03 16:18:31 -07:00
Brian Huffman
ed1dd212ab More small fixes in Programming Cryptol 2016-08-03 16:04:10 -07:00
Brian Huffman
4cc76e6c8b Small fixes for crash-course chapter of Programming Cryptol
Changes include spelling, grammar, punctuation,
typesetting, and code formatting. A few factual errors
have been fixed, and some Cryptol REPL output has been
updated as well.
2016-08-03 09:54:52 -07:00
Robert Dockins
1528fb524d Comment cleanup 2016-07-25 16:00:07 -07:00
Robert Dockins
2c4bd660ea Clean up VWord/VSeq handling in some of the Cryptol primitives,
and add some missing cases.
2016-07-25 15:58:12 -07:00
Robert Dockins
1c5f786811 Fix an off-by-one error in the implementation of 'split'.
This was causing incorrect computation in examples/MiniLock/prim/Blake2s.cry.
2016-07-25 14:43:17 -07:00
Robert Dockins
2e15d4f443 Increase the size of the garbage collector nursery to 64m.
This greatly increases mutator productivity, and thus provides
significant speedups on some examples.  The tradeoff with
larger nurseries is the potential for long GC pause times.
This is probably acceptable tradeoff for a tool like Cryptol,
despite the potential for unresponsiveness at the REPL.
2016-07-20 15:55:05 -07:00
Iavor S. Diatchki
b1b7b8b599 Merge pull request #356 from thoughtpolice/stdlib-iterate
lib/extras: add iterate
2016-07-18 11:20:47 -07:00
Iavor S. Diatchki
8c36992904 Merge pull request #344 from adrianherrera/enhancement/MISTY1
Crytol spec for MISTY1 cipher
2016-07-18 11:19:53 -07:00
Austin Seipp
e197497059 lib/extras: add iterate
Signed-off-by: Austin Seipp <aseipp@pobox.com>
2016-07-18 09:01:45 +00:00
Robert Dockins
5d1e1948d8 Add test case to demonstrate tracing, as discussed in issue 68.
The new evaluator allows us to have more direct control over
evaluation order, and makes it straightforward to implement tracing
primitives.  There are two new primitives 'trace' and 'traceVal' in the
Cryptol prelude that produce tracing output when evaluated.
Fixes #68
2016-07-13 15:09:56 -07:00