SQLite Forum

"=" character not mentioned in expr syntax definition
Login

"=" character not mentioned in expr syntax definition

(1) By anonymous on 2021-07-13 04:28:03 [link] [source]

In the docs, the expr syntax definition doesn’t seem to include the "=" character anywhere in it, when expressions such as x == y are possible (especially in WHERE clauses)

Why is this the case? Am I misunderstanding something?

Thanks!

(2.2) By Larry Brasfield (larrybr) on 2021-07-13 09:26:46 edited from 2.1 in reply to 1 [source]

In the docs, the expr syntax definition doesn’t seem to include the "=" character anywhere in it ...

Why is this the case? Am I misunderstanding something?

I would call it a disappointed expectation rather than misunderstanding. The set of "terminals" known as binary operators is shown here. And of course the expression syntax includes those terminals. (See 5th alternative from top: nonterminal(expr) --> terminal(binary-operator) --> nonterminal(expr) .)

Your misexpectation1 is that the terminals should appear individually in the syntax diagrams. They do not; often they appear only as a class (such as "binary-operator"2), which is what the lexer returns to the parser, and what we call "terminals" for that reason.

Conceptually, all those binary operators could be separate terminals, leading to a much-expanded "syntax" diagram. That would be a disfavor to readers, IMO.


  1. Yes, that's a "new" word apparently. Let dictionary authors keep up.

  2. Technically, this is not really true for the SQLite parser. The set of binary operators are returned individually to the parser, grammar for which treats certain subsets as equivalent. The syntax diagrams are not a literal rendition of the grammar input to Lemon; they are an abstraction of it (modulo errors by their human author.)

(4) By TripeHound on 2021-07-13 09:06:05 in reply to 2.1 [link] [source]

The OED (Oxford English Dictionary) has "kept up"! Although mis-expectation doesn't have its own entry, it is listed (with hyphen) under the prefix "mis-" with two citations (the latter omitting the hyphen):

mis-expectation n. Brit. /ˌmɪsɛkspɛkˈteɪʃn/, U.S. /ˌmɪsˌɛkˌspɛkˈteɪʃən/

1685 R. Baxter Paraphr. New Test. Matt. xxiv. 3 Though Christ do not presently blame their mis-expectations.

1992 Q. Jrnl. Econ. 107 1014 A transient increase in employment owing to rigidity or stickiness or misexpectations governing nominal wages or prices.

(3) By mzm2021 on 2021-07-13 08:47:51 in reply to 1 [link] [source]

= is a binary operator and its use is referenced in the 6th line of the syntax diagram.

expr binary-operator expr
box "expr" fit; arrow; oval "binary-operator" fit; arrow; box "expr" fit

All binary operators supported by SQLite are listed in Operators.