-
Notifications
You must be signed in to change notification settings - Fork 49
Integration of EXEC preprocessor beyond baseline. #294
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
Open
utam-1
wants to merge
25
commits into
OCamlPro:gitside-gnucobol-3.x
Choose a base branch
from
utam-1:exec-preprocessor-beyond-baseline
base: gitside-gnucobol-3.x
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
9a895d7
Added initial EXEC preprocessor handling logic in pplex and ppparse
utam-1 119e265
Modified approach based on review comments
utam-1 e492b07
Deleted unreleated files, and fixed inconsistencies
utam-1 31c0601
Refined the test cases based on feedback
utam-1 a946047
Applied the changes based on feedback
utam-1 88a2960
Modified test cases and added support for EOF
utam-1 b645b64
Added new test cases and subsytem token
utam-1 632cc07
Restored to previous commit with modified test cases
utam-1 5909d70
Modified subsystem handling for dotted names and improved test cases
utam-1 f037357
Implementation of step 4, 5 and 6 after baseline integration.
utam-1 3f1ef75
windows-msvc: fix env var reference for dependencies
GitMensch 0a8d46a
workflow updates
GitMensch 4694240
Rename is_test to cob_is_test in libcob as it is an extern value
f28fec5
Config option tab-width can receive a list of comma-separated widths
39f8299
Fix handling of some special contexts, and provide room for more
6ca36c7
Performed modifications based on feedback.
utam-1 4054ab6
Refactored config parser approach and modified test expectations
utam-1 65bde01
Config option tab-width can receive a list of comma-separated widths
89a2526
Fix handling of some special contexts, and provide room for more
7b34538
Fix and update CI
ddeclerck ed29d25
Placed tests in config.at and modified approach for msvc error
utam-1 546813b
Revert "Placed tests in config.at and modified approach for msvc error"
utam-1 126eb25
Changed position of test cases and updated preparser conf
utam-1 0058c20
Modified common.c to resolve the build errors.
utam-1 b9f9d96
Merge branch 'gitside-gnucobol-3.x' into exec-preprocessor-beyond-bas…
utam-1 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -1,4 +1,24 @@ | ||||||
|
|
||||||
| 2026-07-31 Uttam Singh Bhadauriya <uttamsinghbhadoriya23@gmail.com> | ||||||
|
|
||||||
| * cobc.c, config.c, tree.h, pplex.l: | ||||||
| refactor external preparser: move struct cb_preparser_entry | ||||||
| to tree.h; rename tag->subsystem; move config loading | ||||||
| functions to config.c; share line-parsing with cb_config_entry; | ||||||
| fix indentation; fix cmd_len calculation | ||||||
| * help.c: add --preparser option documentation | ||||||
|
|
||||||
| 2026-05-24 Fabrice Le Fessant <fabrice.le_fessant@ocamlpro.com> | ||||||
|
|
||||||
| * config.def: "tab-width" option is changed to a comma-separated | ||||||
| list of tab widths, for example "6,1,4", the last one being reused. | ||||||
| This new meaning is backward compatible. | ||||||
| Implements FR #498 " Adjust tab-width to optionally be a list of | ||||||
| tab-stop positions" | ||||||
| * config.c: initialize cb_tab_width as a string, | ||||||
| each position indicating the number of spaces to insert for a tab | ||||||
| at that position | ||||||
| * pplex.l,cobc.c: use the new type of cb_tab_width | ||||||
| 2026-06-08 Nicolas Berthier <nicolas.berthier@ocamlpro.com> | ||||||
|
|
||||||
| * tree.h, parser.y: change type of cobc_cs_check flags to permit | ||||||
|
|
@@ -25,6 +45,19 @@ | |||||
| at that position | ||||||
| * pplex.c,cobc.c: use the new type of cb_tab_width | ||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
... but I'm a but confused where that entry comes from... |
||||||
|
|
||||||
| 2026-03-16 Uttam Singh Bhadauriya <uttamsinghbhadoriya23@gmail.com> | ||||||
|
|
||||||
| * pplex.l: add EXEC_STATE exclusive start condition to | ||||||
| tokenize EXEC <TAG> ... END-EXEC blocks; add AREA_A lookahead | ||||||
| rule for EXEC; return INCLUDE token for INCLUDE keyword, | ||||||
| plain TOKEN for words; consume all other content silently | ||||||
| * ppparse.y: add exec_statement grammar rule dispatched | ||||||
| from statement_no_replace; EXEC TAG INCLUDE handled as COPY | ||||||
| (full copybook expansion with -I and -ffold-copy support); | ||||||
| all other EXEC TAG blocks warn at "unsupported" level | ||||||
| (defaulting to error) and are ignored; add _exec_token_list | ||||||
| to consume body tokens for parsing purposes only | ||||||
|
|
||||||
| 2025-12-29 Roger Bowler <rbowler@snipix.net> | ||||||
|
|
||||||
| * tree.c (finalize_file): if file is EXTFH enabled then don't warn for | ||||||
|
|
||||||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -117,6 +117,7 @@ enum compile_level { | |||||
| #define CB_FLAG_GETOPT_DEPEND_KEEP_MISSING 25 | ||||||
| #define CB_FLAG_GETOPT_DEPEND_ON_THE_SIDE 26 | ||||||
| #define CB_FLAG_GETOPT_GENTABLE 27 | ||||||
| #define CB_FLAG_GETOPT_PREPARSER 28 | ||||||
|
|
||||||
| /* Info display limits */ | ||||||
| #define CB_IMSG_SIZE 24 | ||||||
|
|
@@ -250,6 +251,8 @@ struct cb_text_list *cb_intrinsic_list = NULL; | |||||
| struct cb_text_list *cb_extension_list = NULL; | ||||||
| struct cb_text_list *cb_static_call_list = NULL; | ||||||
| struct cb_text_list *cb_early_exit_list = NULL; | ||||||
| struct cb_preparser_entry *cb_preparser_list = NULL; | ||||||
| struct cb_preparser_entry *cb_active_preparser = NULL; | ||||||
| char **cb_saveargv = NULL; | ||||||
| const char *cob_config_dir = NULL; | ||||||
| FILE *cb_storage_file = NULL; | ||||||
|
|
@@ -617,6 +620,7 @@ static const struct option long_options[] = { | |||||
| {"save-temps", CB_OP_ARG, NULL, '_'}, | ||||||
| {"std", CB_RQ_ARG, NULL, '$'}, | ||||||
| {"conf", CB_RQ_ARG, NULL, '&'}, | ||||||
| {"preparser", CB_RQ_ARG, NULL, CB_FLAG_GETOPT_PREPARSER}, | ||||||
| {"copy", CB_RQ_ARG, NULL, CB_FLAG_GETOPT_COPY_FILE}, | ||||||
| {"include", CB_RQ_ARG, NULL, CB_FLAG_GETOPT_INCLUDE_FILE}, | ||||||
| {"debug", CB_NO_ARG, NULL, 'd'}, | ||||||
|
|
@@ -3118,6 +3122,7 @@ file_replace_extension (const char *file, const char *ext) | |||||
| return cobc_main_stradd_dup (file, ext); | ||||||
| } | ||||||
|
|
||||||
|
|
||||||
| /* process command line options */ | ||||||
| static int | ||||||
| process_command_line (const int argc, char **argv) | ||||||
|
|
@@ -3335,6 +3340,14 @@ process_command_line (const int argc, char **argv) | |||||
| conf_ret |= cb_load_std (ext); | ||||||
| break; | ||||||
|
|
||||||
| case CB_FLAG_GETOPT_PREPARSER: | ||||||
| /* --preparser <name|path> : register external preparser config */ | ||||||
| if (strlen (cob_optarg) > COB_SMALL_MAX) { | ||||||
| cobc_err_exit (COBC_INV_PAR, "--preparser"); | ||||||
| } | ||||||
| conf_ret |= cb_load_preparser_conf (cob_optarg); | ||||||
| break; | ||||||
|
|
||||||
| case '&': | ||||||
| /* -conf=<xx> : Specify dialect configuration file */ | ||||||
| if (strlen (cob_optarg) > COB_SMALL_MAX) { | ||||||
|
|
@@ -3649,11 +3662,13 @@ process_command_line (const int argc, char **argv) | |||||
| /* -Os : Optimize */ | ||||||
| case 'g': | ||||||
| /* -g : Generate C debug code */ | ||||||
| case '$': | ||||||
| /* -std=<xx> : Specify dialect */ | ||||||
| case CB_FLAG_GETOPT_PREPARSER: | ||||||
| /* --preparser : register external preparser config */ | ||||||
| /* These options were all processed in the first getopt-run */ | ||||||
| break; | ||||||
|
Comment on lines
+3669
to
+3670
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
|
||||||
| case '$': | ||||||
| /* -std=<xx> : Specify dialect */ | ||||||
| case '&': | ||||||
| /* -conf=<xx> : Specify dialect configuration file */ | ||||||
| /* These options were all processed in the first getopt-run */ | ||||||
|
|
@@ -5372,7 +5387,8 @@ preprocess (struct filename *fn) | |||||
| const size_t exception_table_size = sizeof (struct cb_exception) * COB_EC_MAX; | ||||||
| int save_source_format, save_fold_copy, save_fold_call, | ||||||
| save_ref_mod_zero_length; | ||||||
|
|
||||||
| struct cb_preparser_entry *p_reset; | ||||||
|
GitMensch marked this conversation as resolved.
|
||||||
| int preparser_pass = 1; | ||||||
| #ifndef COB_INTERNAL_XREF | ||||||
| #ifdef _WIN32 | ||||||
| const char *envname = "%PATH%"; | ||||||
|
|
@@ -5382,6 +5398,7 @@ preprocess (struct filename *fn) | |||||
| int ret; | ||||||
| #endif | ||||||
|
|
||||||
| restart_preprocess: | ||||||
| if (output_name | ||||||
| || cb_compile_level > CB_LEVEL_PREPROCESS | ||||||
| || cb_depend_output_only) { | ||||||
|
|
@@ -5436,6 +5453,7 @@ preprocess (struct filename *fn) | |||||
| save_ref_mod_zero_length = cb_ref_mod_zero_length; | ||||||
|
|
||||||
| /* Preprocess */ | ||||||
| cb_active_preparser = NULL; | ||||||
| ppparse (); | ||||||
|
|
||||||
| /* Restore default exceptions and flags */ | ||||||
|
|
@@ -5460,6 +5478,86 @@ preprocess (struct filename *fn) | |||||
| /* Release flex buffers - After file close */ | ||||||
| plex_call_destroy (); | ||||||
|
|
||||||
| if (cb_active_preparser) { | ||||||
| int ret_sys; | ||||||
|
|
||||||
| /* Build include-path argument string: "-I path1 -I path2 ..." */ | ||||||
| char *include_args = NULL; | ||||||
| { | ||||||
| const struct cb_text_list *il; | ||||||
| size_t inc_len = 0; | ||||||
| /* First pass: compute total length */ | ||||||
| for (il = cb_include_list; il; il = il->next) { | ||||||
| inc_len += 3 + strlen (il->text) + 1; /* "-I " + path + space */ | ||||||
| } | ||||||
| if (inc_len > 0) { | ||||||
| char *p; | ||||||
| include_args = cobc_malloc (inc_len + 1); | ||||||
| p = include_args; | ||||||
| for (il = cb_include_list; il; il = il->next) { | ||||||
| p += sprintf (p, "-I %s ", il->text); | ||||||
| } | ||||||
| /* remove trailing space */ | ||||||
| if (p > include_args) { | ||||||
| *(p - 1) = '\0'; | ||||||
| } | ||||||
| } | ||||||
| } | ||||||
|
|
||||||
| { | ||||||
| const char *inc_str = include_args ? include_args : ""; | ||||||
| const size_t cmd_len = strlen (cb_active_preparser->command) | ||||||
| + strlen (fn->source) + strlen (fn->preprocess) | ||||||
| + strlen (inc_str) + 6; | ||||||
| char *cmd = cobc_malloc (cmd_len); | ||||||
| if (include_args) { | ||||||
| snprintf (cmd, cmd_len, "%s %s %s \"%s\"", | ||||||
| cb_active_preparser->command, | ||||||
| fn->source, fn->preprocess, inc_str); | ||||||
| } else { | ||||||
| snprintf (cmd, cmd_len, "%s %s %s", | ||||||
| cb_active_preparser->command, | ||||||
| fn->source, fn->preprocess); | ||||||
| } | ||||||
|
|
||||||
| ret_sys = call_system (cmd); | ||||||
| cobc_free (cmd); | ||||||
| } | ||||||
| if (include_args) { | ||||||
| cobc_free (include_args); | ||||||
| } | ||||||
|
|
||||||
| if (ret_sys == 0) { | ||||||
| /* success path — generate unique intermediate filename */ | ||||||
| { | ||||||
| char ext_buf[16]; | ||||||
| preparser_pass++; | ||||||
| snprintf (ext_buf, sizeof (ext_buf), ".i%d", preparser_pass); | ||||||
| fn->source = cobc_strdup (fn->preprocess); | ||||||
| fn->preprocess = file_replace_extension ( | ||||||
| (char *)fn->source, ext_buf); | ||||||
| } | ||||||
| if (cb_active_preparser->cflags) { | ||||||
| COBC_ADD_STR (cobc_cflags, " ", cb_active_preparser->cflags, NULL); | ||||||
| } | ||||||
| if (cb_active_preparser->ldflags) { | ||||||
| COBC_ADD_STR (cobc_ldflags, " ", cb_active_preparser->ldflags, NULL); | ||||||
| } | ||||||
| } else { | ||||||
| /* failure path */ | ||||||
| cb_source_file = fn->source; | ||||||
| if (!cb_active_preparser->warn_only) { | ||||||
| cobc_err_exit (_("external preparser '%s' failed with exit status %d"), | ||||||
| cb_active_preparser->subsystem, ret_sys); | ||||||
| } | ||||||
| cb_warning (cb_warn_unsupported, | ||||||
| _("external preparser '%s' failed; falling back to baseline"), | ||||||
| cb_active_preparser->subsystem); | ||||||
| cb_active_preparser->disabled = 1; | ||||||
| } | ||||||
| goto restart_preprocess; | ||||||
| } | ||||||
|
|
||||||
| if (cobc_gen_listing && !cobc_list_file) { | ||||||
| if (unlikely (fclose (cb_listing_file) != 0)) { | ||||||
| cobc_terminate (fn->listing_file); | ||||||
|
|
@@ -5509,7 +5607,10 @@ preprocess (struct filename *fn) | |||||
| #endif | ||||||
| cb_listing_file = NULL; | ||||||
| } | ||||||
|
|
||||||
| /* This prevents trying the same subsystem again for the current file */ | ||||||
| for (p_reset = cb_preparser_list; p_reset; p_reset = p_reset->next) { | ||||||
| p_reset->disabled = 0; | ||||||
| } | ||||||
| output_return (errorcount); | ||||||
| return !!errorcount; | ||||||
| } | ||||||
|
|
||||||
|
GitMensch marked this conversation as resolved.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you want one entry for the baseline (with the old date) and another one for the follow-up work, which then outlines the changes in config.c, tree.h, ...