#!/usr/bin/perl $verbose = 0; $usage = "$0 \n"; $fsa = shift or die $usage; $syms = shift or die $usage; open(F, $syms) or die $usage; while () { chomp; ($sym, $id) = split(/\s+/, $_); $symtbl{$sym} = $id; } close(F); print STDERR "read $syms\n" if ($verbose); $input = ; @inputlist = split(/\s+/, $input); $s = 0; open(T, ">/tmp/$$.txt") or die "could not open /tmp/$$.txt\n"; foreach $inp (@inputlist) { printf T "%d\t%d\t%s\n", $s, $s+1, $symtbl{$inp}; $s++; } printf T "%d\n", $s; close(T); system("fsmcompile /tmp/$$.txt > /tmp/$$.fsa"); system("fsmintersect $fsa /tmp/$$.fsa | fsmprint > /tmp/$$.result"); if (-z "/tmp/$$.result") { print "not accepted\n"; } else { print "accepted\n"; } unlink("/tmp/$$.txt", "/tmp/$$.fsa", "/tmp/$$.result"); 1;