首页 > 代码库 > C语法归约之数组和指针(1)
C语法归约之数组和指针(1)
上一篇,开始了语法归约,给出变量声明定义初始化归约过程,和c99文法图,请查阅这里,相关文法图在这里依然要使用
1、数组归约
1.1、示例代码
int a[10]; int a[2][3]; int a[2][3][4]; struct AA boy[100]; struct AA boy[100][100]; union BB girl[10];
1.2、归约过程
curr: int next: a type-specifier declaration-specifiers curr: ID next: [ declaration-specifiers direct-declarator curr: [ next: 10 curr: 10 next: ] declaration-specifiers direct-declarator [ primary-expression declaration-specifiers direct-declarator [ postfix-expression declaration-specifiers direct-declarator [ unary-expression declaration-specifiers direct-declarator [ cast-expression declaration-specifiers direct-declarator [ multiplicative-expression declaration-specifiers direct-declarator [ additive-expression declaration-specifiers direct-declarator [ shift-expression declaration-specifiers direct-declarator [ relational-expression declaration-specifiers direct-declarator [ equality-expression declaration-specifiers direct-declarator [ AND-expression declaration-specifiers direct-declarator [ exclusive-OR-expression declaration-specifiers direct-declarator [ inclusive-OR-expression declaration-specifiers direct-declarator [ logical-AND-expression declaration-specifiers direct-declarator [ logical-OR-expression declaration-specifiers direct-declarator [ conditional-expression declaration-specifiers direct-declarator [ assignment-expression curr: ] next: ; declaration-specifiers direct-declarator declaration-specifiers declarator declaration-specifiers init-declarator declaration-specifiers init-declarator-list curr: ; next: int declaration declaration-list curr: int next: a declaration-list type-specifier declaration-list declaration-specifiers curr: ID next: [ declaration-list declaration-specifiers direct-declarator curr: [ next: 2 curr: 2 next: ] declaration-list declaration-specifiers direct-declarator [ primary-expression declaration-list declaration-specifiers direct-declarator [ postfix-expression declaration-list declaration-specifiers direct-declarator [ unary-expression declaration-list declaration-specifiers direct-declarator [ cast-expression declaration-list declaration-specifiers direct-declarator [ multiplicative-expression declaration-list declaration-specifiers direct-declarator [ additive-expression declaration-list declaration-specifiers direct-declarator [ shift-expression declaration-list declaration-specifiers direct-declarator [ relational-expression declaration-list declaration-specifiers direct-declarator [ equality-expression declaration-list declaration-specifiers direct-declarator [ AND-expression declaration-list declaration-specifiers direct-declarator [ exclusive-OR-expression declaration-list declaration-specifiers direct-declarator [ inclusive-OR-expression declaration-list declaration-specifiers direct-declarator [ logical-AND-expression declaration-list declaration-specifiers direct-declarator [ logical-OR-expression declaration-list declaration-specifiers direct-declarator [ conditional-expression declaration-list declaration-specifiers direct-declarator [ assignment-expression curr: ] next: [ declaration-list declaration-specifiers direct-declarator curr: [ next: 3 curr: 3 next: ] declaration-list declaration-specifiers direct-declarator [ primary-expression declaration-list declaration-specifiers direct-declarator [ postfix-expression declaration-list declaration-specifiers direct-declarator [ unary-expression declaration-list declaration-specifiers direct-declarator [ cast-expression declaration-list declaration-specifiers direct-declarator [ multiplicative-expression declaration-list declaration-specifiers direct-declarator [ additive-expression declaration-list declaration-specifiers direct-declarator [ shift-expression declaration-list declaration-specifiers direct-declarator [ relational-expression declaration-list declaration-specifiers direct-declarator [ equality-expression declaration-list declaration-specifiers direct-declarator [ AND-expression declaration-list declaration-specifiers direct-declarator [ exclusive-OR-expression declaration-list declaration-specifiers direct-declarator [ inclusive-OR-expression declaration-list declaration-specifiers direct-declarator [ logical-AND-expression declaration-list declaration-specifiers direct-declarator [ logical-OR-expression declaration-list declaration-specifiers direct-declarator [ conditional-expression declaration-list declaration-specifiers direct-declarator [ assignment-expression curr: ] next: ; declaration-list declaration-specifiers direct-declarator declaration-list declaration-specifiers declarator declaration-list declaration-specifiers init-declarator declaration-list declaration-specifiers init-declarator-list curr: ; next: int declaration-list declaration declaration-list curr: int next: a declaration-list type-specifier declaration-list declaration-specifiers curr: ID next: [ declaration-list declaration-specifiers direct-declarator curr: [ next: 2 curr: 2 next: ] declaration-list declaration-specifiers direct-declarator [ primary-expression declaration-list declaration-specifiers direct-declarator [ postfix-expression declaration-list declaration-specifiers direct-declarator [ unary-expression declaration-list declaration-specifiers direct-declarator [ cast-expression declaration-list declaration-specifiers direct-declarator [ multiplicative-expression declaration-list declaration-specifiers direct-declarator [ additive-expression declaration-list declaration-specifiers direct-declarator [ shift-expression declaration-list declaration-specifiers direct-declarator [ relational-expression declaration-list declaration-specifiers direct-declarator [ equality-expression declaration-list declaration-specifiers direct-declarator [ AND-expression declaration-list declaration-specifiers direct-declarator [ exclusive-OR-expression declaration-list declaration-specifiers direct-declarator [ inclusive-OR-expression declaration-list declaration-specifiers direct-declarator [ logical-AND-expression declaration-list declaration-specifiers direct-declarator [ logical-OR-expression declaration-list declaration-specifiers direct-declarator [ conditional-expression declaration-list declaration-specifiers direct-declarator [ assignment-expression curr: ] next: [ declaration-list declaration-specifiers direct-declarator curr: [ next: 3 curr: 3 next: ] declaration-list declaration-specifiers direct-declarator [ primary-expression declaration-list declaration-specifiers direct-declarator [ postfix-expression declaration-list declaration-specifiers direct-declarator [ unary-expression declaration-list declaration-specifiers direct-declarator [ cast-expression declaration-list declaration-specifiers direct-declarator [ multiplicative-expression declaration-list declaration-specifiers direct-declarator [ additive-expression declaration-list declaration-specifiers direct-declarator [ shift-expression declaration-list declaration-specifiers direct-declarator [ relational-expression declaration-list declaration-specifiers direct-declarator [ equality-expression declaration-list declaration-specifiers direct-declarator [ AND-expression declaration-list declaration-specifiers direct-declarator [ exclusive-OR-expression declaration-list declaration-specifiers direct-declarator [ inclusive-OR-expression declaration-list declaration-specifiers direct-declarator [ logical-AND-expression declaration-list declaration-specifiers direct-declarator [ logical-OR-expression declaration-list declaration-specifiers direct-declarator [ conditional-expression declaration-list declaration-specifiers direct-declarator [ assignment-expression curr: ] next: [ declaration-list declaration-specifiers direct-declarator curr: [ next: 4 curr: 4 next: ] declaration-list declaration-specifiers direct-declarator [ primary-expression declaration-list declaration-specifiers direct-declarator [ postfix-expression declaration-list declaration-specifiers direct-declarator [ unary-expression declaration-list declaration-specifiers direct-declarator [ cast-expression declaration-list declaration-specifiers direct-declarator [ multiplicative-expression declaration-list declaration-specifiers direct-declarator [ additive-expression declaration-list declaration-specifiers direct-declarator [ shift-expression declaration-list declaration-specifiers direct-declarator [ relational-expression declaration-list declaration-specifiers direct-declarator [ equality-expression declaration-list declaration-specifiers direct-declarator [ AND-expression declaration-list declaration-specifiers direct-declarator [ exclusive-OR-expression declaration-list declaration-specifiers direct-declarator [ inclusive-OR-expression declaration-list declaration-specifiers direct-declarator [ logical-AND-expression declaration-list declaration-specifiers direct-declarator [ logical-OR-expression declaration-list declaration-specifiers direct-declarator [ conditional-expression declaration-list declaration-specifiers direct-declarator [ assignment-expression curr: ] next: ; declaration-list declaration-specifiers direct-declarator declaration-list declaration-specifiers declarator declaration-list declaration-specifiers init-declarator declaration-list declaration-specifiers init-declarator-list curr: ; next: struct declaration-list declaration declaration-list curr: struct next: AA curr: boy next: ID declaration-list struct-specifier declaration-list type-specifier declaration-list declaration-specifiers curr: ID next: [ declaration-list declaration-specifiers direct-declarator curr: [ next: 100 curr: 100 next: ] declaration-list declaration-specifiers direct-declarator [ primary-expression declaration-list declaration-specifiers direct-declarator [ postfix-expression declaration-list declaration-specifiers direct-declarator [ unary-expression declaration-list declaration-specifiers direct-declarator [ cast-expression declaration-list declaration-specifiers direct-declarator [ multiplicative-expression declaration-list declaration-specifiers direct-declarator [ additive-expression declaration-list declaration-specifiers direct-declarator [ shift-expression declaration-list declaration-specifiers direct-declarator [ relational-expression declaration-list declaration-specifiers direct-declarator [ equality-expression declaration-list declaration-specifiers direct-declarator [ AND-expression declaration-list declaration-specifiers direct-declarator [ exclusive-OR-expression declaration-list declaration-specifiers direct-declarator [ inclusive-OR-expression declaration-list declaration-specifiers direct-declarator [ logical-AND-expression declaration-list declaration-specifiers direct-declarator [ logical-OR-expression declaration-list declaration-specifiers direct-declarator [ conditional-expression declaration-list declaration-specifiers direct-declarator [ assignment-expression curr: ] next: ; declaration-list declaration-specifiers direct-declarator declaration-list declaration-specifiers declarator declaration-list declaration-specifiers init-declarator declaration-list declaration-specifiers init-declarator-list curr: ; next: struct declaration-list declaration declaration-list curr: struct next: AA curr: boy next: ID declaration-list struct-specifier declaration-list type-specifier declaration-list declaration-specifiers curr: ID next: [ declaration-list declaration-specifiers direct-declarator curr: [ next: 100 curr: 100 next: ] declaration-list declaration-specifiers direct-declarator [ primary-expression declaration-list declaration-specifiers direct-declarator [ postfix-expression declaration-list declaration-specifiers direct-declarator [ unary-expression declaration-list declaration-specifiers direct-declarator [ cast-expression declaration-list declaration-specifiers direct-declarator [ multiplicative-expression declaration-list declaration-specifiers direct-declarator [ additive-expression declaration-list declaration-specifiers direct-declarator [ shift-expression declaration-list declaration-specifiers direct-declarator [ relational-expression declaration-list declaration-specifiers direct-declarator [ equality-expression declaration-list declaration-specifiers direct-declarator [ AND-expression declaration-list declaration-specifiers direct-declarator [ exclusive-OR-expression declaration-list declaration-specifiers direct-declarator [ inclusive-OR-expression declaration-list declaration-specifiers direct-declarator [ logical-AND-expression declaration-list declaration-specifiers direct-declarator [ logical-OR-expression declaration-list declaration-specifiers direct-declarator [ conditional-expression declaration-list declaration-specifiers direct-declarator [ assignment-expression curr: ] next: [ declaration-list declaration-specifiers direct-declarator curr: [ next: 100 curr: 100 next: ] declaration-list declaration-specifiers direct-declarator [ primary-expression declaration-list declaration-specifiers direct-declarator [ postfix-expression declaration-list declaration-specifiers direct-declarator [ unary-expression declaration-list declaration-specifiers direct-declarator [ cast-expression declaration-list declaration-specifiers direct-declarator [ multiplicative-expression declaration-list declaration-specifiers direct-declarator [ additive-expression declaration-list declaration-specifiers direct-declarator [ shift-expression declaration-list declaration-specifiers direct-declarator [ relational-expression declaration-list declaration-specifiers direct-declarator [ equality-expression declaration-list declaration-specifiers direct-declarator [ AND-expression declaration-list declaration-specifiers direct-declarator [ exclusive-OR-expression declaration-list declaration-specifiers direct-declarator [ inclusive-OR-expression declaration-list declaration-specifiers direct-declarator [ logical-AND-expression declaration-list declaration-specifiers direct-declarator [ logical-OR-expression declaration-list declaration-specifiers direct-declarator [ conditional-expression declaration-list declaration-specifiers direct-declarator [ assignment-expression curr: ] next: ; declaration-list declaration-specifiers direct-declarator declaration-list declaration-specifiers declarator declaration-list declaration-specifiers init-declarator declaration-list declaration-specifiers init-declarator-list curr: ; next: union declaration-list declaration declaration-list curr: union next: BB curr: girl next: ID declaration-list union-specifier declaration-list type-specifier declaration-list declaration-specifiers curr: ID next: [ declaration-list declaration-specifiers direct-declarator curr: [ next: 10 curr: 10 next: ] declaration-list declaration-specifiers direct-declarator [ primary-expression declaration-list declaration-specifiers direct-declarator [ postfix-expression declaration-list declaration-specifiers direct-declarator [ unary-expression declaration-list declaration-specifiers direct-declarator [ cast-expression declaration-list declaration-specifiers direct-declarator [ multiplicative-expression declaration-list declaration-specifiers direct-declarator [ additive-expression declaration-list declaration-specifiers direct-declarator [ shift-expression declaration-list declaration-specifiers direct-declarator [ relational-expression declaration-list declaration-specifiers direct-declarator [ equality-expression declaration-list declaration-specifiers direct-declarator [ AND-expression declaration-list declaration-specifiers direct-declarator [ exclusive-OR-expression declaration-list declaration-specifiers direct-declarator [ inclusive-OR-expression declaration-list declaration-specifiers direct-declarator [ logical-AND-expression declaration-list declaration-specifiers direct-declarator [ logical-OR-expression declaration-list declaration-specifiers direct-declarator [ conditional-expression declaration-list declaration-specifiers direct-declarator [ assignment-expression curr: ] next: ; declaration-list declaration-specifiers direct-declarator declaration-list declaration-specifiers declarator declaration-list declaration-specifiers init-declarator declaration-list declaration-specifiers init-declarator-list curr: ; next: NULL declaration-list declaration declaration-list translation-unit
1.3、总结说明
无论数组是多少维度,每个维度的归约过程都是一样一样的!没有区别。由于(expression),id, string, 常量会归约到primary-expression。因此,从文法上讲,数组的定义中可以出现表达式和变量。但是后期编译要为数组分配空间,而变量需要计算才能知道大小,因此是不能在数组定义时候使用变量的!
2、指针归约
2.1、示例代码
static int *ip; signed char *str; char **str; void *vp; int *a; int ****a; struct AA *boy; struct AA **boy; struct AA ****boy; union BB *girl; union BB **girl;
2.2、归约过程
curr: static next: int storage-class-specifier curr: int next: * storage-class-specifier type-specifier storage-class-specifier declaration-specifiers declaration-specifiers curr: * next: ip declaration-specifiers pointer curr: ID next: ; declaration-specifiers pointer direct-declarator declaration-specifiers declarator declaration-specifiers init-declarator declaration-specifiers init-declarator-list curr: ; next: signed declaration declaration-list curr: signed next: char declaration-list type-specifier curr: char next: * declaration-list type-specifier type-specifier declaration-list type-specifier declaration-specifiers declaration-list declaration-specifiers curr: * next: str declaration-list declaration-specifiers pointer curr: ID next: ; declaration-list declaration-specifiers pointer direct-declarator declaration-list declaration-specifiers declarator declaration-list declaration-specifiers init-declarator declaration-list declaration-specifiers init-declarator-list curr: ; next: char declaration-list declaration declaration-list curr: char next: * declaration-list type-specifier declaration-list declaration-specifiers curr: * next: * curr: * next: str declaration-list declaration-specifiers * pointer declaration-list declaration-specifiers pointer curr: ID next: ; declaration-list declaration-specifiers pointer direct-declarator declaration-list declaration-specifiers declarator declaration-list declaration-specifiers init-declarator declaration-list declaration-specifiers init-declarator-list curr: ; next: void declaration-list declaration declaration-list curr: void next: * declaration-list type-specifier declaration-list declaration-specifiers curr: * next: vp declaration-list declaration-specifiers pointer curr: ID next: ; declaration-list declaration-specifiers pointer direct-declarator declaration-list declaration-specifiers declarator declaration-list declaration-specifiers init-declarator declaration-list declaration-specifiers init-declarator-list curr: ; next: int declaration-list declaration declaration-list curr: int next: * declaration-list type-specifier declaration-list declaration-specifiers curr: * next: a declaration-list declaration-specifiers pointer curr: ID next: ; declaration-list declaration-specifiers pointer direct-declarator declaration-list declaration-specifiers declarator declaration-list declaration-specifiers init-declarator declaration-list declaration-specifiers init-declarator-list curr: ; next: int declaration-list declaration declaration-list curr: int next: * declaration-list type-specifier declaration-list declaration-specifiers curr: * next: * curr: * next: * curr: * next: * curr: * next: a declaration-list declaration-specifiers * * * pointer declaration-list declaration-specifiers * * pointer declaration-list declaration-specifiers * pointer declaration-list declaration-specifiers pointer curr: ID next: ; declaration-list declaration-specifiers pointer direct-declarator declaration-list declaration-specifiers declarator declaration-list declaration-specifiers init-declarator declaration-list declaration-specifiers init-declarator-list curr: ; next: struct declaration-list declaration declaration-list curr: struct next: AA curr: ID next: * declaration-list struct-specifier declaration-list type-specifier declaration-list declaration-specifiers curr: * next: boy declaration-list declaration-specifiers pointer curr: ID next: ; declaration-list declaration-specifiers pointer direct-declarator declaration-list declaration-specifiers declarator declaration-list declaration-specifiers init-declarator declaration-list declaration-specifiers init-declarator-list curr: ; next: struct declaration-list declaration declaration-list curr: struct next: AA curr: ID next: * declaration-list struct-specifier declaration-list type-specifier declaration-list declaration-specifiers curr: * next: * curr: * next: boy declaration-list declaration-specifiers * pointer declaration-list declaration-specifiers pointer curr: ID next: ; declaration-list declaration-specifiers pointer direct-declarator declaration-list declaration-specifiers declarator declaration-list declaration-specifiers init-declarator declaration-list declaration-specifiers init-declarator-list curr: ; next: struct declaration-list declaration declaration-list curr: struct next: AA curr: ID next: * declaration-list struct-specifier declaration-list type-specifier declaration-list declaration-specifiers curr: * next: * curr: * next: * curr: * next: * curr: * next: boy declaration-list declaration-specifiers * * * pointer declaration-list declaration-specifiers * * pointer declaration-list declaration-specifiers * pointer declaration-list declaration-specifiers pointer curr: ID next: ; declaration-list declaration-specifiers pointer direct-declarator declaration-list declaration-specifiers declarator declaration-list declaration-specifiers init-declarator declaration-list declaration-specifiers init-declarator-list curr: ; next: union declaration-list declaration declaration-list curr: union next: BB curr: ID next: * declaration-list union-specifier declaration-list type-specifier declaration-list declaration-specifiers curr: * next: girl declaration-list declaration-specifiers pointer curr: ID next: ; declaration-list declaration-specifiers pointer direct-declarator declaration-list declaration-specifiers declarator declaration-list declaration-specifiers init-declarator declaration-list declaration-specifiers init-declarator-list curr: ; next: union declaration-list declaration declaration-list curr: union next: BB curr: ID next: * declaration-list union-specifier declaration-list type-specifier declaration-list declaration-specifiers curr: * next: * curr: * next: girl declaration-list declaration-specifiers * pointer declaration-list declaration-specifiers pointer curr: ID next: ; declaration-list declaration-specifiers pointer direct-declarator declaration-list declaration-specifiers declarator declaration-list declaration-specifiers init-declarator declaration-list declaration-specifiers init-declarator-list curr: ; next: NULL declaration-list declaration declaration-list translation-unit
2.3、总结说明
指针定义前面挂多少个星都无妨,只要你愿意挂千万,文法照样解析。只是使用产生式poiner->*pointer迭代次数多点而已!
3、指针和数组的一起归约
3.1、示例代码
int *a[11]; int (**a)[5]; int (*a)[5][4]; int *a[11][22]; char **a[2]; char ***a[2]; struct AA *boy[11]; struct AA **boy[11][22]; struct AA (*boy)[11]; struct AA (**boy)[11]; union BB *girl[10][22]; union BB **girl[10];
3.2、归约过程
curr: int next: * type-specifier declaration-specifiers curr: * next: a declaration-specifiers pointer curr: ID next: [ declaration-specifiers pointer direct-declarator curr: [ next: 11 curr: 11 next: ] declaration-specifiers pointer direct-declarator [ primary-expression declaration-specifiers pointer direct-declarator [ postfix-expression declaration-specifiers pointer direct-declarator [ unary-expression declaration-specifiers pointer direct-declarator [ cast-expression declaration-specifiers pointer direct-declarator [ multiplicative-expression declaration-specifiers pointer direct-declarator [ additive-expression declaration-specifiers pointer direct-declarator [ shift-expression declaration-specifiers pointer direct-declarator [ relational-expression declaration-specifiers pointer direct-declarator [ equality-expression declaration-specifiers pointer direct-declarator [ AND-expression declaration-specifiers pointer direct-declarator [ exclusive-OR-expression declaration-specifiers pointer direct-declarator [ inclusive-OR-expression declaration-specifiers pointer direct-declarator [ logical-AND-expression declaration-specifiers pointer direct-declarator [ logical-OR-expression declaration-specifiers pointer direct-declarator [ conditional-expression declaration-specifiers pointer direct-declarator [ assignment-expression curr: ] next: ; declaration-specifiers pointer direct-declarator declaration-specifiers declarator declaration-specifiers init-declarator declaration-specifiers init-declarator-list curr: ; next: int declaration declaration-list curr: int next: ( declaration-list type-specifier declaration-list declaration-specifiers curr: ( next: * curr: * next: * curr: * next: a declaration-list declaration-specifiers ( * pointer declaration-list declaration-specifiers ( pointer curr: ID next: ) declaration-list declaration-specifiers ( pointer direct-declarator declaration-list declaration-specifiers ( declarator curr: ) next: [ declaration-list declaration-specifiers direct-declarator curr: [ next: 5 curr: 5 next: ] declaration-list declaration-specifiers direct-declarator [ primary-expression declaration-list declaration-specifiers direct-declarator [ postfix-expression declaration-list declaration-specifiers direct-declarator [ unary-expression declaration-list declaration-specifiers direct-declarator [ cast-expression declaration-list declaration-specifiers direct-declarator [ multiplicative-expression declaration-list declaration-specifiers direct-declarator [ additive-expression declaration-list declaration-specifiers direct-declarator [ shift-expression declaration-list declaration-specifiers direct-declarator [ relational-expression declaration-list declaration-specifiers direct-declarator [ equality-expression declaration-list declaration-specifiers direct-declarator [ AND-expression declaration-list declaration-specifiers direct-declarator [ exclusive-OR-expression declaration-list declaration-specifiers direct-declarator [ inclusive-OR-expression declaration-list declaration-specifiers direct-declarator [ logical-AND-expression declaration-list declaration-specifiers direct-declarator [ logical-OR-expression declaration-list declaration-specifiers direct-declarator [ conditional-expression declaration-list declaration-specifiers direct-declarator [ assignment-expression curr: ] next: ; declaration-list declaration-specifiers direct-declarator declaration-list declaration-specifiers declarator declaration-list declaration-specifiers init-declarator declaration-list declaration-specifiers init-declarator-list curr: ; next: int declaration-list declaration declaration-list curr: int next: ( declaration-list type-specifier declaration-list declaration-specifiers curr: ( next: * curr: * next: a declaration-list declaration-specifiers ( pointer curr: ID next: ) declaration-list declaration-specifiers ( pointer direct-declarator declaration-list declaration-specifiers ( declarator curr: ) next: [ declaration-list declaration-specifiers direct-declarator curr: [ next: 5 curr: 5 next: ] declaration-list declaration-specifiers direct-declarator [ primary-expression declaration-list declaration-specifiers direct-declarator [ postfix-expression declaration-list declaration-specifiers direct-declarator [ unary-expression declaration-list declaration-specifiers direct-declarator [ cast-expression declaration-list declaration-specifiers direct-declarator [ multiplicative-expression declaration-list declaration-specifiers direct-declarator [ additive-expression declaration-list declaration-specifiers direct-declarator [ shift-expression declaration-list declaration-specifiers direct-declarator [ relational-expression declaration-list declaration-specifiers direct-declarator [ equality-expression declaration-list declaration-specifiers direct-declarator [ AND-expression declaration-list declaration-specifiers direct-declarator [ exclusive-OR-expression declaration-list declaration-specifiers direct-declarator [ inclusive-OR-expression declaration-list declaration-specifiers direct-declarator [ logical-AND-expression declaration-list declaration-specifiers direct-declarator [ logical-OR-expression declaration-list declaration-specifiers direct-declarator [ conditional-expression declaration-list declaration-specifiers direct-declarator [ assignment-expression curr: ] next: [ declaration-list declaration-specifiers direct-declarator curr: [ next: 4 curr: 4 next: ] declaration-list declaration-specifiers direct-declarator [ primary-expression declaration-list declaration-specifiers direct-declarator [ postfix-expression declaration-list declaration-specifiers direct-declarator [ unary-expression declaration-list declaration-specifiers direct-declarator [ cast-expression declaration-list declaration-specifiers direct-declarator [ multiplicative-expression declaration-list declaration-specifiers direct-declarator [ additive-expression declaration-list declaration-specifiers direct-declarator [ shift-expression declaration-list declaration-specifiers direct-declarator [ relational-expression declaration-list declaration-specifiers direct-declarator [ equality-expression declaration-list declaration-specifiers direct-declarator [ AND-expression declaration-list declaration-specifiers direct-declarator [ exclusive-OR-expression declaration-list declaration-specifiers direct-declarator [ inclusive-OR-expression declaration-list declaration-specifiers direct-declarator [ logical-AND-expression declaration-list declaration-specifiers direct-declarator [ logical-OR-expression declaration-list declaration-specifiers direct-declarator [ conditional-expression declaration-list declaration-specifiers direct-declarator [ assignment-expression curr: ] next: ; declaration-list declaration-specifiers direct-declarator declaration-list declaration-specifiers declarator declaration-list declaration-specifiers init-declarator declaration-list declaration-specifiers init-declarator-list curr: ; next: int declaration-list declaration declaration-list curr: int next: * declaration-list type-specifier declaration-list declaration-specifiers curr: * next: a declaration-list declaration-specifiers pointer curr: ID next: [ declaration-list declaration-specifiers pointer direct-declarator curr: [ next: 11 curr: 11 next: ] declaration-list declaration-specifiers pointer direct-declarator [ primary-expression declaration-list declaration-specifiers pointer direct-declarator [ postfix-expression declaration-list declaration-specifiers pointer direct-declarator [ unary-expression declaration-list declaration-specifiers pointer direct-declarator [ cast-expression declaration-list declaration-specifiers pointer direct-declarator [ multiplicative-expression declaration-list declaration-specifiers pointer direct-declarator [ additive-expression declaration-list declaration-specifiers pointer direct-declarator [ shift-expression declaration-list declaration-specifiers pointer direct-declarator [ relational-expression declaration-list declaration-specifiers pointer direct-declarator [ equality-expression declaration-list declaration-specifiers pointer direct-declarator [ AND-expression declaration-list declaration-specifiers pointer direct-declarator [ exclusive-OR-expression declaration-list declaration-specifiers pointer direct-declarator [ inclusive-OR-expression declaration-list declaration-specifiers pointer direct-declarator [ logical-AND-expression declaration-list declaration-specifiers pointer direct-declarator [ logical-OR-expression declaration-list declaration-specifiers pointer direct-declarator [ conditional-expression declaration-list declaration-specifiers pointer direct-declarator [ assignment-expression curr: ] next: [ declaration-list declaration-specifiers pointer direct-declarator curr: [ next: 22 curr: 22 next: ] declaration-list declaration-specifiers pointer direct-declarator [ primary-expression declaration-list declaration-specifiers pointer direct-declarator [ postfix-expression declaration-list declaration-specifiers pointer direct-declarator [ unary-expression declaration-list declaration-specifiers pointer direct-declarator [ cast-expression declaration-list declaration-specifiers pointer direct-declarator [ multiplicative-expression declaration-list declaration-specifiers pointer direct-declarator [ additive-expression declaration-list declaration-specifiers pointer direct-declarator [ shift-expression declaration-list declaration-specifiers pointer direct-declarator [ relational-expression declaration-list declaration-specifiers pointer direct-declarator [ equality-expression declaration-list declaration-specifiers pointer direct-declarator [ AND-expression declaration-list declaration-specifiers pointer direct-declarator [ exclusive-OR-expression declaration-list declaration-specifiers pointer direct-declarator [ inclusive-OR-expression declaration-list declaration-specifiers pointer direct-declarator [ logical-AND-expression declaration-list declaration-specifiers pointer direct-declarator [ logical-OR-expression declaration-list declaration-specifiers pointer direct-declarator [ conditional-expression declaration-list declaration-specifiers pointer direct-declarator [ assignment-expression curr: ] next: ; declaration-list declaration-specifiers pointer direct-declarator declaration-list declaration-specifiers declarator declaration-list declaration-specifiers init-declarator declaration-list declaration-specifiers init-declarator-list curr: ; next: char declaration-list declaration declaration-list curr: char next: * declaration-list type-specifier declaration-list declaration-specifiers curr: * next: * curr: * next: a declaration-list declaration-specifiers * pointer declaration-list declaration-specifiers pointer curr: ID next: [ declaration-list declaration-specifiers pointer direct-declarator curr: [ next: 2 curr: 2 next: ] declaration-list declaration-specifiers pointer direct-declarator [ primary-expression declaration-list declaration-specifiers pointer direct-declarator [ postfix-expression declaration-list declaration-specifiers pointer direct-declarator [ unary-expression declaration-list declaration-specifiers pointer direct-declarator [ cast-expression declaration-list declaration-specifiers pointer direct-declarator [ multiplicative-expression declaration-list declaration-specifiers pointer direct-declarator [ additive-expression declaration-list declaration-specifiers pointer direct-declarator [ shift-expression declaration-list declaration-specifiers pointer direct-declarator [ relational-expression declaration-list declaration-specifiers pointer direct-declarator [ equality-expression declaration-list declaration-specifiers pointer direct-declarator [ AND-expression declaration-list declaration-specifiers pointer direct-declarator [ exclusive-OR-expression declaration-list declaration-specifiers pointer direct-declarator [ inclusive-OR-expression declaration-list declaration-specifiers pointer direct-declarator [ logical-AND-expression declaration-list declaration-specifiers pointer direct-declarator [ logical-OR-expression declaration-list declaration-specifiers pointer direct-declarator [ conditional-expression declaration-list declaration-specifiers pointer direct-declarator [ assignment-expression curr: ] next: ; declaration-list declaration-specifiers pointer direct-declarator declaration-list declaration-specifiers declarator declaration-list declaration-specifiers init-declarator declaration-list declaration-specifiers init-declarator-list curr: ; next: char declaration-list declaration declaration-list curr: char next: * declaration-list type-specifier declaration-list declaration-specifiers curr: * next: * curr: * next: * curr: * next: a declaration-list declaration-specifiers * * pointer declaration-list declaration-specifiers * pointer declaration-list declaration-specifiers pointer curr: ID next: [ declaration-list declaration-specifiers pointer direct-declarator curr: [ next: 2 curr: 2 next: ] declaration-list declaration-specifiers pointer direct-declarator [ primary-expression declaration-list declaration-specifiers pointer direct-declarator [ postfix-expression declaration-list declaration-specifiers pointer direct-declarator [ unary-expression declaration-list declaration-specifiers pointer direct-declarator [ cast-expression declaration-list declaration-specifiers pointer direct-declarator [ multiplicative-expression declaration-list declaration-specifiers pointer direct-declarator [ additive-expression declaration-list declaration-specifiers pointer direct-declarator [ shift-expression declaration-list declaration-specifiers pointer direct-declarator [ relational-expression declaration-list declaration-specifiers pointer direct-declarator [ equality-expression declaration-list declaration-specifiers pointer direct-declarator [ AND-expression declaration-list declaration-specifiers pointer direct-declarator [ exclusive-OR-expression declaration-list declaration-specifiers pointer direct-declarator [ inclusive-OR-expression declaration-list declaration-specifiers pointer direct-declarator [ logical-AND-expression declaration-list declaration-specifiers pointer direct-declarator [ logical-OR-expression declaration-list declaration-specifiers pointer direct-declarator [ conditional-expression declaration-list declaration-specifiers pointer direct-declarator [ assignment-expression curr: ] next: ; declaration-list declaration-specifiers pointer direct-declarator declaration-list declaration-specifiers declarator declaration-list declaration-specifiers init-declarator declaration-list declaration-specifiers init-declarator-list curr: ; next: struct declaration-list declaration declaration-list curr: struct next: AA curr: ID next: * declaration-list struct-specifier declaration-list type-specifier declaration-list declaration-specifiers curr: * next: boy declaration-list declaration-specifiers pointer curr: ID next: [ declaration-list declaration-specifiers pointer direct-declarator curr: [ next: 11 curr: 11 next: ] declaration-list declaration-specifiers pointer direct-declarator [ primary-expression declaration-list declaration-specifiers pointer direct-declarator [ postfix-expression declaration-list declaration-specifiers pointer direct-declarator [ unary-expression declaration-list declaration-specifiers pointer direct-declarator [ cast-expression declaration-list declaration-specifiers pointer direct-declarator [ multiplicative-expression declaration-list declaration-specifiers pointer direct-declarator [ additive-expression declaration-list declaration-specifiers pointer direct-declarator [ shift-expression declaration-list declaration-specifiers pointer direct-declarator [ relational-expression declaration-list declaration-specifiers pointer direct-declarator [ equality-expression declaration-list declaration-specifiers pointer direct-declarator [ AND-expression declaration-list declaration-specifiers pointer direct-declarator [ exclusive-OR-expression declaration-list declaration-specifiers pointer direct-declarator [ inclusive-OR-expression declaration-list declaration-specifiers pointer direct-declarator [ logical-AND-expression declaration-list declaration-specifiers pointer direct-declarator [ logical-OR-expression declaration-list declaration-specifiers pointer direct-declarator [ conditional-expression declaration-list declaration-specifiers pointer direct-declarator [ assignment-expression curr: ] next: ; declaration-list declaration-specifiers pointer direct-declarator declaration-list declaration-specifiers declarator declaration-list declaration-specifiers init-declarator declaration-list declaration-specifiers init-declarator-list curr: ; next: struct declaration-list declaration declaration-list curr: struct next: AA curr: ID next: * declaration-list struct-specifier declaration-list type-specifier declaration-list declaration-specifiers curr: * next: * curr: * next: boy declaration-list declaration-specifiers * pointer declaration-list declaration-specifiers pointer curr: ID next: [ declaration-list declaration-specifiers pointer direct-declarator curr: [ next: 11 curr: 11 next: ] declaration-list declaration-specifiers pointer direct-declarator [ primary-expression declaration-list declaration-specifiers pointer direct-declarator [ postfix-expression declaration-list declaration-specifiers pointer direct-declarator [ unary-expression declaration-list declaration-specifiers pointer direct-declarator [ cast-expression declaration-list declaration-specifiers pointer direct-declarator [ multiplicative-expression declaration-list declaration-specifiers pointer direct-declarator [ additive-expression declaration-list declaration-specifiers pointer direct-declarator [ shift-expression declaration-list declaration-specifiers pointer direct-declarator [ relational-expression declaration-list declaration-specifiers pointer direct-declarator [ equality-expression declaration-list declaration-specifiers pointer direct-declarator [ AND-expression declaration-list declaration-specifiers pointer direct-declarator [ exclusive-OR-expression declaration-list declaration-specifiers pointer direct-declarator [ inclusive-OR-expression declaration-list declaration-specifiers pointer direct-declarator [ logical-AND-expression declaration-list declaration-specifiers pointer direct-declarator [ logical-OR-expression declaration-list declaration-specifiers pointer direct-declarator [ conditional-expression declaration-list declaration-specifiers pointer direct-declarator [ assignment-expression curr: ] next: [ declaration-list declaration-specifiers pointer direct-declarator curr: [ next: 22 curr: 22 next: ] declaration-list declaration-specifiers pointer direct-declarator [ primary-expression declaration-list declaration-specifiers pointer direct-declarator [ postfix-expression declaration-list declaration-specifiers pointer direct-declarator [ unary-expression declaration-list declaration-specifiers pointer direct-declarator [ cast-expression declaration-list declaration-specifiers pointer direct-declarator [ multiplicative-expression declaration-list declaration-specifiers pointer direct-declarator [ additive-expression declaration-list declaration-specifiers pointer direct-declarator [ shift-expression declaration-list declaration-specifiers pointer direct-declarator [ relational-expression declaration-list declaration-specifiers pointer direct-declarator [ equality-expression declaration-list declaration-specifiers pointer direct-declarator [ AND-expression declaration-list declaration-specifiers pointer direct-declarator [ exclusive-OR-expression declaration-list declaration-specifiers pointer direct-declarator [ inclusive-OR-expression declaration-list declaration-specifiers pointer direct-declarator [ logical-AND-expression declaration-list declaration-specifiers pointer direct-declarator [ logical-OR-expression declaration-list declaration-specifiers pointer direct-declarator [ conditional-expression declaration-list declaration-specifiers pointer direct-declarator [ assignment-expression curr: ] next: ; declaration-list declaration-specifiers pointer direct-declarator declaration-list declaration-specifiers declarator declaration-list declaration-specifiers init-declarator declaration-list declaration-specifiers init-declarator-list curr: ; next: struct declaration-list declaration declaration-list curr: struct next: AA curr: ID next: ( declaration-list struct-specifier declaration-list type-specifier declaration-list declaration-specifiers curr: ( next: * curr: * next: boy declaration-list declaration-specifiers ( pointer curr: ID next: ) declaration-list declaration-specifiers ( pointer direct-declarator declaration-list declaration-specifiers ( declarator curr: ) next: [ declaration-list declaration-specifiers direct-declarator curr: [ next: 11 curr: 11 next: ] declaration-list declaration-specifiers direct-declarator [ primary-expression declaration-list declaration-specifiers direct-declarator [ postfix-expression declaration-list declaration-specifiers direct-declarator [ unary-expression declaration-list declaration-specifiers direct-declarator [ cast-expression declaration-list declaration-specifiers direct-declarator [ multiplicative-expression declaration-list declaration-specifiers direct-declarator [ additive-expression declaration-list declaration-specifiers direct-declarator [ shift-expression declaration-list declaration-specifiers direct-declarator [ relational-expression declaration-list declaration-specifiers direct-declarator [ equality-expression declaration-list declaration-specifiers direct-declarator [ AND-expression declaration-list declaration-specifiers direct-declarator [ exclusive-OR-expression declaration-list declaration-specifiers direct-declarator [ inclusive-OR-expression declaration-list declaration-specifiers direct-declarator [ logical-AND-expression declaration-list declaration-specifiers direct-declarator [ logical-OR-expression declaration-list declaration-specifiers direct-declarator [ conditional-expression declaration-list declaration-specifiers direct-declarator [ assignment-expression curr: ] next: ; declaration-list declaration-specifiers direct-declarator declaration-list declaration-specifiers declarator declaration-list declaration-specifiers init-declarator declaration-list declaration-specifiers init-declarator-list curr: ; next: struct declaration-list declaration declaration-list curr: struct next: AA curr: ID next: ( declaration-list struct-specifier declaration-list type-specifier declaration-list declaration-specifiers curr: ( next: * curr: * next: * curr: * next: boy declaration-list declaration-specifiers ( * pointer declaration-list declaration-specifiers ( pointer curr: ID next: ) declaration-list declaration-specifiers ( pointer direct-declarator declaration-list declaration-specifiers ( declarator curr: ) next: [ declaration-list declaration-specifiers direct-declarator curr: [ next: 11 curr: 11 next: ] declaration-list declaration-specifiers direct-declarator [ primary-expression declaration-list declaration-specifiers direct-declarator [ postfix-expression declaration-list declaration-specifiers direct-declarator [ unary-expression declaration-list declaration-specifiers direct-declarator [ cast-expression declaration-list declaration-specifiers direct-declarator [ multiplicative-expression declaration-list declaration-specifiers direct-declarator [ additive-expression declaration-list declaration-specifiers direct-declarator [ shift-expression declaration-list declaration-specifiers direct-declarator [ relational-expression declaration-list declaration-specifiers direct-declarator [ equality-expression declaration-list declaration-specifiers direct-declarator [ AND-expression declaration-list declaration-specifiers direct-declarator [ exclusive-OR-expression declaration-list declaration-specifiers direct-declarator [ inclusive-OR-expression declaration-list declaration-specifiers direct-declarator [ logical-AND-expression declaration-list declaration-specifiers direct-declarator [ logical-OR-expression declaration-list declaration-specifiers direct-declarator [ conditional-expression declaration-list declaration-specifiers direct-declarator [ assignment-expression curr: ] next: ; declaration-list declaration-specifiers direct-declarator declaration-list declaration-specifiers declarator declaration-list declaration-specifiers init-declarator declaration-list declaration-specifiers init-declarator-list curr: ; next: union declaration-list declaration declaration-list curr: union next: BB curr: ID next: * declaration-list union-specifier declaration-list type-specifier declaration-list declaration-specifiers curr: * next: girl declaration-list declaration-specifiers pointer curr: ID next: [ declaration-list declaration-specifiers pointer direct-declarator curr: [ next: 10 curr: 10 next: ] declaration-list declaration-specifiers pointer direct-declarator [ primary-expression declaration-list declaration-specifiers pointer direct-declarator [ postfix-expression declaration-list declaration-specifiers pointer direct-declarator [ unary-expression declaration-list declaration-specifiers pointer direct-declarator [ cast-expression declaration-list declaration-specifiers pointer direct-declarator [ multiplicative-expression declaration-list declaration-specifiers pointer direct-declarator [ additive-expression declaration-list declaration-specifiers pointer direct-declarator [ shift-expression declaration-list declaration-specifiers pointer direct-declarator [ relational-expression declaration-list declaration-specifiers pointer direct-declarator [ equality-expression declaration-list declaration-specifiers pointer direct-declarator [ AND-expression declaration-list declaration-specifiers pointer direct-declarator [ exclusive-OR-expression declaration-list declaration-specifiers pointer direct-declarator [ inclusive-OR-expression declaration-list declaration-specifiers pointer direct-declarator [ logical-AND-expression declaration-list declaration-specifiers pointer direct-declarator [ logical-OR-expression declaration-list declaration-specifiers pointer direct-declarator [ conditional-expression declaration-list declaration-specifiers pointer direct-declarator [ assignment-expression curr: ] next: [ declaration-list declaration-specifiers pointer direct-declarator curr: [ next: 22 curr: 22 next: ] declaration-list declaration-specifiers pointer direct-declarator [ primary-expression declaration-list declaration-specifiers pointer direct-declarator [ postfix-expression declaration-list declaration-specifiers pointer direct-declarator [ unary-expression declaration-list declaration-specifiers pointer direct-declarator [ cast-expression declaration-list declaration-specifiers pointer direct-declarator [ multiplicative-expression declaration-list declaration-specifiers pointer direct-declarator [ additive-expression declaration-list declaration-specifiers pointer direct-declarator [ shift-expression declaration-list declaration-specifiers pointer direct-declarator [ relational-expression declaration-list declaration-specifiers pointer direct-declarator [ equality-expression declaration-list declaration-specifiers pointer direct-declarator [ AND-expression declaration-list declaration-specifiers pointer direct-declarator [ exclusive-OR-expression declaration-list declaration-specifiers pointer direct-declarator [ inclusive-OR-expression declaration-list declaration-specifiers pointer direct-declarator [ logical-AND-expression declaration-list declaration-specifiers pointer direct-declarator [ logical-OR-expression declaration-list declaration-specifiers pointer direct-declarator [ conditional-expression declaration-list declaration-specifiers pointer direct-declarator [ assignment-expression curr: ] next: ; declaration-list declaration-specifiers pointer direct-declarator declaration-list declaration-specifiers declarator declaration-list declaration-specifiers init-declarator declaration-list declaration-specifiers init-declarator-list curr: ; next: union declaration-list declaration declaration-list curr: union next: BB curr: ID next: * declaration-list union-specifier declaration-list type-specifier declaration-list declaration-specifiers curr: * next: * curr: * next: girl declaration-list declaration-specifiers * pointer declaration-list declaration-specifiers pointer curr: ID next: [ declaration-list declaration-specifiers pointer direct-declarator curr: [ next: 10 curr: 10 next: ] declaration-list declaration-specifiers pointer direct-declarator [ primary-expression declaration-list declaration-specifiers pointer direct-declarator [ postfix-expression declaration-list declaration-specifiers pointer direct-declarator [ unary-expression declaration-list declaration-specifiers pointer direct-declarator [ cast-expression declaration-list declaration-specifiers pointer direct-declarator [ multiplicative-expression declaration-list declaration-specifiers pointer direct-declarator [ additive-expression declaration-list declaration-specifiers pointer direct-declarator [ shift-expression declaration-list declaration-specifiers pointer direct-declarator [ relational-expression declaration-list declaration-specifiers pointer direct-declarator [ equality-expression declaration-list declaration-specifiers pointer direct-declarator [ AND-expression declaration-list declaration-specifiers pointer direct-declarator [ exclusive-OR-expression declaration-list declaration-specifiers pointer direct-declarator [ inclusive-OR-expression declaration-list declaration-specifiers pointer direct-declarator [ logical-AND-expression declaration-list declaration-specifiers pointer direct-declarator [ logical-OR-expression declaration-list declaration-specifiers pointer direct-declarator [ conditional-expression declaration-list declaration-specifiers pointer direct-declarator [ assignment-expression curr: ] next: ; declaration-list declaration-specifiers pointer direct-declarator declaration-list declaration-specifiers declarator declaration-list declaration-specifiers init-declarator declaration-list declaration-specifiers init-declarator-list curr: ; next: NULL declaration-list declaration declaration-list translation-unit
3.3、总结说明
(*a)*a 都归约到direct-declarator。它的区分在归约过程上,以及后期类型解析上!
下文:函数
C语法归约之数组和指针(1)
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。