Skip to content

hrw4u: grammar accepts bare operator statements (no-op;) that can never compile #13701

Description

@masaori335

Summary

The grammar has a statement alternative for a bare operator without parentheses:

| op=IDENT SEMICOLON

Nothing written that way compiles. Every op is rejected, so the alternative is
unreachable and should be removed from the grammar.

Reproduce

source result
no-op(); no-op
no-op; error: This operator requires an argument
skip-remap;, set-debug; same error

Why remove rather than fix

The call form is the only form anything produces or documents:

producer form
doc/admin-guide/configuration/hrw4u.en.rst no-op();, set-debug(), skip-remap()
reverse conversion, u4wrh (src/hrw_symbols.py:315) always name()
test corpus (tests/data) no-op();, 0 bare-op inputs

Making the bare form work instead (check arity rather than validator presence)
would add a second spelling for the same statement with no caller asking for
it. break; is a separate alternative and is unaffected either way.

Trade-off: after removal, no-op; becomes an ANTLR syntax error rather than a
named one. If the friendlier message matters, it belongs in the suggestion
engine, not in a grammar alternative that produces no output.

Note

test_the_corpus_reaches_every_grammar_rule does not catch this: it records
rule names, and statement is reached through its other alternatives.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions