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

String comparison would be quite handy #51

Open
MartinHelmut opened this issue Aug 14, 2021 · 0 comments
Open

String comparison would be quite handy #51

MartinHelmut opened this issue Aug 14, 2021 · 0 comments
Labels
enhancement Improve on an existing feature. feature Something new.
Milestone

Comments

@MartinHelmut
Copy link
Member

MartinHelmut commented Aug 14, 2021

Currently there is no easy way to compare in a script against a string value passed by parameter. This would be quite handy though, and there are different ways to tackle this. What this would enable is getting rid of parameters currently used like release, profile or debug, as they could be dependent on the actual build target.

Option 1

One would be adding a comparison operator to the script syntax, that could look like this:

script = "%{target == 'release' 'do this' or 'do that'}"

This would mean introducing a new == operator. BNF would be:

# Entry point:
script = statement | expression

statement = or_statement | if_statement;

expression = comparison
  | function
  | variable
  | literal;

comparison = expression "==" expression

literal = string;
string = "'" .* "'";

or_statement = if_statement "or" expression;

if_statement = expression expression;

function = function_name "(" (expression ("," expression)*)? ")";
function_name = alpha (alpha | digit)*;

variable = short_variable | long_variable;
short_variable = strict_alpha;
long_variable = strict_alpha (alpha | digit)+;

digit = 0-9;
alpha = A-Za-z_;
strict_alpha = A-Za-z;

Option 2

After implementing #24 there could be a equal(first, second) function serving this. This would look like this:

script = "%{equal(target, 'release') 'do this' or 'do that'}"
@MartinHelmut MartinHelmut added feature Something new. enhancement Improve on an existing feature. labels Aug 14, 2021
@MartinHelmut MartinHelmut added this to the Version 1 milestone Aug 14, 2021
@MartinHelmut MartinHelmut modified the milestones: Version 1, MVP Jun 23, 2022
@MartinHelmut MartinHelmut modified the milestones: MVP, Version 1 Aug 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Improve on an existing feature. feature Something new.
Projects
None yet
Development

No branches or pull requests

1 participant