mirror of
https://github.com/fish-shell/fish-shell.git
synced 2024-11-25 18:03:37 +08:00
More work towards instanced parser
This commit is contained in:
parent
3d8face1f9
commit
7e486e3b5c
|
@ -1243,9 +1243,9 @@ static void complete_from_args( const wchar_t *str,
|
|||
array_list_t possible_comp;
|
||||
|
||||
al_init( &possible_comp );
|
||||
|
||||
parser_t parser(PARSER_TYPE_COMPLETIONS_ONLY);
|
||||
proc_push_interactive(0);
|
||||
eval_args( args, &possible_comp );
|
||||
parser.eval_args( args, &possible_comp );
|
||||
proc_pop_interactive();
|
||||
|
||||
complete_strings( comp_out, str, desc, 0, &possible_comp, flags );
|
||||
|
|
15
env.cpp
15
env.cpp
|
@ -247,11 +247,7 @@ static void clear_hash_entry( void *key, void *data )
|
|||
*/
|
||||
static void start_fishd()
|
||||
{
|
||||
string_buffer_t cmd;
|
||||
struct passwd *pw;
|
||||
|
||||
sb_init( &cmd );
|
||||
pw = getpwuid(getuid());
|
||||
struct passwd *pw = getpwuid(getuid());
|
||||
|
||||
debug( 3, L"Spawning new copy of fishd" );
|
||||
|
||||
|
@ -261,12 +257,9 @@ static void start_fishd()
|
|||
return;
|
||||
}
|
||||
|
||||
sb_printf( &cmd, FISHD_CMD, pw->pw_name );
|
||||
|
||||
eval( (wchar_t *)cmd.buff,
|
||||
0,
|
||||
TOP );
|
||||
sb_destroy( &cmd );
|
||||
wcstring cmd = format_string(FISHD_CMD, pw->pw_name);
|
||||
parser_t parser(PARSER_TYPE_GENERAL);
|
||||
parser.eval( cmd.c_str(), 0, TOP );
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
12
expand.cpp
12
expand.cpp
|
@ -731,7 +731,7 @@ static int expand_pid2( const wcstring &in, int flags, std::vector<wcstring> &ou
|
|||
}
|
||||
|
||||
|
||||
void expand_variable_error( const wchar_t *token, int token_pos, int error_pos )
|
||||
void expand_variable_error( parser_t &parser, const wchar_t *token, int token_pos, int error_pos )
|
||||
{
|
||||
int stop_pos = token_pos+1;
|
||||
|
||||
|
@ -758,7 +758,7 @@ void expand_variable_error( const wchar_t *token, int token_pos, int error_pos )
|
|||
|
||||
if( is_var )
|
||||
{
|
||||
error( SYNTAX_ERROR,
|
||||
parser.error( SYNTAX_ERROR,
|
||||
error_pos,
|
||||
COMPLETE_VAR_BRACKET_DESC,
|
||||
cpy,
|
||||
|
@ -767,7 +767,7 @@ void expand_variable_error( const wchar_t *token, int token_pos, int error_pos )
|
|||
}
|
||||
else
|
||||
{
|
||||
error( SYNTAX_ERROR,
|
||||
parser.error( SYNTAX_ERROR,
|
||||
error_pos,
|
||||
COMPLETE_VAR_BRACKET_DESC,
|
||||
L"",
|
||||
|
@ -781,7 +781,7 @@ void expand_variable_error( const wchar_t *token, int token_pos, int error_pos )
|
|||
|
||||
case INTERNAL_SEPARATOR:
|
||||
{
|
||||
error( SYNTAX_ERROR,
|
||||
parser.error( SYNTAX_ERROR,
|
||||
error_pos,
|
||||
COMPLETE_VAR_PARAN_DESC );
|
||||
break;
|
||||
|
@ -789,7 +789,7 @@ void expand_variable_error( const wchar_t *token, int token_pos, int error_pos )
|
|||
|
||||
case 0:
|
||||
{
|
||||
error( SYNTAX_ERROR,
|
||||
parser.error( SYNTAX_ERROR,
|
||||
error_pos,
|
||||
COMPLETE_VAR_NULL_DESC );
|
||||
break;
|
||||
|
@ -797,7 +797,7 @@ void expand_variable_error( const wchar_t *token, int token_pos, int error_pos )
|
|||
|
||||
default:
|
||||
{
|
||||
error( SYNTAX_ERROR,
|
||||
parser.error( SYNTAX_ERROR,
|
||||
error_pos,
|
||||
COMPLETE_VAR_DESC,
|
||||
token[stop_pos] );
|
||||
|
|
2
expand.h
2
expand.h
|
@ -204,7 +204,7 @@ int expand_is_clean( const wchar_t *in );
|
|||
\param token_pos The position where the expansion begins
|
||||
\param error_pos The position on the line to report to the error function.
|
||||
*/
|
||||
void expand_variable_error( const wchar_t *token, int token_pos, int error_pos );
|
||||
void expand_variable_error( parser_t &parser, const wchar_t *token, int token_pos, int error_pos );
|
||||
|
||||
|
||||
#endif
|
||||
|
|
5
fish.cpp
5
fish.cpp
|
@ -77,9 +77,10 @@ static int read_init()
|
|||
wchar_t *config_dir_escaped;
|
||||
void *context;
|
||||
string_buffer_t *eval_buff;
|
||||
parser_t parser();
|
||||
|
||||
eval( L"builtin . " DATADIR "/fish/config.fish 2>/dev/null", 0, TOP );
|
||||
eval( L"builtin . " SYSCONFDIR L"/fish/config.fish 2>/dev/null", 0, TOP );
|
||||
parser.eval( L"builtin . " DATADIR "/fish/config.fish 2>/dev/null", 0, TOP );
|
||||
parser.eval( L"builtin . " SYSCONFDIR L"/fish/config.fish 2>/dev/null", 0, TOP );
|
||||
|
||||
/*
|
||||
We need to get the configuration directory before we can source the user configuration file
|
||||
|
|
23
parser.cpp
23
parser.cpp
|
@ -428,29 +428,6 @@ typedef struct
|
|||
wchar_t *cmd;
|
||||
} profile_element_t;
|
||||
|
||||
struct profile_item_t {
|
||||
/**
|
||||
Time spent executing the specified command, including parse time for nested blocks.
|
||||
*/
|
||||
int exec;
|
||||
/**
|
||||
Time spent parsing the specified command, including execution time for command substitutions.
|
||||
*/
|
||||
int parse;
|
||||
/**
|
||||
The block level of the specified command. nested blocks and command substitutions both increase the block level.
|
||||
*/
|
||||
int level;
|
||||
/**
|
||||
If the execution of this command was skipped.
|
||||
*/
|
||||
int skipped;
|
||||
/**
|
||||
The command string.
|
||||
*/
|
||||
wcstring cmd;
|
||||
};
|
||||
|
||||
/**
|
||||
Return the current number of block nestings
|
||||
*/
|
||||
|
|
23
parser.h
23
parser.h
|
@ -187,7 +187,28 @@ enum parser_type_t {
|
|||
PARSER_TYPE_COMPLETIONS_ONLY
|
||||
};
|
||||
|
||||
struct profile_item_t;
|
||||
struct profile_item_t {
|
||||
/**
|
||||
Time spent executing the specified command, including parse time for nested blocks.
|
||||
*/
|
||||
int exec;
|
||||
/**
|
||||
Time spent parsing the specified command, including execution time for command substitutions.
|
||||
*/
|
||||
int parse;
|
||||
/**
|
||||
The block level of the specified command. nested blocks and command substitutions both increase the block level.
|
||||
*/
|
||||
int level;
|
||||
/**
|
||||
If the execution of this command was skipped.
|
||||
*/
|
||||
int skipped;
|
||||
/**
|
||||
The command string.
|
||||
*/
|
||||
wcstring cmd;
|
||||
};
|
||||
|
||||
class parser_t {
|
||||
private:
|
||||
|
|
Loading…
Reference in New Issue
Block a user