inline std::basic_ostream<YYChar>&
operator<< (std::basic_ostream<YYChar>& ostr, const location& loc)
{
- position last = loc.end - 1;
- ostr << loc.begin;
- if (last.filename
+ unsigned int end_col = 0 < loc.end.column ? loc.end.column - 1 : 0;
+ ostr << loc.begin// << "(" << loc.end << ") "
+;
+ if (loc.end.filename
&& (!loc.begin.filename
- || *loc.begin.filename != *last.filename))
- ostr << '-' << last;
- else if (loc.begin.line != last.line)
- ostr << '-' << last.line << '.' << last.column;
- else if (loc.begin.column != last.column)
- ostr << '-' << last.column;
+ || *loc.begin.filename != *loc.end.filename))
+ ostr << '-' << loc.end.filename << ':' << loc.end.line << '.' << end_col;
+ else if (loc.begin.line < loc.end.line)
+ ostr << '-' << loc.end.line << '.' << end_col;
+ else if (loc.begin.column < end_col)
+ ostr << '-' << end_col;
return ostr;
}
]])
int
main (void)
{
+ ]AT_YYLTYPE[ loc;
+]AT_GLR_CC_IF([loc.initialize();])[
#define TEST(L1, C1, L2, C2) \
- ]AT_LOC_FIRST_LINE[ = L1; \
- ]AT_LOC_FIRST_COLUMN[ = C1; \
- ]AT_LOC_LAST_LINE[ = L2; \
- ]AT_LOC_LAST_COLUMN[ = C2; \
- ]YY_LOCATION_PRINT(stdout, AT_LOC)[;\
+ loc.]AT_FIRST_LINE[ = L1; \
+ loc.]AT_FIRST_COLUMN[ = C1; \
+ loc.]AT_LAST_LINE[ = L2; \
+ loc.]AT_LAST_COLUMN[ = C2; \
+ ]AT_SKEL_CC_IF([std::cout << loc],
+ [YY_LOCATION_PRINT(stdout, loc)])[;\
putchar ('\n');
TEST(1, 1, 1, 1);
## FIXME: test Java, and iterate over skeletons.
AT_TEST([yacc.c])
AT_TEST([glr.c])
-#AT_TEST([lalr1.cc])
-#AT_TEST([glr.cc])
+AT_TEST([lalr1.cc])
+AT_TEST([glr.cc])
m4_popdef([AT_TEST])
# AT_LOC_PUSHDEF(FIRST-LINE, FIRST-COLUMN, LAST-LINE, LAST-COLUMN)
# ----------------------------------------------------------------
-# Pushdef AT_LOC_(FIRST|LAST)_(LINE|COLUMN).
+# Pushdef AT(_LOC)?_(FIRST|LAST)_(LINE|COLUMN).
m4_define([AT_LOC_PUSHDEF],
-[m4_pushdef([AT_LOC_FIRST_LINE], [AT_LOC.$1])
-m4_pushdef([AT_LOC_FIRST_COLUMN], [AT_LOC.$2])
-m4_pushdef([AT_LOC_LAST_LINE], [AT_LOC.$3])
-m4_pushdef([AT_LOC_LAST_COLUMN], [AT_LOC.$4])])
+[m4_pushdef([AT_FIRST_LINE], [$1])
+m4_pushdef([AT_FIRST_COLUMN], [$2])
+m4_pushdef([AT_LAST_LINE], [$3])
+m4_pushdef([AT_LAST_COLUMN], [$4])
+m4_pushdef([AT_LOC_FIRST_LINE], [AT_LOC.AT_FIRST_LINE])
+m4_pushdef([AT_LOC_FIRST_COLUMN], [AT_LOC.AT_FIRST_COLUMN])
+m4_pushdef([AT_LOC_LAST_LINE], [AT_LOC.AT_LAST_LINE])
+m4_pushdef([AT_LOC_LAST_COLUMN], [AT_LOC.AT_LAST_COLUMN])])
# AT_LOC_POPDEF
# -------------
-# Popdef AT_LOC_(FIRST|LAST)_(LINE|COL).
+# Popdef AT(_LOC)?_(FIRST|LAST)_(LINE|COLUMN).
m4_define([AT_LOC_POPDEF],
[m4_popdef([AT_LOC_FIRST_LINE])
m4_popdef([AT_LOC_FIRST_COLUMN])
m4_popdef([AT_LOC_LAST_LINE])
-m4_popdef([AT_LOC_LAST_COLUMN])])
+m4_popdef([AT_LOC_LAST_COLUMN])
+m4_popdef([AT_FIRST_LINE])
+m4_popdef([AT_FIRST_COLUMN])
+m4_popdef([AT_LAST_LINE])
+m4_popdef([AT_LAST_COLUMN])
+])