Skip to content
STIMSMITH

Bitvector Literal

Concept WIKI v1 · 8/6/2026

In the Sail ISA specification language, a bitvector literal is a form of literal that denotes a fixed-width bitvector value. The Sail grammar enumerates two lexical forms of bitvector literal and two named constant bitvector literals, alongside other numeric and boolean literals.

Bitvector Literal

Overview

In the Sail ISA Specification Language, a bitvector literal is a lexical literal form that directly denotes a bitvector value of a specific width. Bitvector literals are part of Sail's general lit category, which appears in expressions (<exp>, <atomic_exp>), patterns (<pat>, <atomic_pat>), and atomic type contexts (<atomic_typ>).

Grammar Position

The <lit> non-terminal in the Sail grammar is the single production point at which bitvector literals are introduced. From the Sail grammar, <lit> is defined as:

<lit> ::= true
        | false
        | ()
        | NUMBER
        | undefined
        | bitzero
        | bitone
        | BINARY_LITERAL
        | HEXADECIMAL_LITERAL
        | STRING_LITERAL

Within this production, the members that denote bitvector values are:

  • BINARY_LITERAL — a binary-formatted bitvector literal.
  • HEXADECIMAL_LITERAL — a hexadecimal-formatted bitvector literal.
  • bitzero — a named literal whose value is a bitvector consisting entirely of zero bits.
  • bitone — a named literal whose value is a bitvector consisting entirely of one bits.

The two numeric literal forms (BINARY_LITERAL, HEXADECIMAL_LITERAL) provide explicit, width-carrying representations of bitvectors in source code, while bitzero and bitone provide convenient names for the all-zero and all-one bitvectors.

Occurrences in the Grammar

The <lit> production containing bitvector literals appears in several places in the Sail grammar:

  • In atomic patterns (<atomic_pat>), allowing bitvector literals to be used as pattern matches.
  • In atomic expressions (<atomic_exp>), allowing bitvector literals as values in expressions.
  • In atomic types (<atomic_typ>), allowing bitvector literals to be used in type-level contexts.

These appearances mean bitvector literals can be written both as values and within pattern-matching positions during match expressions.

Related Concepts

  • Sail ISA Specification Language — The language in which bitvector literals are defined.
  • BNF Grammar — The grammar formalism used to specify the syntax of bitvector literals.

References

  • Sail language specification (grammar excerpt).

CITATIONS

3 sources
3 citations
[1] The Sail grammar defines <lit> with alternatives true, false, (), NUMBER, undefined, bitzero, bitone, BINARY_LITERAL, HEXADECIMAL_LITERAL, and STRING_LITERAL. The Sail instruction-set semantics specification language
[2] Within <lit>, the forms BINARY_LITERAL and HEXADECIMAL_LITERAL denote bitvector literals, and bitzero/bitone denote all-zero/all-one bitvector constants. The Sail instruction-set semantics specification language
[3] The <lit> production is referenced from <atomic_typ>, <atomic_pat>, and <atomic_exp>, allowing bitvector literals in type, pattern, and expression positions. The Sail instruction-set semantics specification language