Skip to content

Instantly share code, notes, and snippets.

@tkob
Created May 3, 2014 13:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tkob/11498077 to your computer and use it in GitHub Desktop.
Save tkob/11498077 to your computer and use it in GitHub Desktop.
set f [open val.txt]
set smlc [lindex $argv 0]
if {$smlc == "smlnj"} {
set prompt "\n- "
set errmsg "Error"
spawn sml
} elseif {$smlc == "poly"} {
set prompt "\n> "
set errmsg "Error"
spawn poly
} elseif {$smlc == "mosml"} {
set prompt "\n- "
set errmsg "!"
spawn mosml -P full
} elseif {$smlc == "smlsharp"} {
set prompt "\n# "
set errmsg "Error"
spawn smlsharp
} elseif {$smlc == "aliceml"} {
set prompt "\n- "
set errmsg "unknown"
spawn alice
} else {
error {check.tcl [smlnj|poly|mosml|smlsharp|aliceml]}
}
set out [open $smlc.txt w]
expect -- $prompt
while {![eof $f]} {
set val [gets $f]
send "$val;\r"
set available 1
expect {
$errmsg {set available 0; exp_continue}
-- $prompt {
if {$available} {
puts $out "yes"
} else {
puts $out "no"
}
}
}
}
send "\004"
expect eof
close $f
close $out
# header
ARGV.each do |file_name|
print file_name.sub(".txt",""), " "
end
puts ""
files = ARGV.map {|file_name| open file_name}
files[1..-1]
.reduce(files[0]) {|result, item| result.zip(item)}
.each do |cols|
cols.flatten.map{|col| col.chomp }.each do |col|
print col, " "
end
puts ""
end
files.each do |file|
file.close()
end
#/bin/bash
cat manpages.txt | while read url; do
wget -nc $url
done
sml_comparison.md: comparison.txt
perl -alne 'print map {"|".$$_} @F; if($$.==1) {print "|---" x @F}' \
< comparison.txt > sml_comparison.md
comparison.txt: smlnj.txt poly.txt mosml.txt smlsharp.txt aliceml.txt
ruby compare.rb val.txt smlnj.txt poly.txt mosml.txt smlsharp.txt aliceml.txt > comparison.txt
smlnj.txt: val.txt
expect -f check.tcl smlnj
poly.txt: val.txt
expect -f check.tcl poly
mosml.txt: val.txt
expect -f check.tcl mosml
smlsharp.txt: val.txt
expect -f check.tcl smlsharp
aliceml.txt: val.txt
expect -f check.tcl aliceml
val.txt: manpages.txt
./gethtml.sh
ruby module.rb > val.txt
manpages.txt:
ruby manpages.rb > manpages.txt
clean:
rm *.html manpages.txt val.txt
rm smlnj.txt poly.txt mosml.txt
require 'uri'
require 'open-uri'
require 'nokogiri'
uri = 'http://www.standardml.org/Basis/manpages.html'
doc = Nokogiri::HTML(open(uri),nil,"utf-8")
doc.xpath("//h4/a").each do |link|
if link.text =~ / (\w+) (structure|functor|signature)/ then
puts URI.join(uri, link["href"])
end
end
require 'nokogiri'
done = {}
Dir.glob('*.html').sort.each do |filename|
doc = Nokogiri::HTML(open(filename),nil,"utf-8")
links = doc.xpath("//a")
str_names = links.flat_map do |link|
if link["name"] =~ /((\w|\{N\})+):STR:SPEC$/
name = $1
["16", "31", "32", "63", "64"].map {|n| name.sub(/\{N\}/, n)}
elsif link["name"] =~ /(\w+):STR:SPEC$/
[$1]
else
[]
end
end
str_names.each do |str_name|
if not done[str_name]
links.each do |link|
if link["name"] =~ /\.(\w+):VAL:SPEC$/
puts "#{str_name}.#{$1}"
end
end
done[str_name] = true
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment