Use smart-pointer and generate C++ code for bison/flex#410
Use smart-pointer and generate C++ code for bison/flex#410hangingman wants to merge 9 commits intoBNFC:masterfrom
Conversation
|
Thanks for the update, @hangingman ! I will have a look soon, but I decided to make 2.9.4 a conservative release, and only then merge new features. |
5f6eebb to
cc2c700
Compare
|
Thanks @hangingman for the PR! I pushed a commit that puts the At the moment, they error if flag Also, the plain (This is for |
|
@andreasabel Thank you !
Got it. I'll look into it.
OK, I will fix it. |
|
Looks like Haskell-CI is currently broken because of I'll fix a push to |
|
@andreasabel Oh, I got it. |
|
I pushed the fix for #416 to master just now. |
67111e6 to
a700506
Compare
|
Sorry broke the stack build by accident, but now both builds should work. (Fixed in #417.) |
* Modify include file and Parser header file name as psXXX * Add compile option to `src/BNFC/Backend/CPP/Makefile.hs`
* Modify C++ generator module for mainly using unique_ptr
* refacotor prList, prListC
* Implement switching bison %union and variant * Implement C++ parser with driver setting * Implement C++ driver/scanner class * Fix file extension * Fix token type * Fix flex buffer related code * Refactor makefile compile option * Implement reverse function in ListXXX class Add member fields for Driver class to receive parsed objects Update CFtoBisonC and CFtoSTLAbs for wrapping std::uniuqe_ptr Update C++ Abs files and Printer class Update PrettyPrinter code for using smart-ptr Enable to compile testcc * add driver entry codes * modify SkelSTL.hs for header file extension * Enable debugging of lexer/parser Change bison yy file to use shared_ptr instead of unique_ptr
Fix following: * Dont' generate `override` keyword on `--ansi` mode * Remove doubly defined YY_BUFFER_STATE in `--ansi` mode * Switch `--ansi` and `-std=c++14` mode in `source/src/BNFC/Backend/CPP/PrettyPrinter.hs` * Fix Parser.h, switch entry points interfaces * Use C++ location/position interface
a700506 to
e0d21a2
Compare
|
@andreasabel CI is passed. But, I realized test cases under the testing directory is failing. working on this PR hangingman#5 |
) * Make enable filtering of bnfc-system-tests * Remove override keyword from clone() C++ * Add work-around of "transition table overflow, automaton is too big" https://stackoverflow.com/a/63461031/2565527 * Add yylval->emplace<char>(); for escaped charcters * Deal with C++ NO STL * Add switching of smart-pointer on pp and absyn * Fix skelton code generator * Absyn list should append the last when adding the element * Remove dummy FlexLexer class * Fix C/C++ namespace problem * Fix bnfc define statement problem * Switch using shared-ptr or not, according to base-classes or token-classes * Fix cons impl in definedRules * Fix error handling * deal with reversible classes such that it can do left recursion
|
@andreasabel Hi, |
|
@andreasabel @VBeatrice Hi, |
ref #293
PR description:
I modified large amount of source code related with issue #293 .
I would like to take a review. If there are any problems in this PR, please point them out.
And If it's OK, tell me what unit tests should be added.
PR Summary
bnfc
usinginstead oftypedefstd::shared_ptrbnfc-system-tests
PR contents
Makefile and file extension changes:
--ansiflag, Makefile would use-std=c++14compile option otherwise use--ansiflag.--ansiflag, bnfc will generate.cc,.hh,.yy,.llfiles for bison/flex. In the nutshell, it represents C++ things.C++ AST/Test code generator switching
--ansiflag, bnfc would generate codes using smart-pointer (std::shared_ptr), otherwise bnfc generate codes same as before.use
usinginstead oftypedefstd::shared_ptr, like following:std::unique_ptr, it's not necessary to release memory manually. It's convenient. (std::unique_ptris not copy-able. This is not good for storing parsed AST and returning it. On the other hand,std::shared_ptris copy-able , furthermore it will be automatically released after their reference count will be 0. So I introducedshared_ptr. We can find several implmentations usingstd::shared_ptras bison's semantic type in the world GitHub. So, this is common implementation.)bison's yy file will be like following; You can find bison's yy file using variant, and shared_ptr.
std::istream &streamas their parameters. Because it can handle file contents and stdin data. Entrypoints will be generated in "Driver" class.PATTREN,-n PATTERNoption, make enable filtering of bnfc-system-tests