Tencent/matrix · error
Exactly one filename argument is required.
Error message
Exactly one filename argument is required.
What it means
After parsing command-line options via OptInit(), lemon requires exactly one non-option argument: the path to the grammar (.y) file. If OptNArgs() != 1 it prints 'Exactly one filename argument is required.' to stderr and exits with status 1. This is input validation of the command line, not a memory error.
Solutions
- Invoke lemon with exactly one grammar file: lemon parse.y.
- Check build scripts/Makefiles for variables expanding to multiple filenames; quote or restrict them.
- Use lemon -h / read usage output to confirm option syntax (e.g. -d takes a directory as part of the same token).
- Ensure every flag has its expected value so no intended filename is consumed as an option argument.
- Filter the file list in the build recipe down to the single grammar before calling lemon.
Example fix
// before (Makefile) lemon $(YACC_FILES) // after (Makefile) lemon $(GRAMMAR_FILE) # GRAMMAR_FILE must expand to exactly one .y file
Defensive patterns
Strategy: validation
Validate before calling
# shell: verify exactly one grammar file before calling lemon
files=$(ls *.y 2>/dev/null | wc -l)
[ "$files" -eq 1 ] || { echo "need exactly one .y grammar file, found $files"; exit 1; }
lemon "$1" Try / catch
// wrapper in C or shell checking lemon's exit code 1 and its stderr message if ! lemon "$GRAMMAR"; then echo "lemon failed; check that exactly one grammar file was passed" >&2 fi
Prevention
- Always pass exactly one .y file; never glob multiple grammars in one lemon invocation
- Quote variables in build scripts so expansion can't add extra positional args
- Verify option syntax with lemon -h (e.g. -d dir attaches to the flag, not a positional)
- Assert file count in Makefile/CMake custom commands before invoking lemon
When it happens
Trigger: Invoking lemon with zero grammar files (e.g. 'lemon -d.'), or with two or more file arguments (e.g. 'lemon a.y b.y'), so OptNArgs() returns anything other than 1 at lemon.c:1422 in main().
Common situations: Build systems quoting variables that expand to multiple files; accidentally passing both a .y and a .lemon or output filename; forgetting the grammar file entirely; typo'd flags swallowing or adding positional args (e.g. an option missing its value).
Understand the failure class
Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.
Related errors
- Unable to allocate memory for a new parser action.
- Unable to allocate memory for a new acttab.
- malloc failed
- Unable to allocate memory for a new configuration.
- Out of memory. Aborting...
AI-assisted analysis of Tencent/matrix@3b8293bd65 (2026-09-08).
Data as JSON: /api/errors/6293cd0704935e0f.
Report an issue: GitHub.
Appendix: source
Thrown at matrix/matrix-android/matrix-sqlite-lint/src/lemon/lemon-gen/lemon.c:1422
{OPT_FSTR, "D", (char*)handle_D_option, "Define an %ifdef macro."},
{OPT_FLAG, "g", (char*)&rpflag, "Print grammar without actions."},
{OPT_FLAG, "m", (char*)&mhflag, "Output a makeheaders compatible file"},
{OPT_FLAG, "q", (char*)&quiet, "(Quiet) Don't print the report file."},
{OPT_FLAG, "s", (char*)&statistics,
"Print parser stats to standard output."},
{OPT_FLAG, "x", (char*)&version, "Print the version number."},
{OPT_FLAG,0,0,0}
};
int i;
struct lemon lem;
OptInit(argv,options,stderr);
if( version ){
printf("Lemon version 1.0\n");
exit(0);
}
if( OptNArgs()!=1 ){
fprintf(stderr,"Exactly one filename argument is required.\n");
exit(1);
}
lem.errorcnt = 0;
/* Initialize the machine */
Strsafe_init();
Symbol_init();
State_init();
lem.argv0 = argv[0];
lem.filename = OptArg(0);
lem.basisflag = basisflag;
lem.has_fallback = 0;
lem.nconflict = 0;
lem.name = lem.include = lem.arg = lem.tokentype = lem.start = 0;
lem.vartype = 0;
lem.stacksize = 0;
lem.error = lem.overflow = lem.failure = lem.accept = lem.tokendest =
lem.tokenprefix = lem.outname = lem.extracode = 0;View on GitHub (pinned to 3b8293bd65)