mirror of
https://github.com/fish-shell/fish-shell.git
synced 2025-02-21 06:56:09 +08:00
Get some basic function signatures right for new instanced parser
This commit is contained in:
parent
e4ee4ec3d1
commit
fa796d668f
381
builtin.cpp
381
builtin.cpp
File diff suppressed because it is too large
Load Diff
15
builtin.h
15
builtin.h
@ -10,6 +10,8 @@
|
||||
#include "util.h"
|
||||
#include "io.h"
|
||||
|
||||
class parser_t;
|
||||
|
||||
enum
|
||||
{
|
||||
COMMAND_NOT_BUILTIN,
|
||||
@ -125,6 +127,7 @@ int builtin_exists( wchar_t *cmd );
|
||||
/**
|
||||
Execute a builtin command
|
||||
|
||||
\param parser The parser being used
|
||||
\param argv Array containing the command and parameters
|
||||
of the builtin. The list is terminated by a
|
||||
null pointer. This syntax resembles the syntax
|
||||
@ -133,7 +136,7 @@ int builtin_exists( wchar_t *cmd );
|
||||
|
||||
\return the exit status of the builtin command
|
||||
*/
|
||||
int builtin_run( wchar_t **argv, io_data_t *io );
|
||||
int builtin_run( parser_t &parser, wchar_t **argv, io_data_t *io );
|
||||
|
||||
/**
|
||||
Insert all builtin names into l. These are not copies of the strings and should not be freed after use.
|
||||
@ -143,18 +146,18 @@ void builtin_get_names( array_list_t *list );
|
||||
/**
|
||||
Pushes a new set of input/output to the stack. The new stdin is supplied, a new set of output string_buffer_ts is created.
|
||||
*/
|
||||
void builtin_push_io( int stdin_fd );
|
||||
void builtin_push_io( parser_t &parser, int stdin_fd );
|
||||
|
||||
/**
|
||||
Pops a set of input/output from the stack. The output string_buffer_ts are destroued, but the input file is not closed.
|
||||
*/
|
||||
void builtin_pop_io();
|
||||
void builtin_pop_io(parser_t &parser);
|
||||
|
||||
|
||||
/**
|
||||
Return a one-line description of the specified builtin
|
||||
*/
|
||||
const wchar_t *builtin_get_desc( const wchar_t *b );
|
||||
const wchar_t *builtin_get_desc( parser_t &parser, const wchar_t *b );
|
||||
|
||||
|
||||
/**
|
||||
@ -162,7 +165,7 @@ const wchar_t *builtin_get_desc( const wchar_t *b );
|
||||
the commandline builtin operate on the string to complete instead
|
||||
of operating on whatever is to be completed.
|
||||
*/
|
||||
const wchar_t *builtin_complete_get_temporary_buffer();
|
||||
const wchar_t *builtin_complete_get_temporary_buffer(parser_t &parser);
|
||||
|
||||
|
||||
/**
|
||||
@ -171,6 +174,6 @@ const wchar_t *builtin_complete_get_temporary_buffer();
|
||||
the next time this function is called, and must never be free'd manually.
|
||||
*/
|
||||
|
||||
wchar_t *builtin_help_get( const wchar_t *cmd );
|
||||
wchar_t *builtin_help_get( parser_t &parser, const wchar_t *cmd );
|
||||
|
||||
#endif
|
||||
|
@ -214,7 +214,7 @@ static void write_part( const wchar_t *begin,
|
||||
The commandline builtin. It is used for specifying a new value for
|
||||
the commandline.
|
||||
*/
|
||||
static int builtin_commandline( wchar_t **argv )
|
||||
static int builtin_commandline( parser_t &parser, wchar_t **argv )
|
||||
{
|
||||
|
||||
int buffer_part=0;
|
||||
@ -259,7 +259,7 @@ static int builtin_commandline( wchar_t **argv )
|
||||
argv[0],
|
||||
L": Can not set commandline in non-interactive mode\n",
|
||||
NULL );
|
||||
builtin_print_help( argv[0], sb_err );
|
||||
builtin_print_help( parser, argv[0], sb_err );
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -355,7 +355,7 @@ static int builtin_commandline( wchar_t **argv )
|
||||
BUILTIN_ERR_UNKNOWN,
|
||||
argv[0],
|
||||
long_options[opt_index].name );
|
||||
builtin_print_help( argv[0], sb_err );
|
||||
builtin_print_help( parser, argv[0], sb_err );
|
||||
|
||||
return 1;
|
||||
|
||||
@ -418,11 +418,11 @@ static int builtin_commandline( wchar_t **argv )
|
||||
break;
|
||||
|
||||
case 'h':
|
||||
builtin_print_help( argv[0], sb_out );
|
||||
builtin_print_help( parser, argv[0], sb_out );
|
||||
return 0;
|
||||
|
||||
case L'?':
|
||||
builtin_unknown_option( argv[0], argv[woptind-1] );
|
||||
builtin_unknown_option( parser, argv[0], argv[woptind-1] );
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
@ -440,7 +440,7 @@ static int builtin_commandline( wchar_t **argv )
|
||||
BUILTIN_ERR_COMBO,
|
||||
argv[0] );
|
||||
|
||||
builtin_print_help( argv[0], sb_err );
|
||||
builtin_print_help( parser, argv[0], sb_err );
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -451,7 +451,7 @@ static int builtin_commandline( wchar_t **argv )
|
||||
BUILTIN_ERR_MISSING,
|
||||
argv[0] );
|
||||
|
||||
builtin_print_help( argv[0], sb_err );
|
||||
builtin_print_help( parser, argv[0], sb_err );
|
||||
return 1;
|
||||
}
|
||||
for( i=woptind; i<argc; i++ )
|
||||
@ -472,7 +472,7 @@ static int builtin_commandline( wchar_t **argv )
|
||||
_(L"%ls: Unknown input function '%ls'\n"),
|
||||
argv[0],
|
||||
argv[i] );
|
||||
builtin_print_help( argv[0], sb_err );
|
||||
builtin_print_help( parser, argv[0], sb_err );
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
@ -490,7 +490,7 @@ static int builtin_commandline( wchar_t **argv )
|
||||
argv[0],
|
||||
L": Too many arguments\n",
|
||||
NULL );
|
||||
builtin_print_help( argv[0], sb_err );
|
||||
builtin_print_help( parser, argv[0], sb_err );
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -500,7 +500,7 @@ static int builtin_commandline( wchar_t **argv )
|
||||
BUILTIN_ERR_COMBO,
|
||||
argv[0] );
|
||||
|
||||
builtin_print_help( argv[0], sb_err );
|
||||
builtin_print_help( parser, argv[0], sb_err );
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -513,7 +513,7 @@ static int builtin_commandline( wchar_t **argv )
|
||||
L"--cut-at-cursor and --tokenize can not be used when setting the commandline" );
|
||||
|
||||
|
||||
builtin_print_help( argv[0], sb_err );
|
||||
builtin_print_help( parser, argv[0], sb_err );
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -524,7 +524,7 @@ static int builtin_commandline( wchar_t **argv )
|
||||
argv[0],
|
||||
L"insertion mode switches can not be used when not in insertion mode" );
|
||||
|
||||
builtin_print_help( argv[0], sb_err );
|
||||
builtin_print_help( parser, argv[0], sb_err );
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -556,7 +556,7 @@ static int builtin_commandline( wchar_t **argv )
|
||||
BUILTIN_ERR_NOT_NUMBER,
|
||||
argv[0],
|
||||
argv[woptind] );
|
||||
builtin_print_help( argv[0], sb_err );
|
||||
builtin_print_help( parser, argv[0], sb_err );
|
||||
}
|
||||
|
||||
current_buffer = reader_get_buffer();
|
||||
|
@ -289,7 +289,7 @@ const wchar_t *builtin_complete_get_temporary_buffer()
|
||||
tab-completions. Calls the functions in complete.c for any heavy
|
||||
lifting. Defined in builtin_complete.c
|
||||
*/
|
||||
static int builtin_complete( wchar_t **argv )
|
||||
static int builtin_complete( parser_t &parser, wchar_t **argv )
|
||||
{
|
||||
ASSERT_IS_MAIN_THREAD();
|
||||
int res=0;
|
||||
@ -414,7 +414,7 @@ static int builtin_complete( wchar_t **argv )
|
||||
BUILTIN_ERR_UNKNOWN,
|
||||
argv[0],
|
||||
long_options[opt_index].name );
|
||||
builtin_print_help( argv[0], sb_err );
|
||||
builtin_print_help( parser, argv[0], sb_err );
|
||||
|
||||
|
||||
res = 1;
|
||||
@ -489,11 +489,11 @@ static int builtin_complete( wchar_t **argv )
|
||||
break;
|
||||
|
||||
case 'h':
|
||||
builtin_print_help( argv[0], sb_out );
|
||||
builtin_print_help( parser, argv[0], sb_out );
|
||||
return 0;
|
||||
|
||||
case '?':
|
||||
builtin_unknown_option( argv[0], argv[woptind-1] );
|
||||
builtin_unknown_option( parser, argv[0], argv[woptind-1] );
|
||||
res = 1;
|
||||
break;
|
||||
|
||||
@ -505,14 +505,14 @@ static int builtin_complete( wchar_t **argv )
|
||||
{
|
||||
if( condition && wcslen( condition ) )
|
||||
{
|
||||
if( parser_test( condition, 0, 0, 0 ) )
|
||||
if( parser.test( condition, 0, 0, 0 ) )
|
||||
{
|
||||
sb_printf( sb_err,
|
||||
L"%ls: Condition '%ls' contained a syntax error\n",
|
||||
argv[0],
|
||||
condition );
|
||||
|
||||
parser_test( condition, 0, sb_err, argv[0] );
|
||||
parser.test( condition, 0, sb_err, argv[0] );
|
||||
|
||||
res = 1;
|
||||
}
|
||||
@ -523,14 +523,14 @@ static int builtin_complete( wchar_t **argv )
|
||||
{
|
||||
if( comp && wcslen( comp ) )
|
||||
{
|
||||
if( parser_test_args( comp, 0, 0 ) )
|
||||
if( parser.test_args( comp, 0, 0 ) )
|
||||
{
|
||||
sb_printf( sb_err,
|
||||
L"%ls: Completion '%ls' contained a syntax error\n",
|
||||
argv[0],
|
||||
comp );
|
||||
|
||||
parser_test_args( comp, sb_err, argv[0] );
|
||||
parser.test_args( comp, sb_err, argv[0] );
|
||||
|
||||
res = 1;
|
||||
}
|
||||
@ -597,7 +597,7 @@ static int builtin_complete( wchar_t **argv )
|
||||
sb_printf( sb_err,
|
||||
_( L"%ls: Too many arguments\n" ),
|
||||
argv[0] );
|
||||
builtin_print_help( argv[0], sb_err );
|
||||
builtin_print_help( parser, argv[0], sb_err );
|
||||
|
||||
res = 1;
|
||||
}
|
||||
|
@ -160,7 +160,7 @@ static void builtin_jobs_print( job_t *j, int mode, int header )
|
||||
/**
|
||||
The jobs builtin. Used fopr printing running jobs. Defined in builtin_jobs.c.
|
||||
*/
|
||||
static int builtin_jobs( wchar_t **argv )
|
||||
static int builtin_jobs( parser_t &parser, wchar_t **argv )
|
||||
{
|
||||
int argc=0;
|
||||
int found=0;
|
||||
@ -222,7 +222,7 @@ static int builtin_jobs( wchar_t **argv )
|
||||
argv[0],
|
||||
long_options[opt_index].name );
|
||||
|
||||
builtin_print_help( argv[0], sb_err );
|
||||
builtin_print_help( parser, argv[0], sb_err );
|
||||
|
||||
|
||||
return 1;
|
||||
@ -247,11 +247,11 @@ static int builtin_jobs( wchar_t **argv )
|
||||
}
|
||||
|
||||
case 'h':
|
||||
builtin_print_help( argv[0], sb_out );
|
||||
builtin_print_help( parser, argv[0], sb_out );
|
||||
return 0;
|
||||
|
||||
case '?':
|
||||
builtin_unknown_option( argv[0], argv[woptind-1] );
|
||||
builtin_unknown_option( parser, argv[0], argv[woptind-1] );
|
||||
return 1;
|
||||
|
||||
}
|
||||
|
@ -495,7 +495,7 @@ static void print_variables(int include_values, int esc, int scope)
|
||||
The set builtin. Creates, updates and erases environment variables
|
||||
and environemnt variable arrays.
|
||||
*/
|
||||
static int builtin_set( wchar_t **argv )
|
||||
static int builtin_set( parser_t &parser, wchar_t **argv )
|
||||
{
|
||||
|
||||
/**
|
||||
@ -619,11 +619,11 @@ static int builtin_set( wchar_t **argv )
|
||||
break;
|
||||
|
||||
case 'h':
|
||||
builtin_print_help( argv[0], sb_out );
|
||||
builtin_print_help( parser, argv[0], sb_out );
|
||||
return 0;
|
||||
|
||||
case '?':
|
||||
builtin_unknown_option( argv[0], argv[woptind-1] );
|
||||
builtin_unknown_option( parser, argv[0], argv[woptind-1] );
|
||||
return 1;
|
||||
|
||||
default:
|
||||
@ -646,7 +646,7 @@ static int builtin_set( wchar_t **argv )
|
||||
BUILTIN_ERR_COMBO,
|
||||
argv[0] );
|
||||
|
||||
builtin_print_help( argv[0], sb_err );
|
||||
builtin_print_help( parser, argv[0], sb_err );
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -658,7 +658,7 @@ static int builtin_set( wchar_t **argv )
|
||||
BUILTIN_ERR_COMBO,
|
||||
argv[0] );
|
||||
|
||||
builtin_print_help( argv[0], sb_err );
|
||||
builtin_print_help( parser, argv[0], sb_err );
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -670,7 +670,7 @@ static int builtin_set( wchar_t **argv )
|
||||
sb_printf( sb_err,
|
||||
BUILTIN_ERR_GLOCAL,
|
||||
argv[0] );
|
||||
builtin_print_help( argv[0], sb_err );
|
||||
builtin_print_help( parser, argv[0], sb_err );
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -682,7 +682,7 @@ static int builtin_set( wchar_t **argv )
|
||||
sb_printf( sb_err,
|
||||
BUILTIN_ERR_EXPUNEXP,
|
||||
argv[0] );
|
||||
builtin_print_help( argv[0], sb_err );
|
||||
builtin_print_help( parser, argv[0], sb_err );
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -728,7 +728,7 @@ static int builtin_set( wchar_t **argv )
|
||||
|
||||
if( !parse_index( indexes, arg, dest, result.size() ) )
|
||||
{
|
||||
builtin_print_help( argv[0], sb_err );
|
||||
builtin_print_help( parser, argv[0], sb_err );
|
||||
retcode = 1;
|
||||
break;
|
||||
}
|
||||
@ -774,7 +774,7 @@ static int builtin_set( wchar_t **argv )
|
||||
_(L"%ls: Erase needs a variable name\n%ls\n"),
|
||||
argv[0] );
|
||||
|
||||
builtin_print_help( argv[0], sb_err );
|
||||
builtin_print_help( parser, argv[0], sb_err );
|
||||
retcode = 1;
|
||||
}
|
||||
else
|
||||
@ -800,14 +800,14 @@ static int builtin_set( wchar_t **argv )
|
||||
{
|
||||
free( dest );
|
||||
sb_printf( sb_err, BUILTIN_ERR_VARNAME_ZERO, argv[0] );
|
||||
builtin_print_help( argv[0], sb_err );
|
||||
builtin_print_help( parser, argv[0], sb_err );
|
||||
return 1;
|
||||
}
|
||||
|
||||
if( (bad_char = wcsvarname( dest ) ) )
|
||||
{
|
||||
sb_printf( sb_err, BUILTIN_ERR_VARCHAR, argv[0], *bad_char );
|
||||
builtin_print_help( argv[0], sb_err );
|
||||
builtin_print_help( parser, argv[0], sb_err );
|
||||
free( dest );
|
||||
return 1;
|
||||
}
|
||||
@ -816,7 +816,7 @@ static int builtin_set( wchar_t **argv )
|
||||
{
|
||||
free( dest );
|
||||
sb_printf( sb_err, _(L"%ls: Can not specify scope when erasing array slice\n"), argv[0] );
|
||||
builtin_print_help( argv[0], sb_err );
|
||||
builtin_print_help( parser, argv[0], sb_err );
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -848,7 +848,7 @@ static int builtin_set( wchar_t **argv )
|
||||
{
|
||||
if( !parse_index( indexes, argv[woptind], dest, result.size() ) )
|
||||
{
|
||||
builtin_print_help( argv[0], sb_err );
|
||||
builtin_print_help( parser, argv[0], sb_err );
|
||||
retcode = 1;
|
||||
break;
|
||||
}
|
||||
@ -861,7 +861,7 @@ static int builtin_set( wchar_t **argv )
|
||||
if( val_count < idx_count )
|
||||
{
|
||||
sb_printf( sb_err, _(BUILTIN_SET_ARG_COUNT), argv[0] );
|
||||
builtin_print_help( argv[0], sb_err );
|
||||
builtin_print_help( parser, argv[0], sb_err );
|
||||
retcode=1;
|
||||
break;
|
||||
}
|
||||
@ -933,7 +933,7 @@ static int builtin_set( wchar_t **argv )
|
||||
sb_printf( sb_err,
|
||||
_(L"%ls: Values cannot be specfied with erase\n"),
|
||||
argv[0] );
|
||||
builtin_print_help( argv[0], sb_err );
|
||||
builtin_print_help( parser, argv[0], sb_err );
|
||||
retcode=1;
|
||||
}
|
||||
else
|
||||
|
@ -252,7 +252,7 @@ static int set( int resource, int hard, int soft, rlim_t value )
|
||||
The ulimit builtin, used for setting resource limits. Defined in
|
||||
builtin_ulimit.c.
|
||||
*/
|
||||
static int builtin_ulimit( wchar_t ** argv )
|
||||
static int builtin_ulimit( parser_t &parser, wchar_t ** argv )
|
||||
{
|
||||
int hard=0;
|
||||
int soft=0;
|
||||
@ -351,7 +351,7 @@ static int builtin_ulimit( wchar_t ** argv )
|
||||
BUILTIN_ERR_UNKNOWN,
|
||||
argv[0],
|
||||
long_options[opt_index].name );
|
||||
builtin_print_help( argv[0], sb_err );
|
||||
builtin_print_help( parser, argv[0], sb_err );
|
||||
|
||||
return 1;
|
||||
|
||||
@ -415,11 +415,11 @@ static int builtin_ulimit( wchar_t ** argv )
|
||||
#endif
|
||||
|
||||
case L'h':
|
||||
builtin_print_help( argv[0], sb_out );
|
||||
builtin_print_help( parser, argv[0], sb_out );
|
||||
return 0;
|
||||
|
||||
case L'?':
|
||||
builtin_unknown_option( argv[0], argv[woptind-1] );
|
||||
builtin_unknown_option( parser, argv[0], argv[woptind-1] );
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
@ -436,7 +436,7 @@ static int builtin_ulimit( wchar_t ** argv )
|
||||
argv[0],
|
||||
L": Too many arguments\n",
|
||||
NULL );
|
||||
builtin_print_help( argv[0], sb_err );
|
||||
builtin_print_help( parser, argv[0], sb_err );
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -492,7 +492,7 @@ static int builtin_ulimit( wchar_t ** argv )
|
||||
L"%ls: Invalid limit '%ls'\n",
|
||||
argv[0],
|
||||
argv[woptind] );
|
||||
builtin_print_help( argv[0], sb_err );
|
||||
builtin_print_help( parser, argv[0], sb_err );
|
||||
return 1;
|
||||
}
|
||||
new_limit *= get_multiplier( what );
|
||||
@ -507,7 +507,7 @@ static int builtin_ulimit( wchar_t ** argv )
|
||||
argv[0],
|
||||
L": Too many arguments\n",
|
||||
NULL );
|
||||
builtin_print_help( argv[0], sb_err );
|
||||
builtin_print_help( parser, argv[0], sb_err );
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -174,7 +174,7 @@ static int event_is_blocked( event_t *e )
|
||||
block_t *block;
|
||||
event_block_t *eb;
|
||||
|
||||
for( block = current_block; block; block = block->outer )
|
||||
for( block = parser.current_block; block; block = block->outer )
|
||||
{
|
||||
for( eb = block->first_event_block; eb; eb=eb->next )
|
||||
{
|
||||
@ -459,10 +459,10 @@ static void event_fire_internal( event_t *event )
|
||||
*/
|
||||
proc_push_interactive(0);
|
||||
prev_status = proc_get_last_status();
|
||||
parser_push_block( EVENT );
|
||||
current_block->param1.event = event;
|
||||
parser.push_block( EVENT );
|
||||
parser.current_block->param1.event = event;
|
||||
eval( buffer.c_str(), 0, TOP );
|
||||
parser_pop_block();
|
||||
parser.pop_block();
|
||||
proc_pop_interactive();
|
||||
proc_set_last_status( prev_status );
|
||||
}
|
||||
|
8
exec.cpp
8
exec.cpp
@ -1208,10 +1208,10 @@ void exec( job_t *j )
|
||||
break;
|
||||
}
|
||||
|
||||
parser_push_block( shadows?FUNCTION_CALL:FUNCTION_CALL_NO_SHADOW );
|
||||
parser.push_block( shadows?FUNCTION_CALL:FUNCTION_CALL_NO_SHADOW );
|
||||
|
||||
current_block->param2.function_call_process = p;
|
||||
current_block->param1.function_call_name = (wchar_t *)halloc_register( current_block, wcsdup( p->argv[0] ) );
|
||||
parser.current_block->param2.function_call_process = p;
|
||||
parser.current_block->param1.function_call_name = (wchar_t *)halloc_register( current_block, wcsdup( p->argv[0] ) );
|
||||
|
||||
|
||||
/*
|
||||
@ -1234,7 +1234,7 @@ void exec( job_t *j )
|
||||
internal_exec_helper( def, TOP, j->io );
|
||||
|
||||
parser_allow_function();
|
||||
parser_pop_block();
|
||||
parser.pop_block();
|
||||
|
||||
break;
|
||||
}
|
||||
|
@ -204,7 +204,7 @@ void function_destroy()
|
||||
}
|
||||
|
||||
|
||||
void function_add( function_data_t *data )
|
||||
void function_add( function_data_t *data, const parser_t &parser )
|
||||
{
|
||||
int i;
|
||||
|
||||
@ -215,7 +215,7 @@ void function_add( function_data_t *data )
|
||||
|
||||
function_internal_info_t &info = loaded_functions[data->name];
|
||||
|
||||
info.definition_offset = parse_util_lineno( parser_get_buffer(), current_block->tok_pos )-1;
|
||||
info.definition_offset = parse_util_lineno( parser.get_buffer(), parser.current_block->tok_pos )-1;
|
||||
info.definition = data->definition;
|
||||
|
||||
if( data->named_arguments )
|
||||
|
@ -15,6 +15,8 @@
|
||||
#include "util.h"
|
||||
#include "common.h"
|
||||
|
||||
class parser_t;
|
||||
|
||||
/**
|
||||
Structure describing a function. This is used by the parser to
|
||||
store data on a function while parsing it. It is not used
|
||||
|
@ -1863,7 +1863,7 @@ static int parse_job( process_t *p,
|
||||
|
||||
if( new_block )
|
||||
{
|
||||
parser_push_block( WHILE );
|
||||
parser.push_block( WHILE );
|
||||
current_block->param1.while_state=WHILE_TEST_FIRST;
|
||||
current_block->tok_pos = mark;
|
||||
}
|
||||
@ -1876,7 +1876,7 @@ static int parse_job( process_t *p,
|
||||
{
|
||||
tok_next( tok );
|
||||
|
||||
parser_push_block( IF );
|
||||
parser.push_block( IF );
|
||||
|
||||
current_block->param1.if_state=0;
|
||||
current_block->tok_pos = mark;
|
||||
@ -2251,7 +2251,7 @@ static void skipped_exec( job_t * j )
|
||||
( wcscmp( p->argv[0], L"begin" )==0) ||
|
||||
( wcscmp( p->argv[0], L"function" )==0))
|
||||
{
|
||||
parser_push_block( FAKE );
|
||||
parser.push_block( FAKE );
|
||||
}
|
||||
else if( wcscmp( p->argv[0], L"end" )==0)
|
||||
{
|
||||
@ -2537,7 +2537,7 @@ int eval( const wchar_t *cmd, io_data_t *io, enum block_type_t block_type )
|
||||
|
||||
eval_level++;
|
||||
|
||||
parser_push_block( block_type );
|
||||
parser.push_block( block_type );
|
||||
|
||||
current_tokenizer = (tokenizer *)malloc( sizeof(tokenizer));
|
||||
tok_init( current_tokenizer, cmd, 0 );
|
||||
|
18
parser.h
18
parser.h
@ -180,17 +180,31 @@ enum parser_error
|
||||
CMDSUBST_ERROR,
|
||||
};
|
||||
|
||||
enum parser_type_t {
|
||||
PARSER_TYPE_NONE,
|
||||
PARSER_TYPE_GENERAL,
|
||||
PARSER_TYPE_FUNCTIONS_ONLY,
|
||||
PARSER_TYPE_COMPLETIONS_ONLY
|
||||
};
|
||||
|
||||
class parser_t {
|
||||
private:
|
||||
std::vector<block_t> blocks;
|
||||
|
||||
/* No copying allowed */
|
||||
parser_t(const parser_t&);
|
||||
parser_t& operator=(const parser_t&);
|
||||
|
||||
public:
|
||||
|
||||
/** Create a parser of the given type */
|
||||
parser_t(enum parser_type_t type);
|
||||
|
||||
/** The current innermost block */
|
||||
const block_t ¤t_block(void) const;
|
||||
block_t *current_block;
|
||||
|
||||
/** Global event blocks */
|
||||
const block_t &global_event_block(void) const;
|
||||
event_block_t *global_event_block;
|
||||
|
||||
/** Current block level io redirections */
|
||||
io_data_t &block_io(void) const;
|
||||
|
Loading…
x
Reference in New Issue
Block a user