mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-06-08 19:31:14 -03:00
Some changes to migrate towards C++ and a multithreaded model
This commit is contained in:
44
parser.h
44
parser.h
@@ -1,5 +1,5 @@
|
||||
/** \file parser.h
|
||||
The fish parser.
|
||||
The fish parser.
|
||||
*/
|
||||
|
||||
#ifndef FISH_PARSER_H
|
||||
@@ -24,12 +24,12 @@ typedef struct event_block
|
||||
The types of events to block. This is interpreted as a bitset
|
||||
whete the value is 1 for every bit corresponding to a blocked
|
||||
event type. For example, if EVENT_VARIABLE type events should
|
||||
be blocked, (type & 1<<EVENT_BLOCKED) should be set.
|
||||
be blocked, (type & 1<<EVENT_BLOCKED) should be set.
|
||||
|
||||
Note that EVENT_ANY can be used to specify any event.
|
||||
*/
|
||||
int type;
|
||||
|
||||
|
||||
/**
|
||||
The next event_block struct
|
||||
*/
|
||||
@@ -40,7 +40,7 @@ typedef struct event_block
|
||||
|
||||
|
||||
/**
|
||||
block_t represents a block of commands.
|
||||
block_t represents a block of commands.
|
||||
*/
|
||||
typedef struct block
|
||||
{
|
||||
@@ -48,7 +48,7 @@ typedef struct block
|
||||
int skip; /**< Whether execution of the commands in this block should be skipped */
|
||||
int tok_pos; /**< The start index of the block */
|
||||
int had_command; /**< Set to non-zero once a command has been executed in this block */
|
||||
|
||||
|
||||
/**
|
||||
Status for the current loop block. Can be any of the values from the loop_status enum.
|
||||
*/
|
||||
@@ -63,18 +63,18 @@ typedef struct block
|
||||
Block type-specific data
|
||||
*/
|
||||
void *data;
|
||||
|
||||
|
||||
/**
|
||||
First block type specific variable
|
||||
*/
|
||||
union
|
||||
union
|
||||
{
|
||||
int while_state; /**< True if the loop condition has not yet been evaluated*/
|
||||
wchar_t *for_variable; /**< Name of the variable to loop over */
|
||||
int if_state; /**< The state of the if block, can be one of IF_STATE_UNTESTED, IF_STATE_FALSE, IF_STATE_TRUE */
|
||||
wchar_t *switch_value; /**< The value to test in a switch block */
|
||||
const wchar_t *source_dest; /**< The name of the file to source*/
|
||||
event_t *event; /**<The event that triggered this block */
|
||||
event_t *event; /**<The event that triggered this block */
|
||||
wchar_t *function_call_name;
|
||||
} param1;
|
||||
|
||||
@@ -83,7 +83,7 @@ typedef struct block
|
||||
*/
|
||||
union
|
||||
{
|
||||
array_list_t for_vars; /**< List of values for a for block */
|
||||
array_list_t for_vars; /**< List of values for a for block */
|
||||
int switch_taken; /**< Whether a switch match has already been found */
|
||||
process_t *function_call_process; /**< The process representing this function call */
|
||||
} param2;
|
||||
@@ -93,24 +93,24 @@ typedef struct block
|
||||
Name of file that created this block
|
||||
*/
|
||||
const wchar_t *src_filename;
|
||||
|
||||
|
||||
/**
|
||||
Line number where this block was created
|
||||
*/
|
||||
int src_lineno;
|
||||
|
||||
|
||||
/**
|
||||
Some naming confusion. This is a pointer to the first element in the list of all event blocks.
|
||||
*/
|
||||
event_block_t *first_event_block;
|
||||
|
||||
|
||||
/**
|
||||
Next outer block
|
||||
Next outer block
|
||||
*/
|
||||
struct block *outer;
|
||||
struct block *outer;
|
||||
} block_t;
|
||||
|
||||
/**
|
||||
/**
|
||||
Types of blocks
|
||||
*/
|
||||
enum block_type
|
||||
@@ -135,7 +135,7 @@ enum block_type
|
||||
/**
|
||||
Possible states for a loop
|
||||
*/
|
||||
enum loop_status
|
||||
enum loop_status
|
||||
{
|
||||
LOOP_NORMAL, /**< Current loop block executed as normal */
|
||||
LOOP_BREAK, /**< Current loop block should be removed */
|
||||
@@ -159,14 +159,14 @@ enum while_status
|
||||
/**
|
||||
Errors that can be generated by the parser
|
||||
*/
|
||||
enum parser_error
|
||||
enum parser_error
|
||||
{
|
||||
/**
|
||||
No error
|
||||
*/
|
||||
NO_ERR=0,
|
||||
/**
|
||||
An error in the syntax
|
||||
An error in the syntax
|
||||
*/
|
||||
SYNTAX_ERROR,
|
||||
/**
|
||||
@@ -187,7 +187,7 @@ extern block_t *current_block;
|
||||
extern event_block_t *global_event_block;
|
||||
|
||||
/**
|
||||
Current block level io redirections
|
||||
Current block level io redirections
|
||||
*/
|
||||
extern io_data_t *block_io;
|
||||
|
||||
@@ -213,7 +213,7 @@ int eval_args( const wchar_t *line,
|
||||
array_list_t *output );
|
||||
|
||||
/**
|
||||
Sets the current evaluation error. This function should only be used by libraries that are called by
|
||||
Sets the current evaluation error. This function should only be used by libraries that are called by
|
||||
|
||||
\param ec The new error code
|
||||
\param p The character offset at which the error occured
|
||||
@@ -224,7 +224,7 @@ void error( int ec, int p, const wchar_t *str, ... );
|
||||
|
||||
/**
|
||||
Returns a string describing the current parser pisition in the format 'FILENAME (line LINE_NUMBER): LINE'.
|
||||
Example:
|
||||
Example:
|
||||
|
||||
init.fish (line 127): ls|grep pancake
|
||||
*/
|
||||
@@ -315,7 +315,7 @@ void parser_init();
|
||||
void parser_destroy();
|
||||
|
||||
/**
|
||||
This function checks if the specified string is a help option.
|
||||
This function checks if the specified string is a help option.
|
||||
|
||||
\param s the string to test
|
||||
\param min_match is the minimum number of characters that must match in a long style option, i.e. the longest common prefix between --help and any other option. If less than 3, 3 will be assumed.
|
||||
|
||||
Reference in New Issue
Block a user