Let's say I have a SQL-like language that supports seeing if two expressions are equal only if they are the same type, and if they're not the same type it'll raise an error. Examples would be:
1 = 1 # true
1 = 1.2 # false
1 = '1' # error
1 = '1'::int # true
What would the best production for this be?
EQ: expr '=' expr
Or something much more detailed, which would attempt to catch type errors at the lexing(parsing?) stage, such as:
EQ: numeric_expr '=' numeric_expr
| string_expr '=' string_expr
| ...etc