[GHC] #9224: Add support for binary integer literals

#9224: Add support for binary integer literals -------------------------------------------+------------------------------- Reporter: hvr | Owner: Type: feature request | Status: new Priority: normal | Milestone: 7.10.1 Component: Compiler (Parser) | Version: Keywords: literals | Operating System: Architecture: Unknown/Multiple | Unknown/Multiple Difficulty: Easy (less than 1 hour) | Type of failure: Blocked By: | None/Unknown Related Tickets: | Test Case: | Blocking: -------------------------------------------+------------------------------- Currently, Haskell98/2010 support base-10, base-8 (via `0[oO]`-prefix) and base-16 (via `0[xX]`-prefix) integer literals. I hereby propose to add conditional support for base-2 integers via a `0[bB]`-prefix, controlled via a new `-XBinaryLiterals` language extension flag/pragma. The change to the lexer is trivial (see attached patch), however I'm stuck on the lexer using a 32-bit feature-mask, of which all 32bits are already taken, and I'd need a 33th bit for the `BinaryLiteralsBit` flag. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9224 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9224: Add support for binary integer literals -------------------------------------+------------------------------------- Reporter: hvr | Owner: Type: feature request | Status: new Priority: normal | Milestone: 7.10.1 Component: Compiler | Version: (Parser) | Keywords: literals Resolution: | Architecture: Unknown/Multiple Operating System: Unknown/Multiple | Difficulty: Easy (less than 1 Type of failure: None/Unknown | hour) Test Case: | Blocked By: Blocking: | Related Tickets: -------------------------------------+------------------------------------- Comment (by hvr): Initial patch (sans the language-extension) pushed to https://phabricator.haskell.org/D22 for review -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9224#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9224: Add support for binary integer literals -------------------------------------+------------------------------------- Reporter: hvr | Owner: Type: feature request | Status: new Priority: normal | Milestone: 7.10.1 Component: Compiler | Version: (Parser) | Keywords: literals Resolution: | Architecture: Unknown/Multiple Operating System: Unknown/Multiple | Difficulty: Easy (less than 1 Type of failure: None/Unknown | hour) Test Case: | Blocked By: Blocking: | Related Tickets: -------------------------------------+------------------------------------- Description changed by hvr: Old description:
Currently, Haskell98/2010 support base-10, base-8 (via `0[oO]`-prefix) and base-16 (via `0[xX]`-prefix) integer literals.
I hereby propose to add conditional support for base-2 integers via a `0[bB]`-prefix, controlled via a new `-XBinaryLiterals` language extension flag/pragma. The change to the lexer is trivial (see attached patch), however I'm stuck on the lexer using a 32-bit feature-mask, of which all 32bits are already taken, and I'd need a 33th bit for the `BinaryLiteralsBit` flag.
New description: Haskell2010 supports - base-10 (prefix-less), - base-8 (via `0[oO]`-prefix), and - base-16 (via `0[xX]`-prefix) integer literals. I hereby propose to add conditional support for base-2 integers literals via a `0[bB]`-prefix, disabled by default, and controllable via a new `{-# LANGUAGE BinaryLiterals #-}` language extension flag/pragma. The use of a `0b` prefix for indicating binary literals is known from popular programming languages such as Python, Ruby, and Java. -- -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9224#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9224: Add support for binary integer literals
-------------------------------------+-------------------------------------
Reporter: hvr | Owner:
Type: feature request | Status: new
Priority: normal | Milestone: 7.10.1
Component: Compiler | Version:
(Parser) | Keywords: literals
Resolution: | Architecture: Unknown/Multiple
Operating System: Unknown/Multiple | Difficulty: Easy (less than 1
Type of failure: None/Unknown | hour)
Test Case: | Blocked By:
Blocking: | Related Tickets:
-------------------------------------+-------------------------------------
Comment (by Herbert Valerio Riedel

#9224: Add support for binary integer literals
-------------------------------------+-------------------------------------
Reporter: hvr | Owner:
Type: feature request | Status: new
Priority: normal | Milestone: 7.10.1
Component: Compiler | Version:
(Parser) | Keywords: literals
Resolution: | Architecture: Unknown/Multiple
Operating System: Unknown/Multiple | Difficulty: Easy (less than 1
Type of failure: None/Unknown | hour)
Test Case: | Blocked By:
Blocking: | Related Tickets:
-------------------------------------+-------------------------------------
Comment (by Herbert Valerio Riedel

#9224: Add support for binary integer literals -------------------------------------+------------------------------------- Reporter: hvr | Owner: Type: feature request | Status: closed Priority: normal | Milestone: 7.10.1 Component: Compiler | Version: (Parser) | Keywords: literals Resolution: fixed | Architecture: Unknown/Multiple Operating System: Unknown/Multiple | Difficulty: Easy (less than 1 Type of failure: None/Unknown | hour) Test Case: | Blocked By: Blocking: | Related Tickets: -------------------------------------+------------------------------------- Changes (by hvr): * status: new => closed * resolution: => fixed -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9224#comment:5 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9224: Add support for binary integer literals -------------------------------------+------------------------------------- Reporter: hvr | Owner: Type: feature request | Status: closed Priority: normal | Milestone: 7.10.1 Component: Compiler | Version: (Parser) | Resolution: fixed | Keywords: literals Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by Lemming): That's pretty useful for bit manipulation! -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9224#comment:6 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC