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

Imported Upstream version 5.00.01

parent d38d62b0
#define VERSION "5.00.00"
#define VERSION "5.00.01"
#define YEARS "2005-2016"
......@@ -11,7 +11,8 @@ class Block: private std::string
{
friend std::ostream &operator<<(std::ostream &out, Block const &blk);
size_t d_line;
size_t d_lineNr;
std::string d_source; // the source in which the block
// was found. The block's text itself
// is in the Block's base class
......@@ -53,7 +54,8 @@ class Block: private std::string
std::vector<AtDollar>::const_reverse_iterator rbeginAtDollar() const;
std::vector<AtDollar>::const_reverse_iterator rendAtDollar() const;
size_t line() const;
size_t lineNr() const;
void setLineNr(size_t lineNr);
std::string const &source() const; // the block's source file
std::string const &str() const; // the block's contents
......@@ -87,9 +89,14 @@ Block::rendAtDollar() const
return d_atDollar.rend();
}
inline size_t Block::line() const
inline size_t Block::lineNr() const
{
return d_lineNr;
}
inline void Block::setLineNr(size_t lineNr)
{
return d_line;
d_lineNr = lineNr;
}
inline std::string const &Block::source() const
......
......@@ -8,7 +8,7 @@ void Block::open(size_t lineno, string const &source)
{ // assign line if no braces were open yet
clear();
this->string::operator=("{");
d_line = lineno;
d_lineNr = lineno;
d_source = source;
}
......
bisonc++ (5.00.01)
* Fixed verbinsert calls: yodl 3.07.01 implements a macro 'verbinsert'
rendering bisonc++'s own definition superfluous. The new definition
requires 1 argument, and the old one 2, so the verbinsert calls were
updated accordingly.
* Alexander Sedov noticed that line numbers in the default actions were
incorrect. Line numbers of default actions are now set to the line of the
'|' or ';' character following the production rule receiving a default
action block.
* Updated the 'required' file.
-- Frank B. Brokken <f.b.brokken@rug.nl> Mon, 25 Apr 2016 15:47:27 +0530
bisonc++ (5.00.00)
* Options/directives:
......
......@@ -4,7 +4,7 @@ grammar.
For example, here is an erroneous attempt to define a sequence of zero or more
words:
verbinsert(-as4)(examples/rr1)
verbinsert(-as4 examples/rr1)
The error is an ambiguity: there is more than one way to parse a single
word into a sequence. It could be reduced to a maybeword and then into a
sequence via the second rule. Alternatively, nothing-at-all could be reduced
......
......@@ -6,7 +6,7 @@ calculator. Now we show how to recover from erroneous input.
The b() grammar-specification language includes the reserved symbol tt(error),
which can be used in production rules. In the example below it has been added
as a new alternative for recognizing the tt(line) nonterminal:
verbinsert(//LINE)(errorcalc/parser/grammar)
verbinsert(//LINE errorcalc/parser/grammar)
This addition to the grammar allows the calculator to recover from syntax
errors. If a syntax error is encountered, the third production rule is
activated, skipping all tokens until a newline token has been encounters. At
......
Here are the directives that are used for the reverse polish notation
calculator. As in bf(C++), end-of-line comments may be used.
verbinsert(//DECL)(rpn/parser/grammar)
verbinsert(//DECL rpn/parser/grammar)
The grammar file's first (directive) configures b() by specifying the
tokens (see section The b() Declarations Section). Each terminal symbol that
is not a single-character literal must be declared here (Single-character
......
Here are the grammar rules for the reverse polish notation calculator.
verbinsert(//RULES)(rpn/parser/grammar)
verbinsert(//RULES rpn/parser/grammar)
The rules of the tt(rpn) `language' defined here are the expression
(using the name tt(exp)), the line of input (tt(line)), and the complete input
transcript (tt(input)). Each of these nonterminal symbols has several
......
......@@ -66,9 +66,6 @@ DEFINEMACRO(lshift)(0)(\
)\
)
DEFINEMACRO(verbinsert)(2)(\
PIPETHROUGH(yodlverbinsert ARG1 ARG2)()\
)
DEFINEMACRO(rshift)(0)(\
IFDEF(latex)(\
NOTRANS($>>$)\
......
......@@ -11,7 +11,7 @@ void clean(int dist)
if (dist)
run("rm -rf tmp" );
run("rm -rf tmp a */a" );
chdir("documentation");
......
void github()
{
run("cp -r release.yo tmp/manhtml/bisonc++man.html tmp/manual "
"../../wip");
run("cp -r release.yo tmp/manhtml/*.html tmp/manual " "../../wip");
run("cp changelog ../../wip/changelog.txt");
exit(0);
}
......@@ -9,7 +9,6 @@
#define REFRESH
#define LIBRARY "modules"
#define SHAREDREQ ""
//#define CLS
#define USE_ALL "a"
#define SOURCES "*.cc"
#define ADD_LIBRARIES "bobcat"
......@@ -18,7 +17,6 @@
#define SCANGEN "flexc++"
#define SCANFLAGS ""
#define SCANSPEC "lexer"
//#define SCANFILES ""
#define SCANOUT "lex.cc"
#define PARSER_DIR "parser"
#define PARSGEN "bisonc++"
......
......@@ -90,6 +90,9 @@ _rule:
_ruleName
_productionList
';'
{
updateDefaultActionLineNr();
}
;
rules:
......
......@@ -5,6 +5,7 @@ void Parser::installAction(Block &block)
// process the block for the last
// production rule, having a given number
// of elements.
substituteBlock(d_rules.nElements(), block);
d_rules.setAction(block);
}
......
......@@ -10,5 +10,7 @@ void Parser::installDefaultAction(Production const &prod,
" " + s_semanticValue + " = " + rhs + ";\n"
"}";
d_rules.setAction(block);
d_rules.setAction(block, true); // true: last actionblock was default
// action. Requires update of the
// action block's line number.
}
// Generated by Bisonc++ V5.00.00 on Wed, 13 Apr 2016 12:39:56 +0530
// Generated by Bisonc++ V5.00.01 on Mon, 25 Apr 2016 11:51:55 +0530
// $insert class.ih
#include "parser.ih"
......@@ -2388,6 +2388,12 @@ try
}
break;
case 113:
{
updateDefaultActionLineNr();
}
break;
}
// $insert debug
if (d_debug__)
......
......@@ -111,6 +111,8 @@ class Parser: public ParserBase
std::string> const &polymorphic() const;
private:
void updateDefaultActionLineNr();
void checkField(std::string const &field); // see inc/typename
static void warnDefaultAction(Production const &prod);
......
// Generated by Bisonc++ V5.00.00 on Wed, 13 Apr 2016 12:39:56 +0530
// Generated by Bisonc++ V5.00.01 on Mon, 25 Apr 2016 11:51:55 +0530
#ifndef ParserBase_h_included
#define ParserBase_h_included
......
#include "parser.ih"
void Parser::updateDefaultActionLineNr()
{
d_rules.updateDefaultActionLineNr(d_scanner.lineNr());
}
......@@ -12,7 +12,7 @@ void Production::insertAction(Production const *prod, std::ostream &out,
Block const &block = prod->action();
if (lineDirectives)
out << "#line " << block.line() << " \"" << block.source() <<
out << "#line " << block.lineNr() << " \"" << block.source() <<
"\"\n";
while (true)
......
......@@ -72,6 +72,8 @@ class Production: private std::vector<Symbol *>
Production(Symbol const *nonTerminal, size_t lineNr);
Block const &action() const;
void setBlockLineNr(size_t lineNr);
Symbol const &operator[](size_t idx) const;
Symbol const *rhs(size_t idx) const; // idx-ed symbol in the rhs
Symbol const *lhs() const;
......@@ -108,6 +110,11 @@ class Production: private std::vector<Symbol *>
std::ostream &standard(std::ostream &out) const;
};
inline void Production::setBlockLineNr(size_t lineNr)
{
d_action.setLineNr(lineNr);
}
inline void Production::setLineNr(size_t lineNr)
{
d_lineNr = lineNr;
......
......@@ -5,15 +5,15 @@ explicitly mentioned, but a fairly recent one is assumed.
Required software for building Bisonc++ 4.13.00
-----------------------------------------------
libbobcat-dev (>= 4.01.03),
libbobcat-dev (>= 4.01.04),
To use the provided build-script:
icmake (>= 8.00.04)
icmake (>= 8.01.00)
To construct the manual and map-page:
yodl (>= 3.06.0)
yodl (>= 3.07.01)
......@@ -9,6 +9,10 @@ void Rules::addProduction(size_t lineNr)
// that case there's
// also no production.
// cerr << "addProduction: PRODUCTION at line " << lineNr << '\n';
updateDefaultActionLineNr(lineNr);
s_lastLineNr = lineNr;
// create production
......@@ -27,3 +31,4 @@ void Rules::addProduction(size_t lineNr)
// endl;
}
......@@ -20,6 +20,9 @@
// iterators into the symbol table
class Rules
{
bool d_defaultAction; // last action was default action:
// requires line update at the next
// rule definition
public:
// For each rule, maintain a record of file/line combinations
// indicating where the rule was first seen. This allows me to
......@@ -96,6 +99,7 @@ class Rules
// add the symbol as the next element of the
// rule-production that's currently being defined.
void updateDefaultActionLineNr(size_t lineNr);
void addProduction(size_t lineNr);
// add a new production to the set of productions of the
// rule currently being defined
......@@ -143,7 +147,7 @@ class Rules
// associate an action with the currently defined rule
// production
void setAction(Block const &block);
void setAction(Block const &block, bool defaultAction = false);
void setHiddenAction(Block const &block);
......@@ -255,8 +259,9 @@ inline size_t Rules::nElements() const
return d_currentProduction->size();
}
inline void Rules::setAction(Block const &block)
inline void Rules::setAction(Block const &block, bool defaultAction)
{
d_defaultAction = defaultAction;
d_currentProduction->setAction(block);
}
......
#include "rules.ih"
void Rules::updateDefaultActionLineNr(size_t lineNr)
{
if (d_defaultAction && d_currentProduction)
{
d_currentProduction->setBlockLineNr(lineNr);
d_defaultAction = false;
}
}
// Generated by Flexc++ V2.05.00 on Wed, 13 Apr 2016 12:40:03 +0530
// Generated by Flexc++ V2.05.00 on Mon, 25 Apr 2016 11:51:55 +0530
#include <iostream>
#include <fstream>
......
// Generated by Flexc++ V2.05.00 on Wed, 13 Apr 2016 12:40:03 +0530
// Generated by Flexc++ V2.05.00 on Mon, 25 Apr 2016 11:51:55 +0530
#ifndef ScannerBASE_H_INCLUDED
#define ScannerBASE_H_INCLUDED
......
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