summaryrefslogtreecommitdiff
path: root/orig/pq-web/pas2js.sed
blob: 12e812ae1c1c2ff3c1e71d58106963930067ce70 (plain)
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
#!/usr/bin/sed -f

# Convert Pascal syntax to Javascript

s,{,/*,g
s,},*/,g
s/ = / == /g
s/:=/=/g
s/procedure/function/g
s/begin/{/
s/end;/}/g
s/end/}/g

s/not/!/g
s/ and / \&\& /g
s/ or / || /g
s/<>/!=/g
s/ mod / % /g

s/if /if (/g
s/ then/)/g

s/while /while (/g
s/for /for (/g
s/with /with (/g
s/ do/)/

s/case /switch (/g
/\Wcase\W/ s/ of/) {/g

s/Result =/return/g

/^function / s/): [A-Za-z][A-Za-z]*;/)/ 
/^function /  s/: [A-Za-z][A-Za-z]*;/()/
#/^function / s/: [A-Za-z][A-Za-z]*//g

/\Wfor\W/ s/ to /; i <= /
/\Wfor\W/ s/)/; ++i)/