%parser %symbol file { public int nlines,nchars; public bool trunc; public file(int nl,int nc,bool tr) { nlines=nl; nchars=nc; trunc=tr; } } %start file file : lastline %file(0,0,($1>0)) | line file %file($2.nlines+1,$2.nchars+$1,$2.trunc); line : EOL { $$ = 0; } | TXT line { $$ = $2+1; } ; lastline : EOF { $$ = 0; } | TXT lastline { $$ = $2+1; } ;