Skip to content

Enable key=value long options in OPT - #23

Open
epi wants to merge 1 commit into
pfusik:masterfrom
epi:epi/longopt
Open

epi wants to merge 1 commit into
pfusik:masterfrom
epi:epi/longopt

Conversation

@epi

@epi epi commented Sep 22, 2026

Copy link
Copy Markdown
Contributor

Prerequisite for stuff like opt 'cpu=65c02' (#16) or opt 'format=sdx' (#17).

@pfusik pfusik left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

We don't have to provide long aliases to all the short options right away. The long options should serve future expansions not 1:1 mapping of short options.

The obvious ones are listing=on, listing=off, cpu=65c02, cpu=6502.

Comment thread source/xasm/package.d Outdated
break;
case "HARDWARE":
switch (optionValue(name, hasValue, value)) {
case "A800":

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Suggested change
case "A800":
case "ATARI800":

Comment thread source/xasm/package.d Outdated
case "A800":
optionHardware = Hardware.a800;
break;
case "A5200":

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Suggested change
case "A5200":
case "ATARI5200":

Comment thread source/xasm/package.d Outdated

void setNamedOption(string name, bool hasValue, string value) {
switch (name) {
case "FILL":

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

How about combining three short options into one long:

 opt o-     = opt 'output=off'
 opt o+h-f- = opt 'output=raw'
 opt o+h-f+ = opt 'output=rom'
 opt o+h+f- = opt 'output=ataridos' ; default
 opt o+h+f+ ; not useful, no long alias

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Looks good. I'd add a few restrictions:

  • setting output is an error after anything has been emitted to object,
  • setting output twice is an error,
  • setting o, h, or f after output has been set explicitly is an error.

Without output, the single-letter options o, h and f work as previously.

@epi epi Sep 24, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Maybe the above are too restrictive – one may want to get label table and/or listing without the object bytes, and opt 'output=spartadosx'; opt o- would be a quite self-descriptive way to spell it, even if not the most elegant.

Currently o- is allowed even mid-block, which I consider a bug because it generates broken binaries. Not sure if there's any code out there that depends on it.

I'd disallow opt o- completely after the first object byte is emitted, unless there is a good reason to keep it allowed between blocks.

@epi epi Sep 24, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It may also make sense to get o out of output (so the latter would only set h and f), and provide 'object=on|off' so that it can be set in one opt with output.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Ignore the last two comments. I don't think there's a use case for o- after output=....

Comment thread source/xasm/package.d Outdated
case "OBJECT":
optionObject = optionBool(name, hasValue, value);
break;
case "UNUSED-LABELS":

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

opt 'warn=unused'

?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Not bad, but:

  • unused alone seems a bit confusing, especially if at some point we find out that it's useful to warn about unused something else.
  • How do we toggle various warnings independently?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Example:

opt 'warn_unused_labels=on,warn_cross_page_branch=off' – it's clear which warnings are toggled, and that all others aren't.

opt 'warn=unused_labels' – does it only enable warning on unused labels? Or does it enable this one and disable everything else? How to disable the warning? no_warn=unused_labels? warn=no_unused_labels? Unintuitive.

Comment thread source/xasm/package.d Outdated

bool optionBool(string name, bool hasValue, string value) {
if (!hasValue)
return true;

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

I don't feel this syntax sugar is any good.

Comment thread source/xasm/package.d Outdated
assert(0);
}

string readOptionName() {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Can we extract [0-9A-Za-z_?]+ lexing from readLabel, returning an uppercased string, and reuse it for option names and values?

@epi
epi requested a review from pfusik September 24, 2026 15:09
@epi epi mentioned this pull request Sep 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants