1 //
2 //	aegis - project change supervisor
3 //	Copyright (C) 2002, 2004-2006, 2008 Peter Miller
4 //
5 //	This program is free software; you can redistribute it and/or modify
6 //	it under the terms of the GNU General Public License as published by
7 //	the Free Software Foundation; either version 3 of the License, or
8 //	(at your option) any later version.
9 //
10 //	This program is distributed in the hope that it will be useful,
11 //	but WITHOUT ANY WARRANTY; without even the implied warranty of
12 //	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 //	GNU General Public License for more details.
14 //
15 //	You should have received a copy of the GNU General Public License
16 //	along with this program. If not, see
17 //	<http://www.gnu.org/licenses/>.
18 //
19 
20 #include <libaegis/arglex2.h>
21 #include <aecomplete/command/generic.h>
22 #include <aecomplete/complete/filename.h>
23 #include <aecomplete/complete/nil.h>
24 
25 
26 complete_ty *
generic_argument_complete()27 generic_argument_complete()
28 {
29     switch (arglex_token)
30     {
31     default:
32 	// discard
33 	arglex();
34 	break;
35 
36     case arglex_token_option_incomplete:
37 	// Maybe "complete_option"?
38 	return complete_nil();
39 
40     case arglex_token_file:
41     case arglex_token_output:
42 	switch (arglex())
43 	{
44 	case arglex_token_string:
45 	    arglex();
46 	    break;
47 
48 	case arglex_token_string_incomplete:
49 	case arglex_token_number_incomplete:
50 	    return complete_filename(0);
51 
52 	default:
53 	    break;
54 	}
55 	break;
56 
57     case arglex_token_library:
58     case arglex_token_directory:
59 	switch (arglex())
60 	{
61 	case arglex_token_string:
62 	    arglex();
63 	    break;
64 
65 	case arglex_token_string_incomplete:
66 	case arglex_token_number_incomplete:
67 	    return complete_filename(1);
68 
69 	default:
70 	    break;
71 	}
72 	break;
73 
74     case arglex_token_page_length:
75     case arglex_token_page_width:
76     case arglex_token_tab_width:
77 	switch (arglex())
78 	{
79 	case arglex_token_number:
80 	    arglex();
81 	    break;
82 
83 	case arglex_token_string_incomplete:
84 	case arglex_token_number_incomplete:
85 	    // Maybe "complete_number"?
86 	    return complete_nil();
87 
88 	default:
89 	    break;
90 	}
91 	break;
92 
93     case arglex_token_trace:
94 	for (;;)
95 	{
96 	    switch (arglex())
97 	    {
98 	    default:
99 		break;
100 
101 	    case arglex_token_string:
102 		arglex();
103 		continue;
104 
105 	    case arglex_token_string_incomplete:
106 	    case arglex_token_number_incomplete:
107 		return complete_filename(0);
108 	    }
109 	    break;
110 	}
111 	break;
112     }
113     return 0;
114 }
115