Re: help with bison - Mailing list pgsql-hackers
From | Joe Conway |
---|---|
Subject | Re: help with bison |
Date | |
Msg-id | 3CB70972.1070904@joeconway.com Whole thread Raw |
In response to | help with bison (Neil Conway <nconway@klamath.dyndns.org>) |
List | pgsql-hackers |
Thomas Lockhart wrote:>> The other day there was a discussion around the fact that X'ffff'>> will get converted into an integerconstant... ... while SQL99>> says that this syntax *should* be used to specify a "binary>> string". It looks likethe 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 thingsup?>>> What else is described as a "binary string" in the spec? I would> have guessed that this would map to a bitfield 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> isthe 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 asthe <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, andF 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>sA, 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
pgsql-hackers by date: