-
Notifications
You must be signed in to change notification settings - Fork 5
/
commands.cpp
3737 lines (2878 loc) · 80.8 KB
/
commands.cpp
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
This is commands.cpp
Coxeter version 3.0 Copyright (C) 2002 Fokko du Cloux
See file main.cpp for full copyright notice
*/
#include "commands.h"
#include "directories.h"
#include "error.h"
#include "fcoxgroup.h"
#include "help.h"
#include "interactive.h"
#include "special.h"
#include "typeA.h"
namespace commands {
using namespace directories;
using namespace error;
using namespace fcoxgroup;
using namespace help;
using namespace interactive;
};
namespace {
using namespace commands;
using namespace stack;
bool wgraph_warning = true;
/* used in the definition of command trees */
struct Empty_tag {};
struct Interface_tag {};
struct Main_tag {};
struct Uneq_tag {};
Stack<CommandTree *> treeStack;
CoxGroup* W = 0;
void activate(CommandTree* tree);
void ambigAction(CommandTree* tree, const String& str);
CommandData* ambigCommand();
void cellCompletion(DictCell<CommandData>* cell);
void commandCompletion(DictCell<CommandData>* cell);
void empty_error(char* str);
CommandTree* emptyCommandTree();
template<class C> CommandTree* initCommandTree();
void printCommandTree(FILE* file, DictCell<CommandData>* cell);
void startup();
void interface_entry();
void interface_exit();
void main_entry();
void main_exit();
void uneq_entry();
void uneq_exit();
void author_f();
void betti_f();
void coatoms_f();
void compute_f();
void descent_f();
void duflo_f();
void extremals_f();
void fullcontext_f();
void help_f();
void ihbetti_f();
void inorder_f();
void interface_f();
void interval_f();
void invpol_f();
void klbasis_f();
void lcorder_f();
void lcells_f();
void lcwgraphs_f();
void lrcorder_f();
void lrcells_f();
void lrcwgraphs_f();
void lrwgraph_f();
void lwgraph_f();
void matrix_f();
void mu_f();
void not_implemented_f();
void pol_f();
void q_f();
void qq_f();
void rank_f();
void rcorder_f();
void rcells_f();
void rcwgraphs_f();
void rwgraph_f();
void schubert_f();
void show_f();
void showmu_f();
void slocus_f();
void sstratification_f();
void type_f();
void uneq_f();
const char* author_tag = "prints a message about the author";
const char* betti_tag = "prints the ordinary betti numbers";
const char* coatoms_tag = "prints out the coatoms of an element";
const char* compute_tag = "prints out the normal form of an element";
const char* descent_tag = "prints out the descent sets";
const char* duflo_tag = "prints out the Duflo involutions";
const char* extremals_tag =
"prints out the k-l polynomials for the extremal pairs";
const char* fullcontext_tag = "sets the context to the full group";
const char* help_tag = "enters help mode";
const char* ihbetti_tag = "prints the IH betti numbers";
const char* input_tag = "(in help mode only) explains the input conventions";
const char* interface_tag = "changes the interface";
const char* interval_tag = "prints an interval in the Bruhat ordering";
const char* intro_tag =
"(in help mode only) prints a message for first time users";
const char* inorder_tag = "tells whether two elements are in Bruhat order";
const char* invpol_tag = "prints a single inverse k-l polynomial";
const char* klbasis_tag = "prints an element of the k-l basis";
const char* lcorder_tag = "prints the left cell order";
const char* lcells_tag = "prints out the left k-l cells";
const char* lcwgraphs_tag = "prints out the W-graphs of the left k-l cells";
const char* lrcorder_tag = "prints the two-sided cell order";
const char* lrcells_tag = "prints out the tow-sided k-l cells";
const char* lrcwgraphs_tag =
"prints out the W-graphs of the two-sided k-l cells";
const char* lrwgraph_tag = "prints out the two-sided W-graph";
const char* lwgraph_tag = "prints out the left W-graph";
const char* matrix_tag = "prints the current Coxeter matrix";
const char* mu_tag = "prints a single mu-coefficient";
const char* pol_tag = "prints a single k-l polynomial";
const char* q_tag = "exits the current mode";
const char* qq_tag = "exits the program";
const char* rank_tag = "resets the rank";
const char* rcorder_tag = "prints the right cell order";
const char* rcells_tag = "prints out the right k-l cells";
const char* rcwgraphs_tag = "prints out the W-graphs of the right k-l cells";
const char* rwgraph_tag = "prints out the right W-graph";
const char* schubert_tag = "prints out the kl data for a schubert variety";
const char* show_tag = "maps out the computation of a k-l polynomial";
const char* showmu_tag = "maps out the computation of a mu coefficient";
const char* slocus_tag =
"prints the rational singular locus of the Schubert variety";
const char* sstratification_tag =
"prints the rational singular stratification of the Schubert variety";
const char* type_tag =
"resets the type and rank (hence restarts the program)";
const char* uneq_tag = "puts the program in unequal-parameter mode";
namespace uneq {
void klbasis_f();
void lcorder_f();
void lrcorder_f();
void lcells_f();
void lrcells_f();
void mu_f();
void pol_f();
void rcells_f();
void rcorder_f();
const char* lcorder_tag = "prints the left cell order";
const char* lrcorder_tag = "prints the two-sided cell order";
const char* lcells_tag = "prints out the left k-l cells";
const char* lrcells_tag = "prints out the two-sided k-l cells";
const char* mu_tag = "prints out a mu-coefficient";
const char* pol_tag = "prints out a single k-l polynomial";
const char* rcells_tag = "prints out the right k-l cells";
const char* rcorder_tag = "prints the right cell order";
};
};
namespace commands {
void (*default_help)() = &help::default_h;
};
namespace commands {
namespace interface {
GroupEltInterface* in_buf = 0;
struct In_tag {};
struct Out_tag {};
void in_entry();
void in_exit();
void out_entry();
void out_exit();
void abort_f();
void alphabetic_f();
void bourbaki_f();
void default_f();
void decimal_f();
void gap_f();
void hexadecimal_f();
void in_f();
void out_f();
void permutation_f();
void symbol_f();
void terse_f();
void ordering_f();
const char* abort_tag = "leaves without modifying the interface";
const char* alphabetic_tag = "sets alphabetic generator symbols";
const char* bourbaki_tag = "sets Bourbaki conventions for i/o";
const char* decimal_tag = "sets decimal generator symbols";
const char* default_tag = "sets i/o to default mode";
const char* gap_tag = "sets i/o to GAP mode";
const char* hexadecimal_tag = "sets hexadecimal generator symbols";
const char* in_tag = "enters reset-input mode";
const char* out_tag = "enters reset-output mode";
const char* permutation_tag =
"sets permutation notation for i/o (in type A only)";
const char* ordering_tag = "modifies the ordering of the generators";
const char* terse_tag = "sets i/o to terse mode";
namespace in {
void alphabetic_f();
void bourbaki_f();
void decimal_f();
void default_f();
void gap_f();
void hexadecimal_f();
void permutation_f();
void postfix_f();
void prefix_f();
void separator_f();
void terse_f();
const char* alphabetic_tag =
"sets alphabetic generator symbols for input";
const char* bourbaki_tag = "sets Bourbaki conventions for input";
const char* decimal_tag = "sets decimal generator symbols for input";
const char* default_tag = "sets default conventions for input";
const char* gap_tag = "sets GAP conventions for input";
const char* hexadecimal_tag =
"sets hexadecimal generator symbols for input";
const char* permutation_tag =
"sets permutation notation for input (in type A only)";
const char* postfix_tag = "resets the input postfix";
const char* prefix_tag = "resets the input prefix";
const char* separator_tag = "resets the input separator";
const char* symbol_tag = "resets an input symbol";
const char* terse_tag = "sets terse conventions for input";
};
namespace out {
void alphabetic_f();
void bourbaki_f();
void decimal_f();
void default_f();
void gap_f();
void hexadecimal_f();
void permutation_f();
void postfix_f();
void prefix_f();
void separator_f();
void terse_f();
const char* alphabetic_tag =
"sets alphabetic generator symbols for output";
const char* bourbaki_tag = "sets Bourbaki conventions for output";
const char* decimal_tag = "sets decimal generator symbols for output";
const char* default_tag = "sets default conventions for output";
const char* gap_tag = "sets GAP conventions for output";
const char* hexadecimal_tag =
"sets hexadecimal generator symbols for output";
const char* permutation_tag =
"sets permutation notation for output (in type A only)";
const char* postfix_tag = "resets the output postfix";
const char* prefix_tag = "resets the output prefix";
const char* separator_tag = "resets the output separator";
const char* symbol_tag = "resets an output symbol";
const char* terse_tag = "sets terse conventions for output";
};
};
};
/*****************************************************************************
This module contains the code for the command interface. Although overall
I'm happy with the way it works, it suffers from a certain amount of
clumsiness.
The idea is that at each point in time, there is a certain active CommandTree
object. This is basically a dictionary of recognized command names, together
with the functions that will executed for them; in other words, something
that should be a map in STL parlance. Actually, the active command tree is
the top of the command tree stack treeStack; exiting the current mode means
popping the stack; entering a new mode means pushing it on the stack.
Each mode has an associated entry and exit function, which take care of
initialization and clean-up duties. Actually, there is mostly one main mode;
the entry function for this is the one which gets type and rank for the user;
the exit function destroys the current group. Redefining type or rank means
exiting and re-entering the main mode. In addition, there is the "empty"
mode, active on startup only, where nothing is defined yet, and some
auxiliary modes which temporarily hide the main mode in order to perform
certain duties : interface mode to set the i/o preferences of the user,
help mode for help, and also unequal-parameter mode which sets unequal
parameters for the k-l functions; this is in fact a sort of duplicate
main mode.
Command completion is implemented to the extend that incomplete commands
are recognized when non-ambiguous.
*****************************************************************************/
/*****************************************************************************
Chapter I -- Running the program
This section contains the following functions :
- ambigAction(str) : what to do with an ambiguous command;
- mainCommandTree() : returns a pointer to the initial command tree (and
builds it on first call);
- relax_f() : does nothing;
- run() : runs an interactive session;
*****************************************************************************/
namespace commands {
void relax_f()
/*
Does nothing.
*/
{}
void run()
/*
This function runs an interactive session of the program.
*/
{
static String name(0);
activate(emptyCommandTree());
if (ERRNO) {
Error (ERRNO);
return;
}
while (1) { /* the only way to exit from this loop is the "qq" command */
CommandTree* tree = treeStack.top();
tree->prompt();
getInput(stdin,name);
CommandData* cd = tree->find(name);
if (cd == 0) {
tree->error(name.ptr());
continue;
}
if (cd == ambigCommand()) {
ambigAction(tree,name);
continue;
}
cd->action();
if (cd->autorepeat) {
tree->setAction("",cd->action);
tree->setRepeat("",true);
}
else {
tree->setAction("",&relax_f);
tree->setRepeat("",false);
}
}
}
void default_error(char* str)
/*
Default response to an unknown command.
*/
{
Error(COMMAND_NOT_FOUND,str);
return;
}
};
namespace {
void activate(CommandTree* tree)
/*
Puts the tree on top of treeStack, and executes the initialization function.
*/
{
treeStack.push(tree);
tree->entry();
if (ERRNO) { /* an error occured during initialization */
Error(ERRNO);
treeStack.pop();
ERRNO = MODECHANGE_FAIL;
}
return;
}
void ambigAction(CommandTree* tree, const String& str)
/*
Response to ambiguous commands. Prints a warning and the list of possible
completions in the current tree on stderr.
*/
{
static String name(0);
bool b = true;
print(stderr,str);
fprintf(stderr," : ambiguous (");
DictCell<CommandData>* cell = tree->findCell(str);
new(&name) String(str);
printExtensions(stderr,cell->left,name,b);
fprintf(stderr,")\n");
return;
}
void empty_error(char* str)
{
CommandTree* tree = mainCommandTree();
CommandData* cd = tree->find(str);
if (cd == 0) {
default_error(str);
return;
}
if (cd == ambigCommand()) {
ambigAction(tree,str);
return;
}
activate(tree);
if (ERRNO) { /* something went wrong during initialization */
Error(ERRNO);
return;
}
/* type and rank are set at this point */
if ((cd != tree->find("type")) && (cd != tree->find("rank")))
cd->action();
if (cd->autorepeat) {
tree->setAction("",cd->action);
tree->setRepeat("",true);
}
else {
tree->setAction("",&relax_f);
tree->setRepeat("",false);
}
return;
}
void startup()
/*
The response to the first carriage return. Sets the response to "help"
to a less verbose version, and starts up the program.
*/
{
activate(mainCommandTree());
if (ERRNO)
Error(ERRNO);
return;
}
};
/*****************************************************************************
Chapter II -- The CommandTree class.
The purpose of a CommandTree is to get a command-name from the user (or
perhaps from a file), and execute the corresponding command. For this,
it maintains a tree of CommandCell s, one for each initial subword of
each recognized command. Each CommandCell knows which command it should
execute.
Recognizing initial subwords allows for command completion : when the
completion is unique, the command is executed as if the full name were
typed. When the completion is not unique, the function for ambiguous
commands is executed : as defined here, it prints the list of all possible
completions in the current tree, and prompts the user again.
The case of the empty command is special : either it does nothing, or,
for most commands, it repeats the previous command.
This setup supports the concept of mode : at all times, there is a current
command tree, and in some situations this will change : new commands can
become available, commands can change behaviour or can become unavailable.
Help mode is an example of this. Another example is the interface command,
which loads the interface mode tree, so that the user can set the various
i/o parameters.
NOTE : even though I like the actual behaviour of the setup, it is all
rather clumsy and should be re-done. The command tree could be replaced
with some associative container like map. The current behaviour could
be pretty much kept as is, until we include the functionalities of
readline.
The following functions are defined :
- constructors and destructors :
- CommandTree(prompt,a,entry,error,exit,h) : builds a command tree with
the given prompt, action a, help function h, given entry and exit
functions, and error function (called when a command is not found);
- ~CommandTree();
- accessors :
- prompt : prints the prompt;
- manipulators :
- add(name,tag,a,h,rep) : adds a command with the given name, tag (used
in the online help), action a, help-action h and repetition flag rep;
- setAction(str,a) : resets the action of the command for str;
- setRepeat(str,b) : resets the repetition flag of the command for b;
******************************************************************************/
namespace commands {
CommandTree::CommandTree(const char* prompt,
void (*a)(),
void (*entry)(),
void (*error)(char*),
void (*exit)(),
void (*h)())
:d_prompt(prompt), d_entry(entry), d_error(error), d_exit(exit)
/*
Initializes a command tree with the given prompt and action for the
empty command.
*/
{
d_root->ptr = new CommandData("","",a,&relax_f,false);
if (h) { /* add help functionality */
d_help = new CommandTree("help",&cr_h,h);
d_help->add("q",q_tag,&q_f,0,false);
add("help",help_tag,&help_f,&help_h,false);
}
}
CommandTree::~CommandTree()
/*
The memory allocated by a CommandTree object is hidden in the dictionary
and in the d_help pointer.
*/
{
delete d_help;
}
/******** accessors *********************************************************/
void CommandTree::prompt() const
/*
Prints the prompt for the command tree.
*/
{
printf("%s : ",d_prompt.ptr());
}
/******** manipulators ******************************************************/
void CommandTree::add(const char* name, const char* tag, void (*a)(),
void (*h)(), bool rep)
/*
This function adds a new command to the tree, adding new cells as
necessary.
*/
{
CommandData *cd = new CommandData(name,tag,a,h,rep);
insert(name,cd);
if (d_help && h) { /* add help functionality */
d_help->add(name,tag,h,0,false);
}
}
void CommandTree::setAction(const char* str, void (*a)())
/*
Assuming that str is a fullname on the command tree, sets the response
to str to a.
NOTE : is a bit dangerous. Should work also when str is only a prefix.
*/
{
CommandData* cd = find(str);
cd->action = a;
return;
}
void CommandTree::setRepeat(const char* str, bool b)
/*
Assuming that str is a fullname on the command tree, sets the autorepeat
value of the corresponding command data structure to b.
*/
{
CommandData* cd = find(str);
cd->autorepeat = b;
return;
}
};
/*****************************************************************************
Chapter III -- The CommandData class.
The CommandData structure collects the data associated to a given command
name. The function a defines the action associated with the command; the
function h defines the action associated with the command in help mode.
The flag b is set if the command should be repeated on a carriage return.
*****************************************************************************/
namespace commands {
CommandData::CommandData(const char* const& str, const char* const& t,
void (*a)(), void (*h)(), bool rep)
:name(str), tag(t), action(a), help(h), autorepeat(rep)
{}
CommandData::~CommandData()
/*
No memory is allocated directly
*/
{}
};
/*****************************************************************************
Chapter IV -- Building the command tree
This section contains the functions used for the construction of the primary
command tree, i.e., the initialization of the command module.
The following functions are defined :
- ambigCommand() : returns a special value flagging ambiguous commands;
- cellCompletion(cell) : auxiliary to commandCompletion;
- commandCompletion(tree) : finishes off the command tree;
- emptyCommandTree() : returns a pointer to the initial command tree;
- initCommandTree<Empty_tag> : builds the empty command tree;
- initCommandTree<Interface_tag> : builds the interface command tree;
- initCommandTree<Main_tag> : builds the main command tree;
- initCommandTree<Uneq_tag> : builds the command tree for unequal parameters;
- interfaceCommandTree() : returns a pointer to the interface command tree;
- mainCommandTree() : returns a pointer to the main command tree;
- uneqCommandTree() : returns a pointer to the unequal-parameter command
tree;
*****************************************************************************/
namespace {
CommandData* ambigCommand()
/*
Returns a dummy command cell which is a placeholder indicating that
ambigAction must be executed; this requires knowledge of where we are
in the command tree.
*/
{
static CommandData cd("","",0,0,false);
return &cd;
}
void cellCompletion(DictCell<CommandData>* cell)
/*
This function fills in the value fields of the cells which do not
correspond to full names. It is assumed that the tree is traversed
in infix (?) order, i.e. first visit left child, then cell, the right
child, so that all longer names are already visited. This allows to
fill in unique completions backwards, making thins easy.
*/
{
if (cell->fullname == true)
return;
if (cell->uniquePrefix == false) { /* ambiguous */
cell->ptr = ambigCommand();
return;
}
if (cell->uniquePrefix == true) { /* unique completion */
cell->ptr = cell->left->value();
return;
}
}
void commandCompletion(DictCell<CommandData>* cell)
/*
This function finishes up the command tree by implementing command
completion. This is done as follows. We traverse the command tree
from the root. If node.fullname is true, we do nothing. Otherwise,
if node.uniquePrefix is true, we set node.value to be equal to the
value of the unique completion of the string recognized by node in
the dictionary. If node.uniquePrefix is false, we set node.value
to ambigCommand().
*/
{
if (cell == 0)
return;
commandCompletion(cell->left);
cellCompletion(cell);
commandCompletion(cell->right);
}
template<> CommandTree* initCommandTree<Empty_tag>()
/*
This function builds the initial command tree of the program. The idea
is that all commands on the main command tree will be considered entry
commands, and so will do the necessary initialization. This is achieved
thru the special error function.
*/
{
static CommandTree tree("coxeter",&startup,&relax_f,&empty_error,&relax_f,
&intro_h);
tree.add("author","author_tag",&author_f,&relax_f,false);
tree.add("qq",qq_tag,&qq_f,&qq_h,false);
commandCompletion(tree.root());
tree.helpMode()->add("intro",intro_tag,&intro_h,0,false);
commandCompletion(tree.helpMode()->root());
return &tree;
}
CommandTree* emptyCommandTree()
/*
Returns a pointer to the initial command tree of the program, building it on
the first call.
*/
{
static CommandTree* tree = initCommandTree<Empty_tag>();
return tree;
}
template<> CommandTree* initCommandTree<Interface_tag>()
/*
This function builds the interface command tree; this makes available the
various little commands that are needed to reset the interface, and that
have no reason to be clogging up the main command tree.
*/
{
static CommandTree tree("interface",&relax_f,&interface_entry,&default_error,
&interface_exit,&interface_help);
tree.add("alphabetic",commands::interface::alphabetic_tag,
&commands::interface::alphabetic_f,&help::interface::alphabetic_h);
tree.add("bourbaki",commands::interface::bourbaki_tag,
&commands::interface::bourbaki_f,&help::interface::bourbaki_h);
tree.add("decimal",commands::interface::decimal_tag,
&commands::interface::decimal_f,&help::interface::decimal_h);
tree.add("default",commands::interface::default_tag,
&commands::interface::default_f,&help::interface::default_h);
tree.add("gap",commands::interface::out::gap_tag,
&commands::interface::out::gap_f, &help::interface::gap_h);
tree.add("hexadecimal",commands::interface::hexadecimal_tag,
&commands::interface::hexadecimal_f,
&help::interface::hexadecimal_h);
tree.add("in",commands::interface::in_tag,&commands::interface::in_f,
help::interface::in_h,false);
tree.add("ordering",commands::interface::ordering_tag,
&commands::interface::ordering_f,help::interface::ordering_h,false);
tree.add("out",commands::interface::out_tag,&commands::interface::out_f,
help::interface::out_h,false);
tree.add("permutation",commands::interface::permutation_tag,
&commands::interface::permutation_f,
&help::interface::permutation_h);
tree.add("q",q_tag,&q_f,0,false);
tree.add("terse",commands::interface::out::terse_tag,
&commands::interface::out::terse_f, &help::interface::out::terse_h);
commandCompletion(tree.root());
commandCompletion(tree.helpMode()->root());
return &tree;
}
template<> CommandTree* initCommandTree<commands::interface::In_tag>()
/*
This function builds the command tree for the input-modification mode.
*/
{
using namespace commands::interface;
static CommandTree tree("in",&relax_f,&in_entry,&default_error,
&in_exit,&help::interface::in_help);
tree.add("q",q_tag,&q_f,0,false);
tree.add("abort",abort_tag,&abort_f,&help::interface::abort_h);
tree.add("alphabetic",in::alphabetic_tag,&in::alphabetic_f,
&help::interface::in::alphabetic_h,false);
tree.add("bourbaki",in::bourbaki_tag,&in::bourbaki_f,
&help::interface::in::bourbaki_h);
tree.add("decimal",in::decimal_tag,&in::decimal_f,
&help::interface::in::decimal_h,false);
tree.add("default",in::default_tag,&in::default_f,
&help::interface::in::default_h);
tree.add("gap",in::gap_tag,&in::gap_f,&help::interface::in::gap_h);
tree.add("hexadecimal",in::hexadecimal_tag,&in::hexadecimal_f,
&help::interface::in::hexadecimal_h,false);
tree.add("permutation",in::permutation_tag,&in::permutation_f,
&help::interface::in::permutation_h,false);
tree.add("postfix",in::postfix_tag,&in::postfix_f,
&help::interface::in::postfix_h);
tree.add("prefix",in::prefix_tag,&in::prefix_f,
&help::interface::in::prefix_h);
tree.add("separator",in::separator_tag,
&in::separator_f,&help::interface::in::separator_h);
tree.add("symbol",in::symbol_tag,&symbol_f,
&help::interface::in::symbol_h);
tree.add("terse",in::terse_tag,&in::terse_f,&help::interface::in::terse_h);
commandCompletion(tree.root());
commandCompletion(tree.helpMode()->root());
return &tree;
}
template<> CommandTree* initCommandTree<commands::interface::Out_tag>()
/*
This function builds the command tree for the output-modification mode.
*/
{
using namespace commands::interface;
static CommandTree tree("out",&relax_f,&out_entry,&default_error,
&out_exit,&help::interface::out_help);
tree.add("q",q_tag,&q_f,0,false);
tree.add("alphabetic",out::alphabetic_tag,&out::alphabetic_f,
&help::interface::out::alphabetic_h,false);
tree.add("bourbaki",out::bourbaki_tag,&out::bourbaki_f,
&help::interface::out::bourbaki_h);
tree.add("decimal",out::decimal_tag,&out::decimal_f,
&help::interface::out::decimal_h,false);
tree.add("default",out::default_tag,&out::default_f,
&help::interface::out::default_h);
tree.add("gap",out::gap_tag,&out::gap_f,
&help::interface::out::gap_h);
tree.add("hexadecimal",out::hexadecimal_tag,&out::hexadecimal_f,
&help::interface::out::hexadecimal_h,false);
tree.add("permutation",out::permutation_tag,&out::permutation_f,
&help::interface::out::permutation_h,false);
tree.add("postfix",out::postfix_tag,&out::postfix_f,
&help::interface::out::postfix_h);
tree.add("prefix",out::prefix_tag,&out::prefix_f,
&help::interface::out::prefix_h);
tree.add("separator",out::separator_tag,
&out::separator_f,&help::interface::out::separator_h);
tree.add("symbol",out::symbol_tag,&symbol_f,
&help::interface::out::symbol_h);
tree.add("terse",out::terse_tag,&out::terse_f,
&help::interface::out::terse_h);
commandCompletion(tree.root());
commandCompletion(tree.helpMode()->root());
return &tree;
}
};
namespace commands {
CommandTree* interface::inCommandTree()
{
static CommandTree* tree = initCommandTree<In_tag>();
return tree;
}
CommandTree* interface::outCommandTree()
{
static CommandTree* tree = initCommandTree<Out_tag>();
return tree;
}
CommandTree* interfaceCommandTree()
/*
Returns a pointer to the interface command tree, building it on the first
call.
*/
{
static CommandTree* tree = initCommandTree<Interface_tag>();
return tree;
}
};
namespace {
template<> CommandTree* initCommandTree<Main_tag>()
/*
This function builds the main command tree, the one that is being run on
startup. Auxiliary trees may be grafted onto this one (thru the pushdown
stack treeStack) by some functions needing to be in special modes.
*/
{
static CommandTree tree("coxeter",&relax_f,&main_entry,&default_error,
&main_exit,&main_help);
tree.add("author",author_tag,&author_f,&relax_f,false);
tree.add("betti",betti_tag,&betti_f,&betti_h,false);
tree.add("coatoms",coatoms_tag,&coatoms_f,&coatoms_h);
tree.add("compute",compute_tag,&compute_f,&compute_h);
tree.add("descent",descent_tag,&descent_f,&descent_h);
tree.add("duflo",duflo_tag,&duflo_f,&duflo_h);
tree.add("extremals",extremals_tag,&extremals_f,&extremals_h);
tree.add("fullcontext",fullcontext_tag,&fullcontext_f,&fullcontext_h);
tree.add("ihbetti",ihbetti_tag,&ihbetti_f,&ihbetti_h,false);
tree.add("interface",interface_tag,&interface_f,&interface_h,false);
tree.add("interval",interval_tag,&interval_f,&interval_h,false);
tree.add("inorder",inorder_tag,&inorder_f,&inorder_h);
tree.add("invpol",invpol_tag,&invpol_f,&invpol_h);
tree.add("lcorder",lcorder_tag,&lcorder_f,&lcorder_h,false);
tree.add("lcells",lcells_tag,&lcells_f,&lcells_h,false);
tree.add("lcwgraphs",lcwgraphs_tag,&lcwgraphs_f,&lcwgraphs_h,false);
tree.add("lrcorder",lrcorder_tag,&lrcorder_f,&lrcorder_h,false);
tree.add("lrcells",lrcells_tag,&lrcells_f,&lrcells_h,false);
tree.add("lrcwgraphs",lrcwgraphs_tag,&lrcwgraphs_f,&lrcwgraphs_h,false);
tree.add("lrwgraph",lrwgraph_tag,&lrwgraph_f,&lrwgraph_h,false);
tree.add("lwgraph",lwgraph_tag,&lwgraph_f,&lwgraph_h,false);
tree.add("klbasis",klbasis_tag,&klbasis_f,&klbasis_h,true);
tree.add("matrix",matrix_tag,&matrix_f,&matrix_h);
tree.add("mu",mu_tag,&mu_f,&mu_h);
tree.add("pol",pol_tag,&pol_f,&pol_h);
tree.add("q",q_tag,&q_f,0,false);
tree.add("qq",qq_tag,&qq_f,&qq_h,false);
tree.add("rank",rank_tag,&rank_f,&rank_h,false);
tree.add("rcorder",rcorder_tag,&rcorder_f,&rcorder_h,false);
tree.add("rcells",rcells_tag,&rcells_f,&rcells_h,false);
tree.add("rcwgraphs",rcwgraphs_tag,&rcwgraphs_f,&rcwgraphs_h,false);
tree.add("rwgraph",rwgraph_tag,&rwgraph_f,&rwgraph_h,false);
tree.add("schubert",schubert_tag,&schubert_f,&schubert_h);