Commit 56e56792 authored by Frank B. Brokken's avatar Frank B. Brokken

New upstream version 6.01.02

parent 6cfb4975
......@@ -24,7 +24,8 @@
// the compiler options to use.
#define CXXFLAGS "-Wall -O2 " \
"-fdiagnostics-color=never"
"-fdiagnostics-color=never "
// "-Wunused-parameter -Werror"
#define LDFLAGS ""
// flags passed to the linker
......
#define VERSION "6.01.00"
#define VERSION "6.01.02"
#define YEARS "2005-2018"
bisonc++
\ No newline at end of file
bisonc++ (6.00.01)
bisonc++ (6.01.02)
* Added C++-17 attributes [[maybe_notused]] to bisonc++'s code, and removed
unused parameters unless required.
-- Frank B. Brokken <f.b.brokken@rug.nl> Thu, 08 Mar 2018 20:16:50 +0100
bisonc++ (6.01.01)
* Fixed a missing destination for the link to the sources of the rpn
calculator mentioned in Ch. 6 of the user manual.
-- Frank B. Brokken <f.b.brokken@rug.nl> Tue, 23 Jan 2018 12:59:39 +0100
bisonc++ (6.01.00)
* Removed std:: in front of thread_local in generated code
* Removed definitions of the Yodl tr-macro from .yo files: it is a
predefined macro in Yodl 4.02.00, and is not used in de documentation.
-- Frank B. Brokken <f.b.brokken@rug.nl> Sat, 20 Jan 2018 11:40:25 +0100
bisonc++ (6.00.00)
......
......@@ -3,5 +3,5 @@ calculator (a calculator using postfix operators). This example provides a
good starting point, since operator precedence is not an issue. The second
example illustrates how operator precedence is handled.
All sources for this calculator are found in the lurl(examples/rpn/)
directory.
All sources for this calculator are found in the
url(examples/rpn/)(examples/rpn/index.html) directory.
<!DOCTYPE html><html><head>
<meta charset="UTF-8">
<title>Overview of rpn files</title>
<style type="text/css">
figure {text-align: center;}
img {vertical-align: center;}
.XXfc {margin-left:auto;margin-right:auto;}
.XXtc {text-align: center;}
.XXtl {text-align: left;}
.XXtr {text-align: right;}
.XXvt {vertical-align: top;}
.XXvb {vertical-align: bottom;}
</style>
<link rev="made" href="mailto:f.b.brokken@rug.nl">
</head>
<body text="#27408B" bgcolor="#FFFAF0">
<hr/>
<h1 id="title">Overview of rpn files</h1>
<p>
<ul>
<li> <a href="build">build</a>
<li> <a href="main.cc">main.cc</a>
<li> <a href="main.ih">main.ih</a>
<li> <a href="parser/grammar">parser/grammar</a>
<li> <a href="parser/lex.cc">parser/lex.cc</a>
<li> <a href="parser/Parser.ih">parser/Parser.ih</a>
</ul>
</body>
</html>
......@@ -44,13 +44,6 @@ IFDEF(latex)
DEFINEMACRO(itx)(0)(it())
DEFINEMACRO(itemlist)(1)(ARG1)
COMMENT(
DEFINEMACRO(tr)(3)(\
row(cell(ARG1)cell(verb( ))\
htmlcommand(<td valign="top">)ARG2+htmlcommand(</td>)cell(verb( ))\
cell(ARG3)))
END)
DEFINEMACRO(turl)(2)(\
IFDEF(html)\
(htmlcommand(<a target=_top href="ARG2">)ARG1+htmlcommand(</a>))\
......
#include "generator.ih"
void Generator::bolAt(ostream &out, string &line, istream &in, bool &accept)
const
void Generator::bolAt(string &line, bool &accept) const
{
auto iter = find(line, 0, s_atBol);
......
......@@ -148,8 +148,7 @@ class Generator
static void replace(std::string &str, char ch,
std::string const &replacement);
void insert(std::ostream &out, size_t indent, char const *skel) const;
void bolAt(std::ostream &out, std::string &line, std::istream &in,
bool &accept) const;
void bolAt(std::string &line, bool &accept) const;
template <typename AtType>
typename std::vector<AtType>::const_iterator find(
......
......@@ -13,7 +13,7 @@ void Generator::insert(ostream &out, size_t indent, char const *skel) const
while (getline(in, line))
{
if (line.find('@') == 0) // @ immediately at BOL
bolAt(out, line, in, accept);
bolAt(line, accept);
else if (accept)
{
replaceBaseFlag(line);
......
......@@ -167,6 +167,9 @@ void install(string request, string dest)
printf(" installing the user-guide at `", target, "'\n");
logInstall("tmp/manual", "", target);
printf(" installing rpn sources at `", target + "examples/'\n");
logRecursive("tmp/manual/examples", target + "examples/");
destInstall(dest, base + "u");
logInstalled(dest, "u");
......
......@@ -31,7 +31,7 @@ void manual()
run("mv *.html " HTMLDEST);
run("cp -r grammar/poly " HTMLDEST);
run("cp -r grammar/essence " HTMLDEST);
run("cp -r examples/rpn/* " HTMLDEST "/examples");
run("cp -r examples/rpn " HTMLDEST "/examples");
exit(0);
}
......
#include "parser.ih"
void Parser::blkAssign(string const &ruleType, Production const &prod)
// unused ruleType is required when initializing s_defaultAction in data.cc
void Parser::blkAssign([[maybe_unused]] string const &ruleType,
Production const &prod)
{
installDefaultAction(
prod,
......
#include "parser.ih"
void Parser::blkDirect(string const &ruleType, Production const &prod)
// unused ruleType is required when initializing s_defaultAction in data.cc
void Parser::blkDirect([[maybe_unused]] string const &ruleType,
Production const &prod)
{
installDefaultAction(prod, svsElement(prod.size(), 1) );
}
#include "parser.ih"
void Parser::blkNop(string const &ruleType, Production const &prod)
// unused parameters are required when initializing s_defaultAction in data.cc
void Parser::blkNop([[maybe_unused]] string const &ruleType,
[[maybe_unused]] Production const &prod)
{
}
#include "parser.ih"
void Parser::blkNopW(string const &ruleType, Production const &prod)
// unused ruleType is required when initializing s_defaultAction in data.cc
void Parser::blkNopW([[maybe_unused]] string const &ruleType,
Production const &prod)
{
wmsg << '`' << &prod <<
"': no default action block was installed" << endl;
......
#include "parser.ih"
void Parser::blkSTYPE(string const &ruleType, Production const &prod)
// unused ruleType is required when initializing s_defaultAction in data.cc
void Parser::blkSTYPE([[maybe_unused]] string const &ruleType,
Production const &prod)
{
installDefaultAction(prod, s_stype + "{}");
}
#include "parser.ih"
bool Parser::errNoTag(int nElements, Block &block, AtDollar const &atd)
// Unused parameters are required for the initialization of s_single in
// data.cc
bool Parser::errNoTag([[maybe_unused]] int nElements,
[[maybe_unused]] Block &block, AtDollar const &atd)
{
stdEmsg(atd) << "the STYPE__ semantic value type does not support "
"tags (`" << atd.text() << "')" << endl;
......
#include "parser.ih"
bool Parser::loc(int nElements, Block &block,AtDollar const &atd)
// unused `nElements' is required when initializing s_union in data.cc
bool Parser::loc([[maybe_unused]] int nElements,
Block &block, AtDollar const &atd)
{
block.replace(atd.pos(), atd.length(), s_locationValue);
warnForceLSP(atd.lineNr());
......
// Generated by Bisonc++ V6.00.00 on Thu, 18 May 2017 09:02:19 +0200
// Generated by Bisonc++ V6.01.01 on Thu, 08 Mar 2018 19:47:12 +0100
// base/comment
......@@ -1370,7 +1370,6 @@ SR__ s_153[] =
{ { 268}, { -10} }, // FLEX
{ { 270}, { -10} }, // IMPLEMENTATION_HEADER
{ { 271}, { -10} }, // LEFT
{ { 292}, { -10} }, // START
{ { 272}, { -10} }, // LOCATIONSTRUCT
{ { 273}, { -10} }, // LSP_NEEDED
{ { 274}, { -10} }, // LTYPE
......@@ -1388,6 +1387,7 @@ SR__ s_153[] =
{ { 289}, { -10} }, // SCANNER_MATCHED_TEXT_FUNCTION
{ { 290}, { -10} }, // SCANNER_TOKEN_FUNCTION
{ { 291}, { -10} }, // STACK_EXPANSION
{ { 292}, { -10} }, // START
{ { 294}, { -10} }, // STYPE
{ { 295}, { -10} }, // TARGET_DIRECTORY
{ { 296}, { -10} }, // TOKEN
......
......@@ -70,7 +70,8 @@ inline int Parser::lex()
return d_scanner.lex();
}
inline void Parser::exceptionHandler(std::exception const &exc)
inline void Parser::exceptionHandler(
[[maybe_unused]] std::exception const &exc)
{
throw; // re-implement to handle exceptions thrown by actions
}
// Generated by Bisonc++ V6.00.00 on Thu, 18 May 2017 09:02:19 +0200
// Generated by Bisonc++ V6.01.01 on Thu, 08 Mar 2018 19:47:12 +0100
// hdr/includes
#ifndef ParserBase_h_included
......
......@@ -189,8 +189,7 @@ class Rules
private:
static bool isTerminal(Symbol const *symbol);
static void updatePrecedence(Production *production,
Terminal::Vector const &tv);
static void updatePrecedence(Production *production);
};
inline Rules::Rules()
......
#include "rules.ih"
void Rules::updatePrecedence(Production *production,
Terminal::Vector const &tv)
void Rules::updatePrecedence(Production *production)
{
if (production->precedence()) // a precedence has already been set
{
return;
auto symbolIter =
find_if(production->begin(), production->end(), isTerminal);
if (symbolIter != production->end())
production->setPrecedence(Terminal::downcast(*symbolIter));
}
// elaborate compound stmnt after if (production->precedence):
// {
// if
// (
// not (*production)[0].isTerminal()
......@@ -21,14 +30,13 @@ void Rules::updatePrecedence(Production *production,
// ": 1st element must be a terminal token, 2nd "
// "element a non-terminal token" << endl;
// }
// return;
// }
return;
}
auto symbolIter =
find_if(production->begin(), production->end(), isTerminal);
if (symbolIter != production->end())
production->setPrecedence(Terminal::downcast(*symbolIter));
}
......@@ -8,5 +8,5 @@
void Rules::updatePrecedences()
{
for (auto production: d_production)
updatePrecedence(production, d_terminal);
updatePrecedence(production);
}
// Generated by Flexc++ V2.05.00 on Thu, 18 May 2017 09:02:20 +0200
// Generated by Flexc++ V2.06.03 on Thu, 08 Mar 2018 19:47:17 +0100
#include <iostream>
#include <fstream>
......@@ -28,8 +28,9 @@ size_t const ScannerBase::s_ranges__[] =
67,67,67,67,67,67,
};
// $insert startcondinfo
// s_dfa__ contains the rows of *all* DFAs ordered by start state. The
// enum class StartCondition__ is defined in the baseclass header
// enum class StartCondition__is defined in the baseclass header.
// StartCondition__::INITIAL is always 0. Each entry defines the row to
// transit to if the column's character range was sensed. Row numbers are
// relative to the used DFA, and d_dfaBase__ is set to the first row of
......@@ -2250,7 +2251,7 @@ size_t ScannerBase::Input::get()
{
case '\n':
++d_lineNr;
// FALLING THROUGH
[[fallthrough]]
default:
if (s_debug__)
......@@ -2592,17 +2593,17 @@ void ScannerBase::updateFinals__()
if (rf[0] != -1) // update to the latest std rule
{
// $insert debug
if (s_debug__)
s_out__ << "latest std rule: " << rf[0] << ", len = " << len << "\n" << dflush__;
// $insert debug
if (s_debug__)
s_out__ << "latest std rule: " << rf[0] << ", len = " << len << "\n" << dflush__;
d_final.std = FinalData { as<size_t>(rf[0]), len };
}
if (rf[1] != -1) // update to the latest bol rule
{
// $insert debug
if (s_debug__)
s_out__ << "latest BOL rule: " << rf[0] << ", len = " << len << "\n" << dflush__;
// $insert debug
if (s_debug__)
s_out__ << "latest BOL rule: " << rf[0] << ", len = " << len << "\n" << dflush__;
d_final.bol = FinalData { as<size_t>(rf[1]), len };
}
}
......
......@@ -101,7 +101,7 @@ inline void Scanner::preCode()
{
}
inline void Scanner::postCode(PostEnum__ type)
inline void Scanner::postCode([[maybe_unused]] PostEnum__ type)
{
}
......
// Generated by Flexc++ V2.05.00 on Thu, 18 May 2017 09:02:20 +0200
// Generated by Flexc++ V2.06.03 on Thu, 08 Mar 2018 19:47:17 +0100
#ifndef ScannerBASE_H_INCLUDED
#define ScannerBASE_H_INCLUDED
......@@ -51,8 +51,8 @@ protected:
};
public:
enum class StartCondition__ {
// $insert startCondNames
// $insert startcondenum
enum class StartCondition__{
INITIAL,
xstring,
pstring,
......@@ -216,10 +216,8 @@ protected:
ScannerBase(std::string const &infilename, std::string const &outfilename);
~ScannerBase();
StartCondition__ startCondition() const; // current start condition
bool popStream();
std::ostream &out();
void begin(StartCondition__ startCondition);
void echo() const;
void leave(int retValue) const;
......@@ -273,7 +271,14 @@ protected:
void lop3__(); // catch-all while matching b
void lop4__(); // matches the LOP's a head
// $insert startconddecl
StartCondition__ startCondition() const; // current start condition
void begin(StartCondition__ startCondition);
private:
static StartCondition__ constexpr SC(int sc);
static int constexpr SC(StartCondition__ sc);
size_t getInput();
size_t getLOP();
void p_pushStream(std::string const &name, std::istream *streamPtr);
......@@ -283,8 +288,6 @@ private:
template <typename ReturnType, typename ArgType>
static ReturnType constexpr as(ArgType value);
static bool constexpr available(size_t value);
static StartCondition__ constexpr SC(int sc);
static int constexpr SC(StartCondition__ sc);
};
inline ScannerBase::~ScannerBase()
......@@ -292,6 +295,30 @@ inline ScannerBase::~ScannerBase()
d_input.close();
}
// $insert startcondimpl
inline ScannerBase::StartCondition__ constexpr ScannerBase::SC(int sc)
{
return as<StartCondition__>(sc);
}
inline int constexpr ScannerBase::SC(StartCondition__ sc)
{
return as<int>(sc);
}
inline ScannerBase::StartCondition__ ScannerBase::startCondition() const
{
return SC(d_startCondition);
}
inline void ScannerBase::begin(StartCondition__ startCondition)
{
if (s_debug__)
s_out__ << "Switching to StartCondition__ # " << as<int>(startCondition) << '\n';
// d_state is reset to 0 by reset__()
d_dfaBase__ = s_dfaBase__[d_startCondition = SC(startCondition)];
}
template <typename ReturnType, typename ArgType>
inline ReturnType constexpr ScannerBase::as(ArgType value)
{
......@@ -309,16 +336,6 @@ inline bool constexpr ScannerBase::available(size_t value)
return value != std::numeric_limits<size_t>::max();
}
inline ScannerBase::StartCondition__ constexpr ScannerBase::SC(int sc)
{
return as<StartCondition__>(sc);
}
inline int constexpr ScannerBase::SC(StartCondition__ sc)
{
return as<int>(sc);
}
inline std::ostream &ScannerBase::out()
{
return *d_out;
......@@ -349,11 +366,6 @@ inline std::string const &ScannerBase::matched() const
return d_matched;
}
inline ScannerBase::StartCondition__ ScannerBase::startCondition() const
{
return SC(d_startCondition);
}
inline std::string const &ScannerBase::filename() const
{
return d_filename;
......@@ -384,15 +396,6 @@ inline void ScannerBase::more()
d_more = true;
}
inline void ScannerBase::begin(StartCondition__ startCondition)
{
// $insert debug
if (s_debug__)
s_out__ << "Switching to StartCondition__ # " << as<int>(startCondition) << "\n" << dflush__;
// d_state is reset to 0 by reset__()
d_dfaBase__ = s_dfaBase__[d_startCondition = SC(startCondition)];
}
inline size_t ScannerBase::state__() const
{
return d_state;
......
......@@ -5,10 +5,8 @@
// A conflict was observed as item 'reducibleItemIdx' and
// 'shiftableItemIdx' have identical LA symbols
//
void SRConflict::handleSRconflict(
size_t shiftableItemIdx,
Next::ConstIter const &next,
size_t reducibleItemIdx)
void SRConflict::handleSRconflict(Next::ConstIter const &next,
size_t reducibleItemIdx)
{
typedef Enum::Solution Solution;
......
......@@ -11,6 +11,6 @@
void SRConflict::processShiftReduceConflict(Next::ConstIter const &next,
size_t reducibleItemIdx)
{
for (auto shiftableItemIdx: next->kernel())
handleSRconflict(shiftableItemIdx, next, reducibleItemIdx);
for ([[maybe_unused]] auto shiftableItemIdx: next->kernel())
handleSRconflict(next, reducibleItemIdx);
}
......@@ -53,10 +53,8 @@ class SRConflict
std::ostream &insert(std::ostream &out) const;
void processShiftReduceConflict(Next::ConstIter const &next,
size_t itemIdx);
void handleSRconflict(size_t shiftableItemIdx,
Next::ConstIter const &next,
size_t reducibleItemIdx);
void handleSRconflict(Next::ConstIter const &next,
size_t reducibleItemIdx);
void visitReduction(size_t idx);
};
......
......@@ -10,7 +10,7 @@ void State::addNext(Symbol const *symbol, size_t idx)
// add all production rules of `symbol' to
// d_itemVector.
if (symbol->isNonTerminal()) // set dependent elements
addProductions(symbol, idx);
addProductions(symbol);
else
++d_nTerminalTransitions;
}
......@@ -11,14 +11,14 @@
// d_nextVector.back()'s kernel adds idx (as the item at d_itemVector[idx]) to
// its kernel-list.
void State::addProductions(Symbol const *symbol, size_t idx)
void State::addProductions(Symbol const *symbol)
{
// obtain all productions of `symbol'
Production::Vector const &productions =
NonTerminal::downcast(symbol)->productions();
for (auto production: productions)
StateItem::addProduction(production, d_itemVector, idx);
StateItem::addProduction(production, d_itemVector);
}
......
......@@ -11,7 +11,7 @@ void State::notReducible(size_t idx) // idx: item index in d_itemVector
Next::ConstIter next;
if (nextContains(&next, symbol)) // the symbol is in d_nextVector
addDependents(*next, symbol, idx);
addDependents(symbol, idx);
else // symbol not yet in d_nextVector
addNext(symbol, idx);
}
......
......@@ -111,8 +111,7 @@ class State
private:
State(size_t idx);
void addDependents(Next const &next, Symbol const *symbol,
size_t itemIdx);
void addDependents(Symbol const *symbol, size_t itemIdx);
// from notreducible from setitems: determine all
// dependent state items and X-link d_itemVector
// and d_nextVector
......@@ -138,7 +137,7 @@ class State
// add the productions of `symbol' to d_itemVector,
// make them depend on d_itemVector[idx]
void addProductions(Symbol const *symbol, size_t idx);
void addProductions(Symbol const *symbol);
Next::ConstIter nextFind(Symbol const *symbol) const;
......
......@@ -21,8 +21,7 @@
using namespace std;
using namespace FBB;
inline void State::addDependents(Next const &next, Symbol const *symbol,
size_t idx)
inline void State::addDependents(Symbol const *symbol, size_t idx)
{
d_itemVector[idx].setNext(Next::addToKernel(d_nextVector, symbol, idx));
}
......
......@@ -58,8 +58,7 @@ class StateItem
// production rule of this item.
static void addProduction(Production const *production,
StateItem::Vector &stateItem,
size_t idx);
StateItem::Vector &stateItem);
static bool containsKernelItem(Item const &item,
size_t nKernelItems,
......@@ -85,7 +84,7 @@ inline void StateItem::setLA(LookaheadSet const &laSet)
}
inline void StateItem::addProduction(Production const *production,
StateItem::Vector &stateItem, size_t idx)
StateItem::Vector &stateItem)
{
stateItem.push_back(StateItem(Item(production)));
}
......
#include "writer.ih"
void Writer::srTable(State const *sp, std::string const &baseclassScope,
FBB::Table &table, std::ostream &out)
void Writer::srTable(State const *sp, FBB::Table &table, std::ostream &out)
{
bool acceptState = sp->isAcceptState();
......
......@@ -20,7 +20,7 @@ void Writer::srTables() const
State::begin(), State::end(),
[&](State const *state)
{
srTable(state, d_baseclass, table, *d_out);
srTable(state, table, *d_out);
}
);
......
......@@ -43,7 +43,6 @@ class Writer
static void productionInfo(Production const *production,
std::ostream &out);
static void srTable(State const *state,
std::string const &baseclassScope,
FBB::Table &table, std::ostream &out);
static void transitions(FBB::Table &table, Next::Vector const &next);
static void transition(Next const &next, FBB::Table &table);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment