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 support for new #Include file delimiters, linked to search order #29

Open
duncanmac99 opened this issue Sep 15, 2018 · 1 comment
Open

Comments

@duncanmac99
Copy link

duncanmac99 commented Sep 15, 2018

The suggestion here is to add support for a custom set of delimiters, such as "#include [file]", or "#include (file)". The advantage is that the choice of delimiter can be used to tell the pre-processor which directory/ies to search first -- or search only.

By default, one sets up a list of possible delimiters, say " '()', '[]', '{}', '^^', '%%' ". These delimiters would only be enabled if the new option '+Ksym' ( where 'sym' is one of '([{^%' ) appears on the command line. This becomes significant when one relates to where the new option appears with regard to the '-I' option(s). If the '+Ksym' option appears just before a particular '-I' directory, searches for any file using that delimiter should start with ^that^ directory and proceed from there. However, if the user adds a '-Ksym' option referencing the ^same^ symbol after at least one more '-I' option has been specified, then search for files surrounded with "sym" should be confined to only that directory/ies.

For example, the command-line "... -I 'path1' +K '[' -I 'path2' -I 'path3' ..." would instruct the pre-processor to start searching for any file named as "#include [file]" at directory 'path2', then proceed down the list to the system directory/ies, then (optionally) cause a "wrap-around" to search the previous directories as well.

However, the command-line "... -I 'path1' +K '[' -I 'path2' -I 'path3' -K '[' -I 'path4' ..." would tell the pre-processor to search ^only^ the directories 'path2' and 'path3' for any file named as "#include [file]".

If the option '+Ksym' does not appear for a given 'sym', then any reference to a #include with the delimiter 'sym' should cause a warning message and the delimiters to be Ignored. Thus, with the command-lines above, a reference to "#include {file}" should cause a warning diagnostic. The files affected can then be searched for using the default "" delimiter rules. It is likely that only one pair of '+Ksym' ... '-Ksym' arguments should be allowed for any given 'sym', but that can be relaxed if it is desired. The presence of '-Ksym' without a preceding '+Ksym' should then be viewed as a Fatal Error, as would the appearance of '-Ksym' without at least one -I directory just before it (i.e. without at least one such -I argument between '+Ksym' and the following '-Ksym').

@duncanmac99
Copy link
Author

duncanmac99 commented Sep 17, 2018

In the existing system, it is legal to specify "#include file", with no delimiters at all. One can add the command-line option '-Kr' to forbid that; if that appeared on the command-line, a declaration in that form would cause a diagnostic (and the file would be Ignored, and not Included).

If this is done, then "wrapping around" the list of files probably should be the default. But one could add '-Kw' to prevent such wrap-around, or '+Kw' to enable it again. If '-Kw' appears before a '+Ksym', then inhibit wrap-around for that "sym", and vice-versa.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants