#!/usr/bin/perl -s our ($q,$s,$n,$p,$debug,$axiom,$outsep); use strict; use warnings; use Parse::GrammarCompare; use Data::Dumper; use utf8::all; $q //= 1; $s //=' '; my $d = 1; $d=0 if $n; my $sep="\n"; $sep = "§\n" if $outsep; my $warn=0; my $file=shift or die("usage $0 [-q=...] gram\n"); die("cant find $file\n") unless -f $file; my $g =parsepg($file); local $SIG{__WARN__}=sub{ my $m=shift; $warn++; }; print Dumper($g) if $debug; if($p){ for(1..$q){ sgen(($axiom?($axiom):()),$g,{sep=>$s,dyn=>$d}); print "$sep" } } else { for(1..$q){ print(sgenstr(($axiom?($axiom):()),$g,{sep=>$s,dyn=>$d}),"$sep")} } print("and $warn Deep!\n") if $warn; __END__ =encoding utf8 =head1 NAME gen-from-gram - generates random sentences from a (prob.) grammar =head1 SYNOPSIS gen-from-gram [options] f.gram -q=5 gen 5 sentences (def=1) -s=',' token separator = ',' (def=' ') -n no dynamic tokens -outsep terminate exemples with "§\n" =head1 DESCRIPTION =head1 grammar format =head1 AUTHOR J.Joao Almeida, jj@di.uminho.pt =head1 SEE ALSO perl(1). =cut