home: hub: minipeg

ref: 487c2a6e18f22dbd8a43aa150db10b19529848eb
dir: /examples/localleg.leg/

View raw version
%{
#define YY_CTX_LOCAL 1
#define YY_CTX_MEMBERS \
  int count;
%}

Char	= ('\n' | '\r\n' | '\r')	{ yy->count++ }
	| .

%%

#include <stdio.h>
#include <string.h>

int main()
{
    yycontext yy;
    memset(&yy, 0, sizeof(yy));
    while (yyparse(&yy))
	;
    printf("%d newlines\n", yy.count);
    yyrelease(&yy);
    return 0;
}