Commit bd6e6bac authored by Frank B. Brokken's avatar Frank B. Brokken

New upstream version 6.00.00

parent b76c15c4
......@@ -23,7 +23,7 @@
#define CXX "g++"
// the compiler options to use.
#define CXXFLAGS "--std=c++14 -Wall -O2 -fdiagnostics-color=never"
#define CXXFLAGS "-Wall -O2 -fdiagnostics-color=never"
#define LDFLAGS ""
// flags passed to the linker
......
#define VERSION "5.03.00"
#define VERSION "6.00.00"
#define YEARS "2005-2017"
bisonc++
\ No newline at end of file
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -15,7 +15,6 @@ int g_echo = ON;
#include "icmake/run"
#include "icmake/md"
#include "icmake/special"
#include "icmake/precompileheaders"
#include "icmake/pathfile"
#include "icmake/findall"
......@@ -36,8 +35,9 @@ int g_echo = ON;
void main(int argc, list argv)
{
string option;
string strip;
string psType; // program or strip
int idx;
int precomp = 1;
for (idx = listlen(argv); idx--; )
{
......@@ -48,7 +48,7 @@ void main(int argc, list argv)
}
else if (argv[idx] == "-P")
{
g_gch = 0;
precomp = 0;
argv -= (list)"-P";
}
else if (strfind(argv[idx], "LOG:") == 0)
......@@ -87,27 +87,38 @@ void main(int argc, list argv)
if (option == "manual")
manual();
if (precomp)
exec(P_NOCHECK,
"sed -i 's,^//#define PRECOMP,#define PRECOMP,' icmconf");
else
{
exec(P_NOCHECK,
"sed -i 's,^#define PRECOMP,//#define PRECOMP,' icmconf");
exec(P_NOCHECK, "rm -f *.ih.gch */*.ih.gch");
}
if (option == "library")
{
precompileHeaders();
system("icmbuild library");
exit(0);
}
if (argv[2] == "strip")
strip = "strip";
if (argv[2] == "strip")
psType = "strip";
else
psType = "program";
if (option == "program")
{
precompileHeaders();
system("icmbuild program " + strip);
system("icmbuild " + psType);
exit(0);
}
if (option == "oxref")
{
precompileHeaders();
system("icmbuild program " + strip);
system("icmbuild " + psType);
run("oxref -fxs tmp/main.o tmp/lib" LIBRARY ".a > " PROGRAM ".xref");
exit(0);
}
......@@ -117,48 +128,48 @@ void main(int argc, list argv)
chdir("scanner");
system("flexc++ -i scanner.ih lexer");
chdir("..");
system("icmbuild program " + strip);
system("icmbuild " + psType);
exit(0);
}
printf("Usage: build [-q] what\n"
"Where\n"
" [-q]: run quietly, do not show executed commands\n"
"`what' is one of:\n"
" clean - clean up remnants of previous "
"compilations\n"
" distclean - clean + fully remove tmp/\n"
" library - build " PROGRAM "'s library\n"
" man - build the man-page (requires Yodl)\n"
" manual - build the manual (requires Yodl)\n"
" program [strip] - build " PROGRAM " (optionally strip the\n"
" executable)\n"
" oxref [strip] - same a `program', also builds xref file\n"
" using oxref\n"
" scanner [strip] - build new scanner, then 'build program'\n"
" install [LOG:path] selection [base] -\n"
" to install the software in the locations "
"defined \n"
" in the INSTALL.im file, optionally below "
"base.\n"
" LOG:path is optional: if specified `path' "
"is the\n"
" logfile on which the installation log is "
"written.\n"
" selection can be\n"
" x, to install all components,\n"
" or a combination of:\n"
" a (additional documentation),\n"
" b (binary program),\n"
" d (standard documentation),\n"
" m (man-pages)\n"
" s (skeleton files)\n"
" u (user guide)\n"
" uninstall logfile - remove files and empty directories listed\n"
" in the file 'logfile'\n"
" github - prepare github's gh-pages update\n"
" (internal use only)\n"
"\n"
printf("Usage: build [-q -P] what\n"
"Where\n"
" -q: run quietly, do not show executed commands\n"
" -P: do not use precompiled headers\n"
"`what' is one of:\n"
" clean - clean up remnants of previous compilations\n"
" distclean - clean + fully remove tmp/\n"
" library - build " PROGRAM "'s library\n"
" man - build the man-page (requires Yodl)\n"
" manual - build the manual (requires Yodl)\n"
" program [strip] - build " PROGRAM " (optionally strip the "
"executable)\n"
" oxref [strip] - same a `program', also builds xref file using "
"oxref\n"
" scanner [strip] - build new scanner, then 'build program'\n"
" install [LOG:path] selection [base] -\n"
" to install the software in the locations "
"defined \n"
" in the INSTALL.im file, optionally below "
"base.\n"
" LOG:path is optional: if specified `path' "
"is the\n"
" logfile on which the installation log is "
"written.\n"
" selection can be\n"
" x, to install all components,\n"
" or a combination of:\n"
" a (additional documentation),\n"
" b (binary program),\n"
" d (standard documentation),\n"
" m (man-pages)\n"
" s (skeleton files)\n"
" u (user guide)\n"
" uninstall logfile - remove files and empty directories listed\n"
" in the file 'logfile'\n"
" github - prepare github's gh-pages update\n"
" (internal use only)\n"
"\n"
);
exit(0);
}
bisonc++ (6.00.00)
* The generated code was rewritten. The protected interface of ParserBase
and names of parse()-related members in Parser was modified. The names of
all accessible members in parserbase.h and parser.h now have two trailing
underscore characters.
Predefined members in parser.ih no longer have trailing underscores, and
can be redefined.
The traditional error(char const *) member in fact never uses its argument
(and bisonc++ only passed the default "Syntax error" argument). Its
prototype now no longer defines a parameter. Here's an overview of
modified member names/signatures:
--------------------------------------------------------
Before 6.00.00 Starting with 6.00.00
--------------------------------------------------------
void error(char const *); void error();
void exceptionHandler__(... void exceptionHandler(...
void errorRecovery(); void errorRecovery__();
void executeAction(int); void executeAction__(int);
void nextToken(); void nextToken__();
--------------------------------------------------------
added:
---------------------------
void nextCycle__();
---------------------------
removed:
---------------------------
int lookup(bool);
---------------------------
When re-generating parsers generated by bisonc++ before version 6.00.00,
the signatures of the above functions in the file parser.h must be
hand-modified to reflect the above changes. In addition, the
implementations of error and exceptionHandler (default implementations
were provided in parser.ih) must be adapted to their new signatures.
* Added a warning to skeleton/binsonc++.h that until the #undef instruction
Parser will be read as ParserBase.
* With Polymorphic semantic values a tag mismatch is no considered fatal
anymore if errors were already encountered. In that case the semantic
value showing a tag mismatch is replaced by the default value of the
semantic value of the expected polymorphic type.
* Compilation of bisonc++ now starts with the construction of precompiled
headers, significantly reducing the compilation time.
* The state stack elements now consist of two values: the first
element holds the state index, the second element the semantic value.
* Added option and directive 'prompt': the generated parser shows a ?-prompt
at each cycle when processing its input (which should not be provided on
the standard input stream).
* `thread-safe' can now also be specified as a directive. Previously it
could only be specified as option.
* Documentation was updated to reflect the above modifications
* The build script now properly recognizes the 'strip' option
* By default precompiled headers are used. The option -P (cf. log entry
'bisonc++ (4.12.03)' below) is now opertational.
Be advised that using -P removes all existing .ih.gch files from the
directory containing 'main.ih' and from all its immediate subdirectories.
* Removed the compiler option --std=c++14, since that's by now the default.
-- Frank B. Brokken <f.b.brokken@rug.nl> Thu, 18 May 2017 09:46:19 +0200
bisonc++ (5.03.00)
* Added a declaration like 'Parser() = default' to the generated parser
class header file.
* Added an item about exsiting constructors and how to add additional
* Added an item about existing constructors and how to add additional
constructors to parser classes generated by bisonc++
* Corrected 'see also' references in the man-pages.
......@@ -1117,7 +1191,7 @@ bisonc++ (1.6.0)
%prec specification or as the priority of their first terminal token.
* The accepting State no longer has default reductions. It doesn't need them
since _EOF_ in those states terminates the parser. Accepting States
since EOF__ in those states terminates the parser. Accepting States
now have search sentinels, allowing the parser to do proper error
recovery.
......
DELETEMACRO(file)
NOUSERMACRO( setDebug lex yylex matched YYText file)
NOUSERMACRO( setDebug lex yylex matched YYText file exceptionHandler lookup
error)
includefile(../../release.yo)
......@@ -60,7 +61,7 @@ the tt(yyparse) function as generated by the GNU-bf(bison) parser generator.
a program offering a more modern user-interface, removing all old-style
(bf(C)) tt(%define) directives from bf(bison++)'s input specification file
(see below for an in-depth discussion of the differences between bf(bison++)
and bic()). Starting with version 0.98, bic() represents a complete rebuilt of
and bic()). Starting with version 0.98, bic() is a complete rebuilt of
the parser generator, closely following descriptions given in Aho, Sethi and
Ullman's em(Dragon Book). Since version 0.98 bic() is a Cpp() program, rather
than a bf(C) program generating bf(C++) code.
......@@ -88,16 +89,18 @@ member functions.
of one man-page is of course that you never have to look for which manual page
contains which information. But on the other hand, bic()'s man-page grew into
a huge man-page of about 2000 lines in which it was hard to find your
way. From release 5.00.00 onward, three man-pages. The following index relates
manual pages to their specific contents:
way. From release 5.00.00 onward, three man-pages. The index below relates
manual pages to their specific contents.
bf(This man-page)
bf(Overview of the contents of bisonc++'s man-pages)
This man-page concentrates on the tt(bisonc++) program itself, offering
the following sections:
itemization(
it() bf(DESCRIPTION): a short description of bic() and its roots;
it() bf(FROM BISONC++ < 6.00.00 TO BISONC++ >= 6.00.00): required
modifications when re-generating parsers;
it() bf(OPTIONS): options supported by bic().
it() bf(QUICK START): a quick start overview about how to use bic();
it() bf(GENERATED FILES): files generated by bic() and their purposes
......@@ -149,6 +152,52 @@ grammar-specification file. This man-page offers these sections:
it() bf(AUTHOR): at the end of this man-page.
)
manpagesection(FROM BISONC++ < 6.00.00 TO BISONC++ >= 6.00.00)
This section is only relevant when re-generating parser code previously
generated by bic() versions before 6.00.00.
Bic() version 6.00.00 generates code that significantly differs from code
generated by earlier versions. The identifiers of all members (both data and
functions) that are generated by bic() and accessible to the generated
parser-class end in two underscore characters. Member functions whose
identifiers end in two underscores are `owned' by bic(), are rewritten each
time bic() is run, and should not be modified. Some members are defined as
members of the generated parser-class, and are declared in the parser class
header file (e.g., tt(parser.h)) and some members are given default
implementations in the parser's internal header file (e.g.,
tt(parser.ih)). Once generated, these files are left alone by
bic(). Therefore, when using bic() version 6.00.00 or beyond to re-generate a
parser which was originally generated by an earlier bic() version, the
existing parser header and internal header files need some minor
modifications:
itemization(
itt(void error(char const *)) was changed to tt(void error()). A
default implementation is provided in the parser's internal header file. The
current implementation directly inserts the text tt(Syntax error) into the
standard output stream;
itt(void exceptionHandler__(std::exception const &exc)) was changed to
tt(void exceptionHandler(std::exception const &exc)). A
default implementation is provided in the parser's internal header file, and
only its trailing underscore characters need to be removed;
itt(int lookup(bool recovery)): remove this member declaration from the
previously generated parser class;
it() The following members are declared without two trailing underscore
characters in the generated parser class. Two underscore characters should
be added to their identifiers: tt(executeAction, errorRecovery, nextToken).
it() The member tt(void nextCycle__()) must be declared in the private
section of the generated parser class.
)
Previously, several data members of the parser's base class were directly
accessible to the parser class. Bic() version 6.00.00 restricts access to
those members. They can still be read, but no longer modified by the parser
class. This applies to the following members:
itemization(
itt(d_token__): use tt(int token__()) instead;
itt(d_state__): use tt(size_t state__()) instead;
)
manpagesection(OPTIONS)
includefile(../manual/invoking/options.yo)
......@@ -159,12 +208,12 @@ manpagesection(QUICK START)
it() First, define a grammar. The reader is referred to bic()'s manual and
other sources (like Aho, Sethi and Ullman's book) for details about how to
define and decorate grammars.
it() No `macro style' tt(%define) declarations are required
anymore. Instead, the normal practice of defining class members in source
files and declaring them in class header files can be followed when using
bic(). Bic() concentrates on its main tasks: defining a parser class and
implementing the parsing function tt(int parse), leaving all other parts of
the parser class' definition to the programmer.
it() No `macro style' tt(%define) declarations are required. Instead, the
normal practice of defining class members in source files and declaring them
in class header files can be followed when using bic(). Bic() concentrates on
its main tasks: defining a parser class and implementing the parsing function
tt(int parse), leaving all other parts of the parser class' definition to the
programmer.
it() Having defined a grammar and (usually) some directives bic() is
run, generating the essential elements of a parser class. See the next section
for details about the files generated by bic().
......@@ -264,8 +313,6 @@ manpagesection(FILES)
tt(LTYPE__).
it() bf(print.in): skeleton implementing the actions of tt(Parser::print)
if the tt(print-tokens) option or directive was specified.
it() bf(threading.in): skeleton defining the variables required for
generating a thread-safe parsing function.
)
manpagesection(SEE ALSO)
......@@ -275,34 +322,19 @@ manpagesection(SEE ALSO)
manpagesection(BUGS)
Parser-class header files (e.g., Parser.h) and parser-class internal
header files (e.g., Parser.ih) generated with bisonc++ < 4.02.00 require
two hand-modifications when used in combination with bisonc++ >=
4.02.00. See the description of tt(exceptionHandler__) for details.
Discontinued options:
itemization(
it() loption(include-only)
it() loption(namespace)
it() loption(polymorphic-inline-skeleton)
)
header files (e.g., Parser.ih) generated with bisonc++ < 6.00.00 require
several minor hand-modifications when re-generating the parser with bic()
>= 6.00.00. See the earlier section bf(FROM BISONC++ < 6.00.00 TO BISONC++
>= 6.00.00) for details.
To avoid collisions with names defined by the parser's (base) class, the
following identifiers should not be used as token names:
itemization(
it() Identifiers ending in two underscores;
it() Any of the following identifiers: tt(ABORT, ACCEPT, ERROR, clearin,
it() Any of the following identifiers: tt(ABORT, ACCEPT, ERROR,
debug, error), or tt(setDebug).
)
When re-using files generated by bic() before version 2.0.0, minor
hand-modification may be necessary. Refer to bic()'s git
(https://github.com/fbb-git/bisoncpp) for details.
The em(Semantic) parser, mentioned in bf(bison++)(1) is not implemented in
bf(bisonc++)(1). According to bf(bison++)(1) the semantic parser was not
available in bf(bison++) either. Maybe a so-called em(pure) parser is
available through the tt(--thread-safe) option.
manpagesection(ABOUT bisonc++)
bf(Bisonc++) was based on bf(bison++), originally developed by Alain
......
DELETEMACRO(file)
NOUSERMACRO(LALR setDebug ParserBase ABORT throw ACCEPT debug error lex print
parse setLoc api file)
parse setLoc api file exceptionHandler)
includefile(../../release.yo)
......@@ -77,6 +77,16 @@ the following sections:
it() bf(AUTHOR): at the end of this man-page.
)
All identifiers ending in two underscore characters are reserved for
bic(). Member functions ending in two underscore characters must not be
redefined. Data members ending in two underscore characters are available in
the generated parser class, and may be modified by user-defined members of the
parser class. Some members like (tt(error, exceptionHandler, lex)) are defined
in the parser class and must remain present, but their implementations may be
altered by the user. Members for which no default implementation is provided
in the parser's internal header file (e.g., tt(Parser.ih)) may not be
redefined or masked by user-provided code.
manpagesection(PUBLIC SYMBOLS)
includefile(../manual/class/public.yo)
......@@ -92,8 +102,8 @@ manpagesection(PRIVATE MEMBER FUNCTIONS)
manpagesection(PRIVATE DATA MEMBERS)
The following data members can be used by members of parser classes
generated by bic(). All data members are actually protected
members inherited from the parser's base class.
generated by bic(). All data members are actually protected members inherited
from the parser's base class.
itemization(
it() bf(size_t d_acceptedTokens__):nl()
Counts the number of accepted tokens since the start of the tt(parse())
......@@ -127,28 +137,19 @@ members inherited from the parser's base class.
Subsequently, the lexical scanner may assign a value to the parser's
tt(d_loc__) variable through the pointer to tt(d_loc__) stored inside
the lexical scanner.
it() bf(LTYPE__ d_lsp__):nl()
The location stack pointer.
Do not modify.
it() bf(size_t d_nErrors__):nl()
The number of errors counted by tt(parse). It is initialized by the
parser's base class initializer, and is updated while tt(parse)
executes. When tt(parse) has returned it contains the total number
of errors counted by tt(parse). Errors are not counted if suppressed
(i.e., if tt(d_acceptedTokens__) is less than tt(d_requiredTokens__)).
it() bf(size_t d_nextToken__):nl()
A pending token.
Do not modify.
it() bf(size_t d_requiredTokens__):nl()
Defines the minimum number of accepted tokens that the tt(parse)
function must have processed before a syntactic error can be
generated.
it() bf(int d_state__):nl()
The current parsing state.
Do not modify.
it() bf(int d_token__):nl()
The current token.
Do not modify.
it() bf(STYPE__ d_val__):nl()
The semantic value of a returned token or nonterminal symbol. With
nonterminal tokens it is assigned a value through the action rule's
......@@ -173,12 +174,37 @@ members inherited from the parser's base class.
If tt(STYPE) is a polymorphic semantic value, specific requirements for
assigning values to tt(d_val__) apply.
IFDEF(MANUAL)((cf. section ref(POLYTYPE)))().
)
it() bf(LTYPE__ d_vsp__):nl()
The semantic value stack pointer.
Do not modify.
manpagesection(BUGS)
With bic() version 6.00.00 the following members were modified. Where
necessary alternatives are mentioned:
itemization(
it() bf(bool Base::debug() const): use the tt(d_debug__) data member;
it() bf(void error(char const *)): replaced by bf(void error+nop()());
it() bf(void exceptionHandler__(std::exception const &exc)): omit final
underscores: bf(void exceptionHandler(std::exception const
&exc))
it() bf(void executeAction+nop()(int)): add two underscores to the
declaration in the parser class interface: bf(void
executeAction__+nop()(int))
it() bf(int lookup+nop()(bool)): omit this member from the parser class
interface.
it() bf(void nextCycle__+nop()(int)): add this member declaration to the
parser class interface.
it() bf(void nextToken+nop()(int)): add two underscores to the declaration
in the parser class interface: bf(void nextToken__+nop()(int))
it() bf(size_t d_nextToken__): removed from the interface.
it() bf(int d_state__): use tt(state__()).
it() bf(int d_token__): use tt(token__()).
it() bf(LTYPE__ d_vsp__): removed from the interface. Use tt(vsp__+nop()())
instead.
)
manpagesection(TYPES AND VARIABLES IN THE ANONYMOUS NAMESPACE)
includefile(../manual/class/anonymous.yo)
......
......@@ -402,6 +402,16 @@ production rule's priority. A well known application of tt(%prec) is:
and the text matched by the lexical scanner as received by the
generated tt(parse) function.
it() bf(%prompt)
When adding debugging code (using the tt(debug) option or
directive) the debug information is displayed continuously while
the parser processes its input. When using the tt(prompt)
directive the generated parser displays a prompt (a question
mark) at each step of the parsing process. Caveat: when using this
option the parser's input cannot be provided at the parser's
standard input stream.
it() bf(%required-tokens) tt(number)
Following a syntactic error, require at least tt(number)
......@@ -533,6 +543,13 @@ grammar's action block the error was encountered.
called. This directive is overruled by the tt(--target-directory)
command-line option.
it() bf(%thread-safe)
Only used with polymorphic semantic values, and then only required
when the parser is used in multiple threads: it ensures that each
thread's polymorphic code only accesses its own parser's error
counting variable.
it() bf(%token) tt(terminal ...)
Defines the names of symbolic terminal tokens. Sequences of
......
......@@ -19,7 +19,7 @@ class Parser: public ParserBase
int parse();
private:
void error(char const *msg); // called on (syntax) errors
void error(); // called on (syntax) errors
int lex(); // returns the next token from the
// lexical scanner.
void print(); // use, e.g., d_token, d_loc
......@@ -27,12 +27,12 @@ class Parser: public ParserBase
void done();
// support functions for parse():
void executeAction(int ruleNr);
void errorRecovery();
int lookup(bool recovery);
void nextToken();
void executeAction__(int ruleNr);
void errorRecovery__();
void nextCycle__();
void nextToken__();
void print__();
void exceptionHandler__(std::exception const &exc);
void exceptionHandler(std::exception const &exc);
};
inline void Parser::prompt()
......
......@@ -6,9 +6,9 @@
#include "parser.h"
inline void Parser::error(char const *msg)
inline void Parser::error()
{
std::cerr << msg << '\n';
std::cerr << "Syntax error\n";
}
// $insert lex
......@@ -22,7 +22,7 @@ inline void Parser::print()
print__(); // displays tokens if --print was specified
}
inline void Parser::exceptionHandler__(std::exception const &exc)
inline void Parser::exceptionHandler(std::exception const &exc)
{
throw; // re-implement to handle exceptions thrown by actions
}
......
// Generated by Bisonc++ V5.00.00 on Wed, 13 Apr 2016 10:19:24 +0530
// Generated by Bisonc++ V6.00.00 on Sun, 14 May 2017 16:12:45 +0200
// hdr/includes
#ifndef ParserBase_h_included
#define ParserBase_h_included
......@@ -7,6 +8,7 @@
#include <vector>
#include <iostream>
// hdr/baseclass
namespace // anonymous
{
......@@ -39,9 +41,14 @@ class ParserBase
typedef int STYPE__;
private:
int d_stackIdx__ = -1;
std::vector<size_t> d_stateStack__;
std::vector<STYPE__> d_valueStack__;
// state semval
typedef std::pair<size_t, STYPE__> StatePair;
// token semval
typedef std::pair<int, STYPE__> TokenPair;
int d_stackIdx = -1;
std::vector<StatePair> d_stateStack;
protected:
enum Return__
......@@ -54,70 +61,98 @@ typedef int STYPE__;
DEFAULT_RECOVERY_MODE__,
UNEXPECTED_TOKEN__,
};
bool d_actionCases__ = false;
bool d_actionCases__ = false; // set by options/directives
bool d_debug__ = true;
size_t d_nErrors__ = 0;
size_t d_requiredTokens__;
size_t d_nErrors__; // initialized by clearin()
size_t d_acceptedTokens__;
int d_token__;
int d_nextToken__;
size_t d_state__;
STYPE__ *d_vsp__;
StatePair *d_vsp__; // points to the topmost value stack
STYPE__ d_val__;
STYPE__ d_nextVal__;
TokenPair d_next__;
bool d_terminalToken__;
bool d_recovery__;
ParserBase();
void ABORT() const;
void ACCEPT() const;
void ERROR() const;
void clearin();
bool actionCases() const;
bool debug() const;
void clearin__();
int lookup__() const;
void pop__(size_t count = 1);
void push__(size_t nextState);
void popToken__();
void pushToken__(int token);
void reduce__(PI__ const &productionInfo);
void redoToken__();
void reduce__(int rule);
void shift__(int state);
void errorVerbose__();
size_t top__() const;
STYPE__ &vs__(int idx); // value stack element idx
public:
void setDebug(bool mode);
void setDebug(DebugMode__ mode);
};
inline ParserBase::DebugMode__ operator|(ParserBase::DebugMode__ lhs,
ParserBase::DebugMode__ rhs)
// hdr/abort
inline void ParserBase::ABORT() const