Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add >>IMP INCLUDE directive #143

Open
wants to merge 9 commits into
base: gcos4gnucobol-3.x
Choose a base branch
from

Conversation

engboris
Copy link
Contributor

@engboris engboris commented Apr 25, 2024

Closes #114 and completes FR176 on SourceForge.

A new directive >> IMP INCLUDE FILE_1 ... FILE_n is introduced, allowing to include multiple C headers. Only files with name finishing by .h are allowed.

I'm not sure about that but I marked the feature with /* GnuCOBOL 3.3 extension*/.

@engboris engboris added the enhancement New feature or request label Apr 25, 2024
Copy link
Collaborator

@GitMensch GitMensch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this first take - please copy the tests for --include and adjust those for the directive. In gnbucobol.texi and NEWS add a remark in the --include description, that the directive can be used as an alternative.

cobc/pplex.l Outdated Show resolved Hide resolved
cobc/ppparse.y Outdated Show resolved Hide resolved
cobc/ppparse.y Outdated Show resolved Hide resolved
cobc/pplex.l Outdated Show resolved Hide resolved
@GitMensch
Copy link
Collaborator

GitMensch commented Apr 29, 2024 via email

@engboris engboris force-pushed the engboris-imp-directive branch 4 times, most recently from c035033 to 7bb6097 Compare April 30, 2024 16:07
cobc/pplex.l Outdated Show resolved Hide resolved
cobc/scanner.l Outdated Show resolved Hide resolved
cobc/scanner.l Outdated Show resolved Hide resolved
cobc/codegen.c Outdated Show resolved Hide resolved
cobc/scanner.l Outdated Show resolved Hide resolved
tests/testsuite.src/syn_misc.at Outdated Show resolved Hide resolved
@engboris engboris force-pushed the engboris-imp-directive branch 3 times, most recently from 2ad6625 to 7b94002 Compare May 3, 2024 15:13
Copy link
Collaborator

@GitMensch GitMensch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

still some requested changes - but we're on the finish line with this PR

NEWS Outdated Show resolved Hide resolved
cobc/codegen.c Outdated Show resolved Hide resolved
cobc/cobc.c Outdated Show resolved Hide resolved
cobc/ChangeLog Outdated Show resolved Hide resolved
tests/testsuite.src/syn_misc.at Show resolved Hide resolved
tests/testsuite.src/used_binaries.at Outdated Show resolved Hide resolved
cobc/codegen.c Outdated Show resolved Hide resolved
cobc/scanner.l Outdated Show resolved Hide resolved
tests/testsuite.src/used_binaries.at Outdated Show resolved Hide resolved
Copy link
Collaborator

@GitMensch GitMensch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"approved with minor changes"

Copy link
Collaborator

@GitMensch GitMensch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changes to the testcases needed, overal fine

tests/testsuite.src/used_binaries.at Outdated Show resolved Hide resolved
tests/testsuite.src/syn_misc.at Show resolved Hide resolved
cobc/codegen.c Outdated Show resolved Hide resolved
@engboris engboris force-pushed the engboris-imp-directive branch 5 times, most recently from 331e050 to 0df9e5b Compare June 13, 2024 12:37
@engboris engboris closed this Jun 13, 2024
@ddeclerck ddeclerck reopened this Jun 13, 2024
@engboris
Copy link
Contributor Author

@GitMensch Could you check this? It was almost finished and it was a rather minor change but I wasn't sure about the tests. Thank you!

Copy link
Collaborator

@GitMensch GitMensch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

code changes requested for @engboris - I'll adjust the used_binaries.at, so please don't force-push

cobc/ChangeLog Outdated Show resolved Hide resolved
cobc/cobc.h Show resolved Hide resolved
cobc/pplex.l Outdated Show resolved Hide resolved
cobc/scanner.l Outdated Show resolved Hide resolved
Comment on lines +1844 to +1848
if (last != NULL) {
cobc_free (last->text);
cobc_free (last);
}
last = l;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently the memory was allocated with cobc_malloc and would need to be always freed, and that must also be done when there is no codegen (preprocess/syntaxy-check only) so must be done outside of codegen.

I think the parse_ memory functions would be more reasonable and drop the need to execute the free, also removing the need to keep the "last" element here; the only thing missing then is to initialize cb_include_file_list_directive at the right place

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I understand correctly, I should free those variables outside/independently of codegen but still after the running of codegen? Maybe after ylex_clear_all () in cobc.c and add a parse_clear_all () function or something like that?

tests/testsuite.src/syn_misc.at Outdated Show resolved Hide resolved
cobc/ppparse.y Show resolved Hide resolved
@GitMensch
Copy link
Collaborator

I've rebased this PR and adjusted the "real" test for IMP INCLUDE. There are still open changes (see review notes), but I'm sure @engboris will have a look at those over the next days (or hours)?

/* GnuCOBOL 3.3 extension */
INCLUDE
{
ppparse_error (_("Missing argument for IMP INCLUDE directive"));
Copy link
Contributor Author

@engboris engboris Jul 29, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if this was what you expected. The only error I get for missing arguments is this one. There is no other errors displayed. You talked about "resetting the error".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants