【发布时间】:2013-04-16 18:22:20
【问题描述】:
为了处理语法规则:
type : ARRAY '[' integer_constant RANGE integer_constant ']' OF stype { $$ = $8 }
| stype { $$ = $1 }
;
我需要传递类型属性(就像我现在所做的那样),但我还需要传递数组的范围以检查数组边界。 我已经尝试了各种使用结构的方法来实现类似的目标:
type : ARRAY '[' integer_constant RANGE integer_constant ']' OF stype { $$.type = $8; $$.range[0] = $3; $$.range[1] = $5; }
| stype { $$.type = $1 }
;
但一切都会导致错误和段错误,我很难找到正确的方法来处理这个问题
谁能指出我正确的方向? 提前致谢。
parse.y:http://pastebin.com/XUUqG35s
【问题讨论】:
标签: parsing attributes bison yacc