2007-04-22 09:50:26 +00:00
|
|
|
/** \file parser_keywords.c
|
|
|
|
|
2007-08-01 17:38:01 +00:00
|
|
|
Functions having to do with parser keywords, like testing if a function is a block command.
|
2007-04-22 09:50:26 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
#include "fallback.h"
|
|
|
|
#include "common.h"
|
|
|
|
#include "parser_keywords.h"
|
|
|
|
|
|
|
|
|
|
|
|
int parser_keywords_is_switch( const wchar_t *cmd )
|
|
|
|
{
|
|
|
|
if( wcscmp( cmd, L"--" ) == 0 )
|
|
|
|
return ARG_SKIP;
|
2010-09-18 01:51:16 +00:00
|
|
|
else
|
2007-04-22 09:50:26 +00:00
|
|
|
return cmd[0] == L'-';
|
|
|
|
}
|
|
|
|
|
|
|
|
int parser_keywords_skip_arguments( const wchar_t *cmd )
|
|
|
|
{
|
2007-09-28 21:32:27 +00:00
|
|
|
return contains( cmd,
|
2007-04-22 09:50:26 +00:00
|
|
|
L"else",
|
|
|
|
L"begin" );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int parser_keywords_is_subcommand( const wchar_t *cmd )
|
|
|
|
{
|
|
|
|
|
|
|
|
return parser_keywords_skip_arguments( cmd ) ||
|
2007-09-28 21:32:27 +00:00
|
|
|
contains( cmd,
|
2007-04-22 09:50:26 +00:00
|
|
|
L"command",
|
|
|
|
L"builtin",
|
|
|
|
L"while",
|
|
|
|
L"exec",
|
|
|
|
L"if",
|
|
|
|
L"and",
|
|
|
|
L"or",
|
|
|
|
L"not" );
|
2010-09-18 01:51:16 +00:00
|
|
|
|
2007-04-22 09:50:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int parser_keywords_is_block( const wchar_t *word)
|
|
|
|
{
|
2007-09-28 21:32:27 +00:00
|
|
|
return contains( word,
|
2007-04-22 09:50:26 +00:00
|
|
|
L"for",
|
|
|
|
L"while",
|
|
|
|
L"if",
|
|
|
|
L"function",
|
|
|
|
L"switch",
|
|
|
|
L"begin" );
|
|
|
|
}
|
|
|
|
|
|
|
|
int parser_keywords_is_reserved( const wchar_t *word)
|
|
|
|
{
|
|
|
|
return parser_keywords_is_block(word) ||
|
|
|
|
parser_keywords_is_subcommand( word ) ||
|
2007-09-28 21:32:27 +00:00
|
|
|
contains( word,
|
2007-04-22 09:50:26 +00:00
|
|
|
L"end",
|
|
|
|
L"case",
|
|
|
|
L"else",
|
|
|
|
L"return",
|
|
|
|
L"continue",
|
|
|
|
L"break" );
|
|
|
|
}
|
|
|
|
|