140 |
b4_syncline([@oline@], [@ofile@])[ |
b4_syncline([@oline@], [@ofile@])[ |
141 |
#ifndef YYLLOC_DEFAULT |
#ifndef YYLLOC_DEFAULT |
142 |
# define YYLLOC_DEFAULT(Current, Rhs, N) \ |
# define YYLLOC_DEFAULT(Current, Rhs, N) \ |
143 |
Current.last = Rhs[N].last; |
Current.end = Rhs[N].end; |
144 |
#endif |
#endif |
145 |
|
|
146 |
namespace yy |
namespace yy |
525 |
/* Return failure if at end of input. */ |
/* Return failure if at end of input. */ |
526 |
if (looka_ == eof_) |
if (looka_ == eof_) |
527 |
goto yyabortlab; |
goto yyabortlab; |
528 |
|
#if YYDEBUG |
529 |
YYCDEBUG << "Discarding token " << looka_ |
YYCDEBUG << "Discarding token " << looka_ |
530 |
<< " (" << name_[ilooka_] << ")." << std::endl; |
<< " (" << name_[ilooka_] << ")." << std::endl; |
531 |
|
#endif |
532 |
looka_ = empty_; |
looka_ = empty_; |
533 |
} |
} |
534 |
|
|
770 |
]b4_epilogue |
]b4_epilogue |
771 |
dnl |
dnl |
772 |
@output stack.hh |
@output stack.hh |
773 |
b4_copyright([2002, 2003])[ |
b4_copyright([Stack handling for Bison C++ parsers], [2002, 2003])[ |
774 |
|
|
775 |
#ifndef BISON_STACK_HH |
#ifndef BISON_STACK_HH |
776 |
# define BISON_STACK_HH |
# define BISON_STACK_HH |
867 |
#endif // not BISON_STACK_HH] |
#endif // not BISON_STACK_HH] |
868 |
dnl |
dnl |
869 |
@output location.hh |
@output location.hh |
870 |
b4_copyright([2002, 2003])[ |
b4_copyright([Location class for Bison C++ parsers], [2002, 2003])[ |
871 |
|
|
872 |
#ifndef BISON_LOCATION_HH |
#ifndef BISON_LOCATION_HH |
873 |
# define BISON_LOCATION_HH |
# define BISON_LOCATION_HH |
874 |
|
|
875 |
|
# include <iostream> |
876 |
|
# include <string> |
877 |
|
|
878 |
namespace yy |
namespace yy |
879 |
{ |
{ |
880 |
struct Position |
class Position |
881 |
{ |
{ |
882 |
|
public: |
883 |
|
Position () |
884 |
|
: filename (), line (1), column (0) |
885 |
|
{} |
886 |
|
|
887 |
|
std::string filename; |
888 |
int line; |
int line; |
889 |
int column; |
int column; |
890 |
}; |
}; |
891 |
|
|
892 |
struct Location |
inline std::ostream& |
893 |
|
operator<< (std::ostream& ostr, const Position& pos) |
894 |
|
{ |
895 |
|
if (pos.filename != "") |
896 |
|
ostr << pos.filename << ':'; |
897 |
|
ostr << pos.line << '.' << pos.column; |
898 |
|
return ostr; |
899 |
|
} |
900 |
|
|
901 |
|
inline Position |
902 |
|
operator- (const Position& pos, int col) |
903 |
{ |
{ |
904 |
Position first; |
Position res (pos); |
905 |
Position last; |
res.column -= col; |
906 |
|
return res; |
907 |
|
} |
908 |
|
|
909 |
|
|
910 |
|
class Location |
911 |
|
{ |
912 |
|
public: |
913 |
|
Position begin; |
914 |
|
Position end; |
915 |
}; |
}; |
916 |
|
|
917 |
|
/* Don't issue twice the line number when the location is on a single |
918 |
|
line. */ |
919 |
|
|
920 |
|
inline std::ostream& |
921 |
|
operator<< (std::ostream& ostr, const Location& pos) |
922 |
|
{ |
923 |
|
ostr << pos.begin; |
924 |
|
if (pos.begin.filename != pos.end.filename) |
925 |
|
ostr << '-' << pos.end - 1; |
926 |
|
else if (pos.begin.line != pos.end.line) |
927 |
|
ostr << '-' << pos.end.line << '.' << pos.end.column - 1; |
928 |
|
else if (pos.begin.column != pos.end.column - 1) |
929 |
|
ostr << '-' << pos.end.column - 1; |
930 |
|
return ostr; |
931 |
|
} |
932 |
|
|
933 |
} |
} |
934 |
|
|
935 |
#endif // not BISON_LOCATION_HH] |
#endif // not BISON_LOCATION_HH] |