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 '#cmdline "args..."' directive #341
Merged
Merged
Conversation
This file contains 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
…ithin source files - refactor parseArgsFromFile() and add parseArgsFromString() - #cmdline "args..." will invoke parseArgsFromString( "args..." )
…mmit - fbc.bas, pp-cond.bas, pp.bas, pp.bi
…with cmdlineOptionTB() - cmdlineOptionTB() has type of FB_CMDLINE_OPTION type FBC_CMDLINE_OPTION takes_argument as boolean '' true = option requires argument allowed_in_source as boolean '' true = can be used with #cmdline directive restart_required as boolean '' true = restart of parser is required when used with #cmdline directive end type - WIP: initially set 'allowed_in_source' to FALSE for all options - WIP: initially set 'restart_required' to FALSE for all options
- rename parseArgsFromString() to fbcParseArgsFromString(), it's a public re-entry point in to fbc main module - add is_source and is_file parameters to handleArg() - add is_source and is_file parameters to fbcParseArgsFromString() - add is_source parameter parseArgsFromFile()
…ives - allows overriding source directives with real fbc command line
- track the module count and only process #cmdline directives in the first module - modules other than the first will ignore #cmdline directives with a warning - add #cmdline "-end" to trigger a restart of the parser - fbc doesn't know how to detect the end of all #cmdline directives to automatically trigger a restart
- #cmdline "-end" will trigger a restart of the parser - remaining !!!TODO!!!'s should only be for special cases and major restarts - error if #cmdline is used anywhere but module level
…restart count - add 'enum FB_RESTART_FLAGS' to track restart requests and restart history - FB_RESTART_FLAGS tracks if the restart is due to #cmdline or #lang - fbInit() expects a FB_RESTART_FLAGS argument instead of restart counts - in cmdlineOptionTB() add a member to indicate if fbc needs to be restarted for each option which would be the case for some options that need to be initialized even before the parser (currently not used)
- if #cmdline "-end" was never given, then detect that a restart is required at the end of parsing the source - change the warning level for ignored #cmdline's - by default not shown but will show with '-w all'
- rename the 'restart' procedures - declare sub fbRestartBeginRequest( byval flags as FB_RESTART_FLAGS ) - declare sub fbRestartAcceptRequest( byval flags as FB_RESTART_FLAGS ) - declare sub fbRestartCloseRequest( byval flags as FB_RESTART_FLAGS ) This should provide a readable sequence for restarting the parser or fbc: - Begin / Accept / Close - the underlying state for request/action/status to be updated through this interface
- all command line options are allowed with #cmdline except '-help' and '-print' - not all options have been tested with #cmdline in a real test - added #cmdline "-restart" just in case #cmdline "-end" gives troubles - #cmdline "-end" will restart the parser or fbc if needed - #cmdline "-restart" will always restart fbc with the new command line options
- github freebasic#341: fbc: #cmdline "args..." directive to specify command line arguments within source files, restarting the parser from some options - github freebasic#341: fbc: #cmdline "-end" will trigger a parser or fbc restart if needed. fbc can't detect the end of reading all the #cmdlines to do this automatically - github freebasic#341: fbc: #cmdline "-restart" will always trigger an fbc restart - github freebasic#341: fbc: only process #cmdline in the first source module (which must be specified on the real command line) - github freebasic#341: fbc: add '-z nocmdline' command line option to ignore #cmdline directives - allows overriding source directives with real fbc command line
Merged
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This update adds a
#cmdline
directive to allow specifying command line arguments in the freebasic source file.#cmdline
directives are processed from the first source module only. (The reason I did it this way is command line options are global and affect all source modules. fbc does not support per-module command line options and that kind of feature would be better done with#pragma
's some other time).For example:
All command line arguments are allowed except for
-print
and-help
. Most arguments have been tested. There are no added tests in the test suite. Not well tested are interactions between#lang
and-pp
processing.How it works:
.bas
) is parsed as usual.#cmdline
directives are processed, then fbc will restart the parser or fbc depending on what arguments were given.#cmdline "-mt"
#cmdline "-gen gcc"
#cmdline "-target win64"
fbc has no clever way of knowing that all the
#cmdline
directives are processed, or a point when none should be allowed.#cmdline "-end"
will trigger a restart if needed to merge in the given command line arguments`#cmdline "-restart" will always trigger an fbc restart
#cmdline
directives are only processd in the first source module and ignored after restart and ignored in other modules.Compiling with warning
-w all
will show all locations of ignore#cmdline
directives.To take full control from the real command line and ignore all
#cmdline
directives even in the first source module$ fbc source.bas -z nocmdline
will disable
#cmdline
processing