Giter VIP home page Giter VIP logo

flexcpp's People

Contributors

fbb-git avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

flexcpp's Issues

Specification example will no longer compile

The specification example given in the flexc++input man page no longer compiles.
Presumably because the mini-scanners are now in a strongly typed enum. Hence if I am not mistaken

"/*"            begin(comment);

<comment>.|\n   // ignore
<comment>"*/"   begin(INITIAL);

needs to become

"/*"            begin(StartCondition__::comment);

<comment>.|\n   // ignore
<comment>"*/"   begin(StartCondition__::INITIAL);

Which is quite ugly, but that is another topic.

Generated code should be sanitized

Hi,
I created a simple program that uses flexc++ to generate a lexer (along with bisonc++ for a parser), and compiled it with -fsanitize=leak.
I got a memory leak from the lexer code generated by flexc++ :

Direct leak of 280 byte(s) in 1 object(s) allocated from:
    #0 0x7f399f313be8 in operator new(unsigned long) (/usr/lib/x86_64-linux-gnu/liblsan.so.0+0xbbe8)
    #1 0x4055b1 in ScannerBase::ScannerBase(std::istream&, std::ostream&) ../src/parse/lex.cc:797

It seems that the skeleton file https://github.com/fbb-git/flexcpp/blob/master/flexc%2B%2B/skeletons/flexc%2B%2B.cc does not properly manage the memory for the input/output streams.

Wrong use of [[fallthrough]] attribute in generated .cc

The Lexer implementation generated by flexcpp uses the [[fallthrough]] attribute in a wrong way. It should be followed by a semicolon, see e.g. here and here.
E.g. currently, I have this:

size_t ScannerBase::Input::get()
{
    switch(size_t ch = next()) // get the next input char
    {
    case '\n':
        ++d_lineNr;
        [[fallthrough]]

    default:
        return ch;
    }
}

in my lex.cc, where it should be

size_t ScannerBase::Input::get()
{
    switch(size_t ch = next()) // get the next input char
    {
    case '\n':
        ++d_lineNr;
        [[fallthrough]]; // Semicolon needed!

    default:
        return ch;
    }
}

The Code is thus not conforming to the C++-17 standard. g++ ignores this, but Visual Studio won't compile this Code.

The current man page mentions 1.xx.xx has not been reached

From the current man page:

By now, the project has evolved to a level that we feel it's defensible to publish the program, although we still tend to consider the program in its experimental stage; it will remain that way until we decide to move its version from the 0.9x.xx series to the 1.xx.xx series.

https://github.com/fbb-git/flexcpp/blob/master/flexc%2B%2B/documentation/man/flexc%2B%2B.yo

Since flexc++ is now production ready (right?), this sentence should definitely be replaced.

Problem with nested namespaces

I have problems when using nested namespaces :)

This is my configuration:

%filenames = "MyParser"
%namespace = "my::nested::ns"
%class-name = "MyParser"
%baseclass-header = "MyParserBase.hpp"
%lex-source = "MyParserBase.cpp"
%class-header = "MyParser.hpp"
%implementation-header = "MyParserImpl.hpp"
%%
[ \t]+                              // skip white space chars.
[0-9]+                              return NUMBER;
[[:alpha:]_][[:alpha:][:digit:]_]*  return IDENTIFIER;
[][]                                return SIGNAL;
.                                   return matched()[0];
\n                                  begin(StartCondition__::INITIAL);

Here is the error:

In file included from parsing/flex/MyParserBase.cpp:9:
In file included from parsing/flex/MyParserImpl.hpp:4:
parsing/flex/MyParser.hpp:3:11: warning: extra tokens at end of #ifndef directive [-Wextra-tokens]
#ifndef my::nested::nsMyParser_H_INCLUDED_
          ^
          //
parsing/flex/MyParser.hpp:4:11: warning: ISO C99 requires whitespace after the macro name [-Wc99-extensions]
#define my::nested::nsMyParser_H_INCLUDED_
          ^

In file included from parsing/flex/MyParserBase.cpp:9:
In file included from parsing/flex/MyParserImpl.hpp:4:
In file included from parsing/flex/MyParser.hpp:7:
flex/MyParserBase.hpp:3:11: warning: extra tokens at end of #ifndef directive [-Wextra-tokens]
#ifndef my::nested::nsMyParserBASE_H_INCLUDED
          ^
          //
In file included from parsing/flex/MyParserBase.cpp:9:
In file included from parsing/flex/MyParserImpl.hpp:4:
parsing/flex/MyParser.hpp:10:11: error: expected identifier or '{'
namespace my::nested::ns
          ^
parsing/flex/MyParser.hpp:4:11: note: expanded from macro 'my'
#define my::nested::nsMyParser_H_INCLUDED_
          ^
parsing/flex/MyParser.hpp:10:11: error: no member named 'nested' in the global namespace
namespace my::nested::ns
          ^~
parsing/flex/MyParser.hpp:4:13: note: expanded from macro 'my'
#define my::nested::nsMyParser_H_INCLUDED_
          ~~^
parsing/flex/MyParserBase.cpp:12:11: error: expected identifier or '{'
namespace my::nested::ns
          ^
parsing/flex/MyParser.hpp:4:11: note: expanded from macro 'my'
#define my::nested::nsMyParser_H_INCLUDED_
          ^
parsing/flex/MyParserBase.cpp:12:11: error: no member named 'nested' in the global namespace
namespace my::nested::ns
          ^~
parsing/flex/MyParser.hpp:4:13: note: expanded from macro 'my'
#define my::nested::nsMyParser_H_INCLUDED_

When I replace %namespace = "my::nested::ns" whith %namespace = "mynestedns" everything works as expected. :)

I think that I'm using C++ feature for which flexc++ is not ready yet :)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.