Talk:Compiler/syntax analyzer: Difference between revisions

From Rosetta Code
Content added Content deleted
mNo edit summary
No edit summary
Line 29: Line 29:
because | is lower precedence than concatenation.
because | is lower precedence than concatenation.


Yep, I agree. It has been corrected. Thanks for the catch! ----[[User:Ed Davis|Ed Davis]] ([[User talk:Ed Davis|talk]]) 18:19, 22 April 2019 (UTC)
Yep, I agree. It has been corrected. Thanks for the catch! --[[User:Ed Davis|Ed Davis]] ([[User talk:Ed Davis|talk]]) 18:19, 22 April 2019 (UTC)

Revision as of 18:20, 22 April 2019

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)

You are correct. Thanks for catching this! I have modified the grammar. --Ed Davis (talk) 11:03, 23 October 2016 (UTC)

prt_list production incorrect

I think the prt_list production should be:

prt_list            =   (String | expr) { ',' (String | expr) } ;

because | is lower precedence than concatenation.

Yep, I agree. It has been corrected. Thanks for the catch! --Ed Davis (talk) 18:19, 22 April 2019 (UTC)