#!/usr/bin/perl -s our ($s,$n,$p,$debug,$chk_ambigous); use strict; use warnings; use Parse::GrammarCompare; use Data::Dumper; use utf8::all; my $warn=0; $chk_ambigous||=0; my $file=shift or die("usage $0 gram\n"); die("Cant find $file\n") unless -f $file; my $g =parsepg($file); local $SIG{__WARN__}=sub{ my $m=shift; $warn++; }; my($flex,$bison)= g2bison($g,{chk_ambigous=>$chk_ambigous}); open(L,">","_.fl"); print L qq{ %{ #include %} %option noyywrap $flex; }; close(L); open(B,">","_.y"); print B qq{ %{ #include int yylex(); void yyerror(const char* s); %} %glr-parser $bison #include "lex.yy.c" int main(){ int i=yyparse(); // printf("ok\\n"); } void yyerror(const char *s) { // printf("not ok\\t"); // fprintf(stderr,"(linha %d):near '%s' - %s\\n",yylineno, yytext,s); // exit(1); } }; close(L); __DATA__