Re: help with bison

From: Joe Conway <mail(at)joeconway(dot)com>
To: Thomas Lockhart <lockhart(at)fourpalms(dot)org>
Cc: Neil Conway <nconway(at)klamath(dot)dyndns(dot)org>, Barry Lind <barry(at)xythos(dot)com>, chriskl(at)familyhealth(dot)com(dot)au, pgsql-hackers(at)postgresql(dot)org
Subject: Re: help with bison
Date: 2002-04-12 16:21:06
Message-ID: 3CB70972.1070904@joeconway.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Thomas Lockhart wrote:
>> The other day there was a discussion around the fact that X'ffff'
>> will get converted into an integer constant... ... while SQL99
>> says that this syntax *should* be used to specify a "binary
>> string". It looks like the hex-to-integer magic actually occurs in
>> the lexer, and then the integer value of 65535 is passed to the parser
>> as an ICONST. I'm wondering if changing the lexer to make this a
conversion
>> to a properly escaped bytea input string, and passing it to the
>> parser as a string constant would speed things up?
>
>
> What else is described as a "binary string" in the spec? I would
> have guessed that this would map to a bit field type (and maybe even
> had looked it up at one time).
>
> Is B'00010001' also described as a "binary string" also, or is it
> more explicitly tied to bit fields?
>
> - Thomas

In SQL99, Section "5.3 <literal>", I see this:

<national character string literal> ::=
N <quote> [ <character representation>... ] <quote>
[ { <separator> <quote> [ <character representation>... ]
<quote> }... ]
<bit string literal> ::=
B <quote> [ <bit>... ] <quote>
[ { <separator> <quote> [ <bit>... ] <quote> }... ]
<hex string literal> ::=
X <quote> [ <hexit>... ] <quote>
[ { <separator> <quote> [ <hexit>... ] <quote> }... ]
<binary string literal> ::=
X <quote> [ { <hexit> <hexit> }... ] <quote>
[ { <separator> <quote> [ { <hexit> <hexit> }... ] <quote> }... ]
<bit> ::=
0 | 1
<hexit> ::=
<digit> | A | B | C | D | E | F | a | b | c | d | e | f

and further down:

11) The declared type of a <bit string literal> is fixed-length
bit string. The length of a <bit string literal> is the number
of bits that it contains.
12) The declared type of a <hex string literal> is fixed-length bit
string. Each <hexit> appearing in the literal is equivalent to
a quartet of bits: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E,
and F are interpreted as 0000, 0001, 0010, 0011, 0100, 0101,
0110, 0111, 1000, 1001, 1010, 1011, 1100, 1101, 1110, and 1111,
respectively. The <hexit>s a, b, c, d, e, and f have respectively
the same values as the <hexit>s A, B, C, D, E, and F.
13) The declared type of a <binary string literal> is binary string.
Each <hexit> appearing in the literal is equivalent to a quartet
of bits: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, and F are
interpreted as 0000, 0001, 0010, 0011, 0100, 0101, 0110, 0111,
1000, 1001, 1010, 1011, 1100, 1101, 1110, and 1111, respectively.
The <hexit>s a, b, c, d, e, and f have respectively the same
values as the <hexit>s A, B, C, D, E, and F.

So, as Peter pointed out, X'ffff' can be interpreted as a binary string
*or* a bit string, but ISTM B'1111' is explicitly tied to a bit string.

Joe

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2002-04-12 16:41:19 Re: numeric/decimal docs bug?
Previous Message Bruce Momjian 2002-04-12 16:21:04 Re: 7.3 schedule