+2002-03-04 Robert Anisko <robert@lrde.epita.fr>
+
+ * data/bison.c++: Unmerge value as yylval and value as yyval. Unmerge
+ location as yylloc and location as yyloc. Use YYLLOC_DEFAULT, and
+ provide a default implementation.
+
2002-03-04 Akim Demaille <akim@epita.fr>
* tests/input.at (Invalid $n, Invalid @n): Add the ending `;'.
# define YYSTYPE yystype
#endif
+#ifndef YYLLOC_DEFAULT
+# define YYLLOC_DEFAULT(Current, Rhs, N) \
+ Current.last_line = Rhs[[N]].last_line; \
+ Current.last_column = Rhs[[N]].last_column;
+#endif
+
m4_if(b4_locations_flag, [0], [],
[#ifndef YYLTYPE
typedef struct yyltype
/* Message. */
std::string message;
- /* @$ and $$. */
+ /* Semantic value and location of lookahead token. */
SemanticType value;
LocationType location;
+ /* @$ and $$. */
+ SemanticType yyval;
+ LocationType yyloc;
+
/* Initial location. */
LocationType initlocation_;
};
len_ = r2_[[n_]];
if (len_)
{
- value = semantic_stack_[[1 - len_]];
- location = location_stack_[[1 - len_]];
+ yyval = semantic_stack_[[1 - len_]];
+ yyloc = location_stack_[[1 - len_]];
}
else
{
- value = semantic_stack_[[0]];
- location = location_stack_[[0]];
+ yyval = semantic_stack_[[0]];
+ yyloc = location_stack_[[0]];
}
#if YYDEBUG
}
#endif
+ if (len_)
+ {
+ Slice< LocationType, LocationStack > slice (location_stack_, len_);
+ YYLLOC_DEFAULT (yyloc, slice, len_);
+ }
+
+ std::cout << "Reduced location is :" << yyloc << std::endl;
+
{
- SemanticType& yyval (value);
- LocationType& yyloc (location);
SemanticStack& yyvsp (semantic_stack_);
LocationStack& yylsp (location_stack_);
}
#endif
- semantic_stack_.push (value);
- location_stack_.push (location);
+ semantic_stack_.push (yyval);
+ location_stack_.push (yyloc);
/* Shift the result of the reduction. */
n_ = r1_[[n_]];
T&
operator [[]] (int index)
{
- return seq_[[seq_.size () - 1 + index]];
+ return seq_[[height () - 1 + index]];
}
inline
const T&
operator [[]] (int index) const
{
- return seq_[[seq_.size () - 1 + index]];
+ return seq_[[height () - 1 + index]];
}
inline
S seq_;
};
+
+ template < class T, class S = Stack< T > >
+ class Slice
+ {
+ public:
+
+ Slice (const S& stack,
+ unsigned range) : stack_ (stack),
+ range_ (range)
+ {
+ }
+
+ inline
+ const T&
+ operator [[]] (unsigned index) const
+ {
+ return stack_[[index - range_]];
+ }
+
+ private:
+
+ const S& stack_;
+ unsigned range_;
+ };
}
#endif // not BISON_STACK_HH