coan 4.2.4
The Line Edit component interface
Collaboration diagram for The Line Edit component interface:

Modules

 Macro-generated code

Files

file  line_edit.c
file  line_edit.h

Defines

#define DELETEABLE_CHR   ((char)001)
#define DELETEABLE_LPAREN   ((char)002)
#define DELETEABLE_RPAREN   ((char)003)
#define DELETEABLE(ch)   ((ch) < 4)

Functions

void keywordedit (const char *replacement)
void delete_paren (size_t lparen_off, size_t rparen_off)
void restore_paren (size_t lparen_off, size_t rparen_off)
void restore_all_paren (void)
void cut_text (char const *start, char const *end)
void truncate_line (size_t off)

Define Documentation

#define DELETEABLE (   ch)    ((ch) < 4)

Macro function to decide if a character in the line-buffer is deleteable

Parameters:
chThe character to test.
Returns:
Non-zero if the character may be deleted.

Definition at line 70 of file line_edit.h.

Referenced by printline_cut().

#define DELETEABLE_CHR   ((char)001)

This character is provisionally inserted in the line buffer to mark it for eventual deletion

Definition at line 55 of file line_edit.h.

#define DELETEABLE_LPAREN   ((char)002)

This character is provisionally inserted in the line buffer in place of a '(' that will eventually be deleted if the line is significantly simplified.

Definition at line 60 of file line_edit.h.

Referenced by delete_paren(), restore_all_paren(), and restore_paren().

#define DELETEABLE_RPAREN   ((char)003)

This character is provisionally inserted in the line buffer in place of a ')' that will eventually be deleted if the line is significantly simplified.

Definition at line 65 of file line_edit.h.

Referenced by delete_paren(), restore_all_paren(), and restore_paren().


Function Documentation

void cut_text ( char const *  start,
char const *  end 
)

Logically delete part of a #-directive in the line buffer.

Parameters:
startStart of text to delete
endStart of further text not to be deleted.

The chunk to be deleted is only "logically" deleted by this function. This is efficient because it avoids shuffling down terminal segments of the buffer in the course of evaluation, when the effect of such editing may be obliterated by subsequent deletions. Physical deletion is performed only once at the end of evaluation, by removing all logically deleted portions of the line-buffer.

The function is only called to delete a truth-functionally redundant operator and one of its operands, so it updates the component state with OPS_CUT

Definition at line 139 of file line_edit.c.

References DELETE_CHARS, and SET_PUBLIC.

Referenced by eval_table().

void delete_paren ( size_t  lparen_off,
size_t  rparen_off 
)

Logically delete a pair of redundant parentheses from a #-directive in the line-buffer.

Parameters:
lparen_offLine buffer offset of the '('
rparen_offLine buffer offset of the ')'

Logical deletion is done by inserting DELETEABLE_LPAREN in the line-buffer in place of the '(' and DELETEABLE_RPAREN in place of the ')'.

If evaluation of the directive results in material simplification (i.e. results in deletions other than deletions of redundant parentheses), then the logically deleted parentheses will be physically deleted when evaluation is complete.

If evaluation of the directive results in no materal simplification then the logically deleted parentheses will finally be restored by restore_all_paren();

The function updates the component state with BRACKETS_PRUNED

Definition at line 93 of file line_edit.c.

References DELETEABLE_LPAREN, DELETEABLE_RPAREN, is_symbol_inner_char(), LINE_START, and SET_PUBLIC.

Referenced by eval_table(), and eval_unary().

Here is the call graph for this function:

void keywordedit ( const char *  replacement)

Replace the keyword of the current directive with another to rectify the CPP syntax for dropped lines, then output the edited directive.

Parameters:
replacementThe keyword with which to replace the current keyword.

Definition at line 84 of file line_edit.c.

References GET_PUBLIC, print(), SET_PUBLIC, and tail_edit().

Referenced by Melif(), Melse(), and Mtrue().

Here is the call graph for this function:

void restore_all_paren ( void  )

Restore logically deleted parentheses to the #-directive in the line buffer when we cannot materially simplify it.

This is done on the principle that if we cannot materially simplify the directive then wev will leave it alone.

The function does not bother to retract BRACKETS_PRUNED from the component state, because this is superflous whenever the the function is called.

Definition at line 126 of file line_edit.c.

References DELETEABLE_LPAREN, DELETEABLE_RPAREN, and GET_PUBLIC.

Referenced by printline_restore_all_paren().

void restore_paren ( size_t  lparen_off,
size_t  rparen_off 
)

Restore a prematurely deleted pair of parentheses in the line buffer.

Parameters:
lparen_offThe offset of the left-hand parenthesis to be restored.
rparen_offThe offset of the right-hand parenthesis to be restored.

Recursive descent parsing obliges us to delete what appear to be superfluous parentheses in the recursive context, but as recursion unwinds it can transpire that deleted parentheses ought to have been retained.

Definition at line 113 of file line_edit.c.

References DELETEABLE_LPAREN, DELETEABLE_RPAREN, LINE_START, and SET_PUBLIC.

Referenced by eval_table().

void truncate_line ( size_t  off)

Truncate the current line at the current text pointer.

Parameters:
offLine buffer offset at which to truncate. This becomes the new length of the line.

Definition at line 152 of file line_edit.c.

References GET_PUBLIC, line_len(), LINE_START, and SET_PUBLIC.

Here is the call graph for this function:

 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines