aboutsummaryrefslogtreecommitdiffhomepage
path: root/parser_keywords.h
blob: 5bad85aab1627fceed7b33ad4ae5f856d76620d4 (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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/** \file parser_keywords.h

Functions having to do with parser keywords, like testing if a function is a block command.
*/

#ifndef FISH_PARSER_KEYWORD_H
#define FISH_PARSER_KEYWORD_H

/**
   Return values for parser_keywords_is_switch()
*/
enum 
{
	ARG_NON_SWITCH,
	ARG_SWITCH,
	ARG_SKIP
};



/**
   Check if the specified argument is a switch. Return ARG_SWITCH if yes,
   ARG_NON_SWITCH if no and ARG_SKIP if the argument is '--'
*/
bool parser_keywords_is_switch( const wcstring &cmd );


/**
   Tests if the specified commands parameters should be interpreted as another command, which will be true if the command is either 'command', 'exec', 'if', 'while', or 'builtin'.  This does not handle "else if" which is more complicated.

   \param cmd The command name to test
   \return 1 of the command parameter is a command, 0 otherwise
*/

bool parser_keywords_is_subcommand( const wcstring &cmd );

/**
   Tests if the specified command is a reserved word, i.e. if it is
   the name of one of the builtin functions that change the block or
   command scope, like 'for', 'end' or 'command' or 'exec'. These
   functions may not be overloaded, so their names are reserved.

   \param word The command name to test
   \return 1 of the command parameter is a command, 0 otherwise
*/
bool parser_keywords_is_reserved( const wcstring &word );

/**
   Test if the specified string is command that opens a new block
*/

bool parser_keywords_is_block( const wcstring &word);

/**
   Check if the specified command is one of the builtins that cannot
   have arguments, any followin argument is interpreted as a new
   command
*/
bool parser_keywords_skip_arguments( const wcstring &cmd );


#endif