Add -XBinaryLiterals language extension (re #9224)
authorHerbert Valerio Riedel <hvr@gnu.org>
Sat, 21 Jun 2014 09:38:17 +0000 (11:38 +0200)
committerHerbert Valerio Riedel <hvr@gnu.org>
Fri, 27 Jun 2014 18:46:32 +0000 (20:46 +0200)
commit1c0b5fdc9f2b6ea8166cc565383d4cd20432343c
tree52a6c1679d03672ff4e03c22642ad0b876d5ed51
parentf4766c4b4ad10ef7c58bc6b443ec244a07c68bf5
Add -XBinaryLiterals language extension (re #9224)

Haskell2010 supports

- base-10 (prefix-less),
- base-8 (via `0[oO]`-prefix), and
- base-16 (via `0[xX]`-prefix) integer literals.

This commit adds syntax support for base-2 integer literals via the new `0[bB]`
prefix. The use of a `0b` prefix for indicating binary literals is known
from popular programming languages such as C++14, Perl, Python, Ruby, and Java.

This syntax extension is disabled by default and can be enabled via the
new `{-# LANGUAGE BinaryLiterals #-}` pragma and/or the new `-XBinaryLiterals`

This new extensions requires to upgrade the `ExtsBitmap` type from
`Word` to `Word64` as this adds a 33th flag which is not guaranteed to
fit into a `Word`.

Signed-off-by: Herbert Valerio Riedel <hvr@gnu.org>
Differential Revision: https://phabricator.haskell.org/D22
22 files changed:
compiler/main/DynFlags.hs
compiler/parser/Ctype.lhs
compiler/parser/Lexer.x
docs/users_guide/7.10.1-notes.xml
docs/users_guide/flags.xml
docs/users_guide/glasgow_exts.xml
testsuite/.gitignore
testsuite/tests/driver/T4437.hs
testsuite/tests/parser/should_fail/ParserNoBinaryLiterals1.hs [new file with mode: 0644]
testsuite/tests/parser/should_fail/ParserNoBinaryLiterals1.stderr [new file with mode: 0644]
testsuite/tests/parser/should_fail/ParserNoBinaryLiterals2.hs [new file with mode: 0644]
testsuite/tests/parser/should_fail/ParserNoBinaryLiterals2.stderr [new file with mode: 0644]
testsuite/tests/parser/should_fail/ParserNoBinaryLiterals3.hs [new file with mode: 0644]
testsuite/tests/parser/should_fail/ParserNoBinaryLiterals3.stderr [new file with mode: 0644]
testsuite/tests/parser/should_fail/all.T
testsuite/tests/parser/should_run/BinaryLiterals0.hs [new file with mode: 0644]
testsuite/tests/parser/should_run/BinaryLiterals0.stdout [new file with mode: 0644]
testsuite/tests/parser/should_run/BinaryLiterals1.hs [new file with mode: 0644]
testsuite/tests/parser/should_run/BinaryLiterals1.stdout [new file with mode: 0644]
testsuite/tests/parser/should_run/BinaryLiterals2.hs [new file with mode: 0644]
testsuite/tests/parser/should_run/BinaryLiterals2.stdout [new file with mode: 0644]
testsuite/tests/parser/should_run/all.T