...
 
Commits (3)
......@@ -23,7 +23,7 @@
#define CXX "g++"
// the compiler options to use.
#define CXXFLAGS "-Wall -O2 -fdiagnostics-color=never"
#define CXXFLAGS "-Wall -O2 --std=c++2a -fdiagnostics-color=never"
// -Wunused-parameter -Werror
// flags passed to the linker
......
#define VERSION "2.07.02"
#define VERSION "2.07.03"
#define YEARS "2008-2018"
flexc++ (2.07.03)
* Updated the QUICK START sections in bf(flexc++)(1).
* Compiling flexc++ itself depends on facilities in the std::filesystem
namespace. This requires a recent compiler (e.g., g++-8.2.0 or beyond)
when compiling flexc++.
* The inline function template 'as' is relocated above the inline functions
using 'as', to prevent clang++-7 compilation warnings.
-- Frank B. Brokken <f.b.brokken@rug.nl> Sat, 10 Nov 2018 12:06:28 +0100
flexc++ (2.07.02)
* [[fallthrough]] requires a final semicolon (cf. C++ std 20, 10.6.5).
......
flexc++ (2.07.03-1) unstable; urgency=low
* New upstream release: updated some manual sections and other cosmetic
changes. See the upstream changelog.
* debian/rules specifies C++ std 2a.
-- Frank B. Brokken <f.b.brokken@rug.nl> Sat, 10 Nov 2018 12:36:35 +0100
flexc++ (2.07.02-2) UNRELEASED; urgency=medium
* d/copyright: Change Format URL to correct one
......
......@@ -5,10 +5,10 @@ Maintainer: Frank B. Brokken <f.b.brokken@rug.nl>
Uploaders: George Danchev <danchev@spnet.net>,
tony mancill <tmancill@debian.org>
Build-Depends: debhelper (>= 11.1.2),
libbobcat-dev (>= 4.08.03),
libbobcat-dev (>= 4.08.05),
icmake (>= 9.02.04),
yodl (>= 4.02.00)
Standards-Version: 4.1.4
Standards-Version: 4.2.1
Homepage: https://fbb-git.gitlab.io/flexcpp/
Vcs-Browser: https://salsa.debian.org/debian/flexcpp
Vcs-Git: https://salsa.debian.org/debian/flexcpp.git
......
......@@ -18,7 +18,7 @@ export LDFLAGS = $(shell dpkg-buildflags --get LDFLAGS)
export LDFLAGS += -Wl,-z,now
export CXXFLAGS = $(shell dpkg-buildflags --get CXXFLAGS)
export CXXFLAGS += --std=c++17 -Wall -D_FORTIFY_SOURCE=2
export CXXFLAGS += --std=c++2a -Wall -D_FORTIFY_SOURCE=2
export CXX = g++
......
......@@ -3,11 +3,15 @@
A bare-bones, no-frills scanner is generated as follows:
itemization(
it() First define a subdirectory tt(scanner), and change-dir to
tt(scanner). This directory is going to contain all scanner-related files,
created next.
it() Create a file tt(lexer) defining the regular expressions to
recognize, and the tokens to return. Use token values exceeding 0xff if plain
ascii character values can also be used as token values. Example (assume
capitalized words are token-symbols defined in an enum defined by the scanner
class):
recognize, and the tokens to return. Use token values exceeding 0xff when
plain ascii character values could also be used as token values. Example
(assume capitalized words are token-symbols defined in an enum defined by the
scanner class):
verb(
%%
[ \t\n]+ // skip white space chars.
......@@ -20,10 +24,10 @@ class):
verb(
flexc++ lexer
)
This generates four files): tt(Scanner.h, Scanner.ih, Scannerbase.h), and
tt(lex.cc)
This generates four files: tt(Scanner.h, Scanner.ih, Scannerbase.h), and
tt(lex.cc).
it() Edit tt(Scanner.h), add the enum defining the token-symbols in
it() Edit tt(Scanner.h) to add the enum defining the token-symbols in
(usually) the public section of the class tt(Scanner). E.g.,
verb(
class Scanner: public ScannerBase
......@@ -35,12 +39,14 @@ class Scanner: public ScannerBase
NUMBER
};
// ... (etc, as generated by flexc++)
}
)
it() Create a file defining tt(int main), e.g.:
it() Change-dir to tt(scanner's) base directory, and there create a file
tt(main.cc) defining tt(int main):
verb(
#include <iostream>
#include "Scanner.h"
#include "scanner/Scanner.h"
using namespace std;
......@@ -68,9 +74,9 @@ int main()
}
}
)
it() Compile all tt(.cc) files:
it() Compile all tt(.cc) files, creating tt(a.out):
verb(
g++ *.cc
g++ *.cc scanner/*.cc
)
it() To `tokenize' tt(main.cc), execute:
......@@ -83,11 +89,11 @@ int main()
To interface flc() to the bf(bisonc++)(1) parser generator proceed as follows:
itemization(
it() Specify a grammar that can be processed by bf(bisonc++)(1). Assuming
that the scanner and parser are developed in, respectively, the
sub-directories tt(scanner) and tt(parser), then a simple grammar
specification that can be used with the scanner developed in the previous
section is (e.g., write the file tt(./parser/grammar)):
it() Start from the directory containing tt(main.cc) used in the previous
section; the lexical scanner developed there is also used here.
it() Create a directory tt(parser) and change-dir to that directory.
it() Define the following grammar in the file tt(grammar):
verb(
%scanner ../scanner/Scanner.h
......@@ -116,62 +122,60 @@ token:
CHAR
;
)
it() Now that the tokens have been identified, change to the (mentioned)
tt(./scanner) directory and write a scanner specification file
tt(lexer). E.g.,
verb(
%%
[ \t\n]+ // skip white space chars.
it() Create the parser by executing:
verb(
bisonc++ grammar
)
This generates four files: tt(parse.cc, Parserbase.h, Parser.h,) and
tt(Parser.ih)
it() Now that the parser has been defined, edit the (three) lines in the
file tt(../scanner/lexer) containing return statements. Change these lines
as follows (the first two lines of the file tt(lexer) remain as-is):
verb(
[0-9]+ return Parser::NUMBER;
[[:alpha:]_][[:alpha:][:digit:]_]* return Parser::IDENTIFIER;
. return Parser::CHAR;
)
This causes the scanner to return tt(Parser) tokens to the generated
This allows the scanner to return tt(Parser) tokens to the generated
parser.
it() Execute:
it() Modify the scanner so that it returns these tt(Parser) tokens
by executing:
verb(
flexc++ lexer
)
This generates four files): tt(Scanner.h, Scanner.ih, Scannerbase.h), and
tt(lex.cc)
it() Add the line
verb(
#include "../parser/Parserbase.h"
)
to the file tt(scanner/Scanner.ih)
it() Next, add the line
verb(
#include "../parser/Parserbase.h"
)
to the file tt(scanner/Scanner.ih), informing the scanner about the
existence of the parser-tokens.
it() Change back to the tt(./parser) directory and execute:
verb(
bisonc++ grammar
)
This generates four files): tt(parse.cc, Parserbase.h, Parser.h,) and
tt(Parser.ih)
it() Return to tt(./parser's) parent directory and write a simple tt(main)
function in the file tt(main.cc). E.g.,
it() Change-dir to the tt(scanner's) parent directory and rewrite the
tt(main.cc) file defined in the previous section to contain:
verb(
#include "parser/Parser.h"
int main(int argc, char **argv)
{
Parser parser;
parser.parse();
}
)
it() Compile all sources:
verb(
g++ *.cc */*.cc
)
verb(
g++ *.cc */*.cc
)
it() Execute the program, providing it some source file to be processed:
verb(
a.out < main.cc
)
it() Execute the program, providing it with some source file to be
processed:
verb(
a.out < main.cc
)
)
manpagesection(3. GENERATED FILES)
......
NOUSERMACRO(lex setDebug main)
NOUSERMACRO(lex setDebug main determineSubsets finalizeStates switchOstream
switchIstream)
includefile(preamble)
affiliation(url(University of Groningen)(http://www.rug.nl/))
......
#include "INSTALL.im"
#define MAIN "main.cc"
#define ADD_LIBRARIES "bobcat"
#define ADD_LIBRARIES "bobcat stdc++fs"
#define ADD_LIBRARY_PATHS ""
#define SCANNER_DIR "scanner"
#define PARSER_DIR "parser"
......
// Generated by Flexc++ V2.07.00 on Tue, 15 May 2018 17:08:05 +0200
// Generated by Flexc++ V2.07.03 on Sat, 10 Nov 2018 12:56:47 +0100
#include <iostream>
#include <fstream>
......
......@@ -13,7 +13,7 @@ void Scanner::maybeSwitchStream()
!= string::npos;
if (not isComment)
isComment = access(text.c_str(), R_OK) != 0;// the file must exist
isComment = fs::exists(text); // the file must exist
// or //incl. is comment
if (isComment)
{
......
......@@ -4,10 +4,14 @@
#include <iostream>
#include <algorithm>
#include <filesystem>
#include <bobcat/mstream>
#include <bobcat/string>
using namespace std;
namespace fs = filesystem;
using namespace FBB;
inline int Scanner::handle(int token) const
......
// Generated by Flexc++ V2.07.00 on Tue, 15 May 2018 17:08:05 +0200
// Generated by Flexc++ V2.07.03 on Sat, 10 Nov 2018 12:56:47 +0100
#ifndef ScannerBASE_H_INCLUDED
#define ScannerBASE_H_INCLUDED
......@@ -282,6 +282,12 @@ inline ScannerBase::~ScannerBase()
d_input.close();
}
template <typename ReturnType, typename ArgType>
inline ReturnType constexpr ScannerBase::as(ArgType value)
{
return static_cast<ReturnType>(value);
}
// $insert startcondimpl
inline ScannerBase::StartCondition_ constexpr ScannerBase::SC(int sc)
{
......@@ -304,12 +310,6 @@ inline void ScannerBase::begin(StartCondition_ startCondition)
d_dfaBase_ = s_dfaBase_[d_startCondition = SC(startCondition)];
}
template <typename ReturnType, typename ArgType>
inline ReturnType constexpr ScannerBase::as(ArgType value)
{
return static_cast<ReturnType>(value);
}
inline bool ScannerBase::knownFinalState()
{
return (d_atBOL && available(d_final.bol.rule)) ||
......
......@@ -227,14 +227,14 @@ inline \@Base::~\@Base()
d_input.close();
}
$insert startcondimpl
template <typename ReturnType, typename ArgType>
inline ReturnType constexpr \@Base::as(ArgType value)
{
return static_cast<ReturnType>(value);
}
$insert startcondimpl
inline bool \@Base::knownFinalState()
{
return (d_atBOL && available(d_final.bol.rule)) ||
......