netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* shift_stmt_expr grammar question
@ 2020-03-08 10:40 Jeremy Sowden
  2020-03-09  9:25 ` Pablo Neira Ayuso
  0 siblings, 1 reply; 2+ messages in thread
From: Jeremy Sowden @ 2020-03-08 10:40 UTC (permalink / raw)
  To: Netfilter Devel

[-- Attachment #1: Type: text/plain, Size: 727 bytes --]

Just noticed that the production for right shifts differs from the
production for left shifts (src/parser_bison.y, ll. 3020ff.):

  shift_stmt_expr    :       primary_stmt_expr
                     |       shift_stmt_expr         LSHIFT          primary_stmt_expr
                     {
                             $$ = binop_expr_alloc(&@$, OP_LSHIFT, $1, $3);
                     }
                     |       shift_stmt_expr         RSHIFT          primary_rhs_expr
                     {
                             $$ = binop_expr_alloc(&@$, OP_RSHIFT, $1, $3);
                     }
                     ;

Is there a reason why the RHS of LSHIFT is primary_stmt_expr, but the
RHS of RSHIFT is primary_rhs_expr?

J.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 659 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: shift_stmt_expr grammar question
  2020-03-08 10:40 shift_stmt_expr grammar question Jeremy Sowden
@ 2020-03-09  9:25 ` Pablo Neira Ayuso
  0 siblings, 0 replies; 2+ messages in thread
From: Pablo Neira Ayuso @ 2020-03-09  9:25 UTC (permalink / raw)
  To: Jeremy Sowden; +Cc: Netfilter Devel

[-- Attachment #1: Type: text/plain, Size: 993 bytes --]

Hi Jeremy,

On Sun, Mar 08, 2020 at 10:40:03AM +0000, Jeremy Sowden wrote:
> Just noticed that the production for right shifts differs from the
> production for left shifts (src/parser_bison.y, ll. 3020ff.):
> 
>   shift_stmt_expr    :       primary_stmt_expr
>                      |       shift_stmt_expr         LSHIFT          primary_stmt_expr
>                      {
>                              $$ = binop_expr_alloc(&@$, OP_LSHIFT, $1, $3);
>                      }
>                      |       shift_stmt_expr         RSHIFT          primary_rhs_expr
>                      {
>                              $$ = binop_expr_alloc(&@$, OP_RSHIFT, $1, $3);
>                      }
>                      ;
> 
> Is there a reason why the RHS of LSHIFT is primary_stmt_expr, but the
> RHS of RSHIFT is primary_rhs_expr?

It's likely a leftover. The rhs rule was introduced to reduce chances
of hitting shift/reduce conflicts, and to restrict syntax on the rhs.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-03-09  9:25 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-08 10:40 shift_stmt_expr grammar question Jeremy Sowden
2020-03-09  9:25 ` Pablo Neira Ayuso

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).