Tencent/matrix · error
Can't find the parser driver template file
Error message
Can't find the parser driver template file "%s".
What it means
Lemon locates its parser driver template (lempar.c) by checking -T paths, the current directory, or via pathsearch against argv0. If no readable copy is found, it prints 'Can't find the parser driver template file "lempar.c".', increments errorcnt and aborts generation.
Solutions
- Pass the template explicitly: lemon -T /path/to/lempar.c grammar.y
- Copy lempar.c into the directory where you invoke lemon
- Ensure lempar.c sits in the same directory as the lemon binary (pathsearch target)
- Fix the -T argument spelling/permissions (file must be readable, access(004))
Example fix
// before lemon parser.y // after lemon -T src/lemon-gen/lempar.c parser.y
Defensive patterns
Strategy: validation
Validate before calling
#!/bin/sh
TPL=${LEMON_TEMPLATE:-$(dirname "$0")/lempar.c}
if [ ! -r "$TPL" ]; then echo "template missing: $TPL"; exit 1; fi
lemon -T "$TPL" parser.y Prevention
- Always pass -T with an absolute path to lempar.c
- Package lempar.c together with the lemon binary in build images
- Verify template presence in CI setup steps
- Run lemon from the repo's lemon-gen directory if relying on relative lookup
When it happens
Trigger: Running lemon without a -T flag where lempar.c is not in the current directory nor next to the lemon executable; the -T argument names a template that fails the access(READ) check; lempar.c deleted from the installed toolchain directory.
Common situations: Installing/copying the lemon binary without shipping lempar.c alongside; running lemon from a different working directory (relative lookup fails); packaging matrix-sqlite-lint's build in a container without the lemon-gen template files; misspelled -T path.
Understand the failure class
Background: "File not found" and ENOENT errors: why libraries can't find a file that should exist — this error's family across 50 libraries.
Related errors
- Need zipalign apk but $pathOfZipAlign is not exist!
- Empty grammar.
- Can't open the template file
- ---APK-UNZIP-PATH ' ' is not exist!
- ---APK-UNZIP-PATH ' ' is not exist!
AI-assisted analysis of Tencent/matrix@3b8293bd65 (2026-09-08).
Data as JSON: /api/errors/30e3a084f88db760.
Report an issue: GitHub.
Appendix: source
Thrown at matrix/matrix-android/matrix-sqlite-lint/src/lemon/lemon-gen/lemon.c:3003
FILE *in;
char *tpltname;
char *cp;
cp = strrchr(lemp->filename,'.');
if( cp ){
sprintf(buf,"%.*s.lt",(int)(cp-lemp->filename),lemp->filename);
}else{
sprintf(buf,"%s.lt",lemp->filename);
}
if( access(buf,004)==0 ){
tpltname = buf;
}else if( access(templatename,004)==0 ){
tpltname = templatename;
}else{
tpltname = pathsearch(lemp->argv0,templatename,0);
}
if( tpltname==0 ){
fprintf(stderr,"Can't find the parser driver template file \"%s\".\n",
templatename);
lemp->errorcnt++;
return 0;
}
in = fopen(tpltname,"rb");
if( in==0 ){
fprintf(stderr,"Can't open the template file \"%s\".\n",templatename);
lemp->errorcnt++;
return 0;
}
return in;
}
/* Print a #line directive line to the output file. */
PRIVATE void tplt_linedir(out,lineno,filename)
FILE *out;
int lineno;
char *filename;View on GitHub (pinned to 3b8293bd65)