Talk:Compiler/syntax analyzer: Difference between revisions

From Rosetta Code
Content added Content deleted
(Question about unary operators)
 
m ((forgot signature))
Line 18: Line 18:
which would be more usual?
which would be more usual?
If I read it correctly, the C reference implementation does treat unary operators as highest precedence.
If I read it correctly, the C reference implementation does treat unary operators as highest precedence.
--[[User:Tigerofdarkness|Tigerofdarkness]] ([[User talk:Tigerofdarkness|talk]]) 08:46, 23 October 2016 (UTC)

Revision as of 08:46, 23 October 2016

Unary operator precedence

In the grmmmar, the definition of primary is:

    primary             =   Identifier
                          | Integer
                          | '(' expr ')'
                          | ('+' | '-' | '!') expr
                          ;

which makes the unary operators the lowest precedence? Should that be:

    primary             =   Identifier
                          | Integer
                          | '(' expr ')'
                          | ('+' | '-' | '!') primary
                          ;

which would be more usual? If I read it correctly, the C reference implementation does treat unary operators as highest precedence. --Tigerofdarkness (talk) 08:46, 23 October 2016 (UTC)