-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathxdkconv.oz
74 lines (70 loc) · 2.25 KB
/
xdkconv.oz
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
%% Copyright 2001-2011
%% by Ralph Debusmann <[email protected]> (Saarland University) and
%% Denys Duchier <[email protected]> (LIFO, Orleans) and
%% Jorge Marques Pelizzoni <[email protected]> (ICMC, Sao Paulo) and
%% Jochen Setz <[email protected]> (Saarland University)
%%
functor
import
Application(exit getArgs)
Property(get)
System(showError showInfo printInfo show)
Helpers(e2V) at 'Helpers.ozf'
Converter(convert) at 'Compiler/Converter.ozf'
define
AArgRec =
{Application.getArgs
record(help(single type:bool char:&h default:false)
grammar(single type:string char:&g default:"")
output(single type:string char:&o default:"")
debug(single type:bool char:&d default:false)
)}
%% help
if AArgRec.help then
{System.showError
'*XDG Development Kit (XDK): Grammar file converter*\n'#
'--(no)help display this help\n'#
' -h\n'#
'--grammar File source grammar file\n'#
' -g (e.g. -g Acl01.ul\n'#
' default: "")\n'#
'--output File destination grammar file\n'#
' -o (e.g. -o Acl01.xml\n'#
' default: "")\n'#
'--(no)debug toggle debug mode\n'#
' -d (default: nodebug)'
}
{Application.exit 1}
end
%% grammar
FromS = AArgRec.grammar
%% output
ToS = AArgRec.output
%% debug
DebugB = AArgRec.debug
%% get off the ground
if FromS=="" then
{System.showError 'No source grammar file.'}
{Application.exit 1}
end
if ToS=="" then
{System.showError 'No destination grammar file.'}
{Application.exit 1}
end
try
{System.printInfo 'Converting grammar file "'#FromS#'" to "'#ToS#'"... '}
I1 = {Property.get 'time.total'}
{Converter.convert FromS ToS proc {$ X} skip end}
I2 = {Property.get 'time.total'}
I = I2-I1
in
{System.showInfo 'done. ('#I#'ms)'}
catch E then
V = {Helpers.e2V E}
in
{System.showError '\n'#V}
if DebugB orelse V=='unhandled error' then {System.show E} end
end
in
{Application.exit 0}
end