fineamy 发表于 2008-06-21 10:34

bison中属性结构问题

number: BASED_NUMBER
             { $$ = $1; based_size = 0;}
      | DEC_NUMBER
             { $$ = $1; based_size = 0;}
      | DEC_NUMBER BASED_NUMBER
             { $$ = pform_verinum_with_size($1,$2, @2.text, @2.first_line);
             based_size = 0; }
请问一下,上面@2.text 代表什么,
@2.first_line在手册中可以查到,好象代表BASED_NUMBER的所在行号吧?但还不是很明白,能否解释下?

fineamy 发表于 2008-06-21 10:43

不好意思,刚看到,赶紧贴上来

/* Recent version of bison expect that the user supply a
   YYLLOC_DEFAULT macro that makes up a yylloc value from existing
   values. I need to supply an explicit version to account for the
   text field, that otherwise won't be copied. */
# define YYLLOC_DEFAULT(Current, Rhs, N)do {       \
(Current).first_line   = (Rhs).first_line;      \
(Current).first_column = (Rhs).first_column;    \
(Current).last_line    = (Rhs).last_line;       \
(Current).last_column= (Rhs).last_column;   \
(Current).text         = (Rhs).text;   } while (0)

这里作者已经做了解释

cjaizss 发表于 2008-06-21 17:24

bison的扩展,可以更方便的调试之类。
我没用过

很快乐 发表于 2008-06-24 20:23

学习了,这个我不会呢1
页: [1]
查看完整版本: bison中属性结构问题