diff --git a/TODO b/TODO index 4836eb60..4e3258dc 100644 --- a/TODO +++ b/TODO @@ -1,4 +1,10 @@ * Short term +** C++ +Move to int everywhere instead of unsigned? stack_size, etc. The parser +itself uses int (for yylen for instance), yet stack is based on size_t. + +Maybe locations should also move to ints. + ** Graphviz display code thoughts The code for the --graph option is over two files: print_graph, and graphviz. This is because Bison used to also produce VCG graphs, but since diff --git a/data/lalr1.cc b/data/lalr1.cc index 467a5fde..0f470994 100644 --- a/data/lalr1.cc +++ b/data/lalr1.cc @@ -359,7 +359,7 @@ m4_define([b4_shared_declarations], /// \warning the contents of \a sym.value is stolen. void yypush_ (const char* m, state_type s, YY_MOVE_REF (symbol_type) sym); - /// Pop \a n symbols the three stacks. + /// Pop \a n symbols from the stack. void yypop_ (unsigned n = 1); /// Constants. diff --git a/data/stack.hh b/data/stack.hh index e04ca023..4f712159 100644 --- a/data/stack.hh +++ b/data/stack.hh @@ -27,7 +27,7 @@ b4_defines_if([b4_required_version_if([302], [], # --------------- m4_define([b4_stack_define], [[ /// A stack with random access from its top. - template > + template > class stack { public: @@ -46,7 +46,7 @@ m4_define([b4_stack_define], T& operator[] (size_type i) { - return seq_[seq_.size () - 1 - i]; + return seq_[size () - 1 - i]; } /// Random access. @@ -55,7 +55,7 @@ m4_define([b4_stack_define], const T& operator[] (size_type i) const { - return seq_[seq_.size () - 1 - i]; + return seq_[size () - 1 - i]; } /// Steal the contents of \a t. @@ -107,7 +107,7 @@ m4_define([b4_stack_define], }; /// Present a slice of the top of a stack. - template > + template > class slice { public: diff --git a/doc/bison.texi b/doc/bison.texi index 00c59a37..aeca17a6 100644 --- a/doc/bison.texi +++ b/doc/bison.texi @@ -11723,7 +11723,7 @@ The rules are simple. The driver is used to report errors. if (! (INT_MIN <= n && n <= INT_MAX && errno != ERANGE)) throw yy::parser::syntax_error (loc, "integer is out of range: " + std::string(yytext)); - return yy::parser::make_NUMBER (n, loc); + return yy::parser::make_NUMBER (int (n), loc); @} @end group @{id@} return yy::parser::make_IDENTIFIER (yytext, loc); diff --git a/examples/variant-11.yy b/examples/variant-11.yy index ba01c6c4..64afd3ee 100644 --- a/examples/variant-11.yy +++ b/examples/variant-11.yy @@ -124,10 +124,10 @@ namespace yy parser::symbol_type yylex () { - static auto count = 0u; - const auto stage = count; + static int count = 0; + const int stage = count; ++count; - auto loc = parser::location_type{nullptr, stage + 1, stage + 1}; + auto loc = parser::location_type{nullptr, unsigned (stage + 1), unsigned (stage + 1)}; if (stage == 0) return parser::make_TEXT (make_string_uptr ("I have numbers for you."), std::move (loc)); else if (stage < max) diff --git a/examples/variant.yy b/examples/variant.yy index 2938c50c..109eb53a 100644 --- a/examples/variant.yy +++ b/examples/variant.yy @@ -114,9 +114,10 @@ namespace yy parser::symbol_type yylex () { - static int stage = -1; - ++stage; - parser::location_type loc (nullptr, stage + 1, stage + 1); + static int count = 0; + const int stage = count; + ++count; + parser::location_type loc (nullptr, unsigned (stage + 1), unsigned (stage + 1)); switch (stage) { case 0: