File: fsm2dav.pl

package info (click to toggle)
tcng 10b-2
  • links: PTS, VCS
  • area: main
  • in suites: lenny
  • size: 3,636 kB
  • ctags: 2,515
  • sloc: ansic: 19,040; pascal: 4,640; yacc: 2,619; sh: 1,914; perl: 1,546; lex: 772; makefile: 756
file content (44 lines) | stat: -rwxr-xr-x 1,319 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/usr/bin/perl
#
# fsm2dav.pl - Convert "raw" FSM output to daVinci term representation
#
# Written 2001 by Werner Almesberger
# Copyright 2001 Network Robots
#
# "Free" daVinci 2.1 can be found at
# http://www.tzi.de/daVinci/daVinci_get_daVinci.html

print "[\n";
$first = 1;
while (<>) {
    chop;
    if (/^(\d+): data (\d+) (\d+) (\d+) (\d+)/) {
	print ",\n" unless $first;
	print "l(\"S$1\",n(\"\",[a(\"OBJECT\",\"$2:$3\")],[\n";
	print "  l(\"E$1T\",e(\"\",[a(\"HEAD\",\"farrow\")],r(\"S$4\"))),\n";
	print "  l(\"E$1F\",e(\"\",[a(\"HEAD\",\"arrow\")],r(\"S$5\")))\n";
	print "  ]))";
    }
    elsif (/^(\d+): conform (\d+) (\d+) (\d+)/) {
	print ",\n" unless $first;
	print "l(\"S$1\",n(\"\",[a(\"OBJECT\",\"conform $2\")],[\n";
	print "  l(\"E$1T\",e(\"\",[a(\"HEAD\",\"farrow\")],r(\"S$3\"))),\n";
	print "  l(\"E$1F\",e(\"\",[a(\"HEAD\",\"arrow\")],r(\"S$4\")))\n";
	print "  ]))";
    }
    elsif (/^(\d+): count (\d+) (\d+)/) {
	print ",\n" unless $first;
	print "l(\"S$1\",n(\"\",[a(\"OBJECT\",\"count $2\")],[\n";
	print "  l(\"E$1T\",e(\"\",[a(\"HEAD\",\"farrow\")],r(\"S$3\")))\n";
	print "  ]))";
    }
    elsif (/^(\d+): <(.*)>/) {
	print ",\n" unless $first;
	print "l(\"S$1\",n(\"\",[a(\"OBJECT\",\"$2\")],[]))";
    }
    else {
	die "unrecognized input";
    }
    $first = 0;
}
print "\n]\n";