简体   繁体   English

这个函数调用参数是否在BNF语法中定义?

[英]Is this like function call arguments are defined in the BNF grammar?

Reading this C's BNF grammar I didn't understand which part this: 这个 C的BNF语法我不明白这个部分:

| postfix_exp '(' argument_exp_list ')'
| postfix_exp '('           ')'

does handle also a function call like id(exp, exp) and id() . 还会处理像id(exp, exp)id()这样的函数调用。 Is this the single combination valid in C syntax or I'm missing something? 这是C语法中有效的单一组合还是我遗漏了什么? if so, why not just: 如果是这样,为什么不呢:

| id '(' argument_exp_list ')'
| id '('            ')' 

The BNF grammar id '(' argument_exp_list ')' is actually equivalent to postfix_exp '(' argument_exp_list ')' where postfix_exp can be a primary_exp as stated on its l-value. BNF语法id '(' argument_exp_list ')'实际上等同于postfix_exp '(' argument_exp_list ')' ,其中postfix_exp可以是其l值所述的primary_exp

postfix_exp     : primary_exp
                | postfix_exp '[' exp ']'
                | postfix_exp '(' argument_exp_list ')'
                | postfix_exp '('           ')'
                | postfix_exp '.' id
                | postfix_exp '->' id
                | postfix_exp '++'
                | postfix_exp '--'

where primary_exp is: 其中primary_exp是:

primary_exp     : id
                | const
                | string
                | '(' exp ')'

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM