1
|
1 #!/usr/bin/env ruby
|
|
2 # coding: utf-8
|
|
3
|
|
4 Suffix = '.agda.replaced'
|
|
5 EscapeChar = '!'
|
|
6 FileName = ARGV.first
|
|
7
|
|
8 ReplaceTable = {
|
|
9 '→' => 'rightarrow',
|
|
10 '->' => 'rightarrow',
|
|
11 '⊔' => 'sqcup',
|
|
12 '∷' => 'text{::}',
|
|
13 '∙' => 'circ',
|
|
14 '≡' => 'equiv',
|
|
15 '×' => 'times',
|
|
16 '⟨' => 'langle',
|
|
17 '⟩' => 'rangle',
|
|
18 'ℕ' => 'mathbb{N}',
|
|
19 '₁' => '_{1}',
|
|
20 '₂' => '_{2}',
|
|
21 '₃' => '_{3}',
|
|
22 '∎' => 'blacksquare',
|
|
23 'λ' => 'lambda',
|
|
24 '∧' => 'wedge',
|
|
25 '/\\' => 'wedge',
|
|
26 '⇒' => 'Rightarrow',
|
|
27 '¬' => 'neg',
|
|
28 '≤' => 'leq',
|
|
29 '⊥' => 'bot',
|
|
30 '∀' => 'forall',
|
|
31 '#' => '\#',
|
|
32 '⊤' => '\top',
|
|
33 '\'' => '\prime',
|
|
34 '≈' => '\approx'
|
|
35 }
|
|
36
|
|
37 code = File.read(FileName)
|
|
38 ReplaceTable.each do |k, v|
|
|
39 escaped_str = EscapeChar + "$\\#{v}$" + EscapeChar
|
|
40 code = code.gsub(k, escaped_str)
|
|
41 end
|
|
42
|
|
43 File.write(FileName.sub(/.agda$/, Suffix), code)
|