Copyright (C) 2000-2012 |
GNU Info (bison.info)Location Default ActionDefault Action for Locations ---------------------------- Actually, actions are not the best place to compute locations. Since locations are much more general than semantic values, there is room in the output parser to redefine the default action to take for each rule. The `YYLLOC_DEFAULT' macro is called each time a rule is matched, before the associated action is run. Most of the time, this macro is general enough to suppress location dedicated code from semantic actions. The `YYLLOC_DEFAULT' macro takes three parameters. The first one is the location of the grouping (the result of the computation). The second one is an array holding locations of all right hand side elements of the rule being matched. The last one is the size of the right hand side rule. By default, it is defined this way: #define YYLLOC_DEFAULT(Current, Rhs, N) \ Current.last_line = Rhs[N].last_line; \ Current.last_column = Rhs[N].last_column; When defining `YYLLOC_DEFAULT', you should consider that: * All arguments are free of side-effects. However, only the first one (the result) should be modified by `YYLLOC_DEFAULT'. * Before `YYLLOC_DEFAULT' is executed, the output parser sets `@$' to `@1'. * For consistency with semantic actions, valid indexes for the location array range from 1 to N. automatically generated by info2www version 1.2.2.9 |