From 7a12c71a95c90e0d829698db9571735c4c31dbda Mon Sep 17 00:00:00 2001 From: Allen Webster Date: Wed, 14 Sep 2016 19:39:33 -0400 Subject: [PATCH] new code manipulating experiments, fix to relex rule --- 4coder_API.html | 28 ++-- 4coder_default_include.cpp | 4 +- 4coder_types.h | 6 +- 4cpp_lexer.h | 3 - 4cpp_lexer_types.h | 248 +++++++++++++++++----------------- 4ed_file_view.cpp | 40 +++--- buffer/4coder_shared.cpp | 8 +- power/4coder_experiments.cpp | 255 ++++++++++++++++++++++++++++++++++- 8 files changed, 428 insertions(+), 164 deletions(-) diff --git a/4coder_API.html b/4coder_API.html index 2751c6c2..f1ed67c7 100644 --- a/4coder_API.html +++ b/4coder_API.html @@ -130,9 +130,9 @@ that protection flag, the object is still returned from the access call.

instance because it is navigating the file system to open a file.

AccessAll = 0xFF
AccessAll is a catchall access for cases where an access call should always return an object no matter what it's protection flags are.


§3.4.17: Dirty_State

enum Dirty_State;
Description
A Dirty_State value describes whether changes have been made to a buffer or to an underlying file since the last sync time between the two. Saving a buffer -to it's file or loading the buffer from the file both act as sync points.

Values
DirtyState_UpToDate
DirtyState_UpToDate indicates that there are no unsaved changes and - the underlying system file still agrees with the buffer's state.

DirtyState_UnsavedChanges
DirtyState_UnsavedChanges indicates that there have been changes in the - buffer since the last sync point.

DirtyState_UnloadedChanges
DirtyState_UnsavedChanges indicates that the underlying file has been +to it's file or loading the buffer from the file both act as sync points.

Values
DirtyState_UpToDate = 0
DirtyState_UpToDate indicates that there are no unsaved changes and + the underlying system file still agrees with the buffer's state.

DirtyState_UnsavedChanges = 1
DirtyState_UnsavedChanges indicates that there have been changes in the + buffer since the last sync point.

DirtyState_UnloadedChanges = 2
DirtyState_UnsavedChanges indicates that the underlying file has been edited since the last sync point with the buffer.


§3.4.18: Seek_Boundary_Flag

enum Seek_Boundary_Flag;
Description
A Seek_Boundary_Flag field specifies a set of "boundary" types used in seeks for the beginning or end of different types of words.

Values
BoundaryWhitespace = 0x1
BoundaryToken = 0x2
BoundaryAlphanumeric = 0x4
BoundaryCamelCase = 0x8

§3.4.19: Command_Line_Interface_Flag

enum Command_Line_Interface_Flag;
Description
A Command_Line_Interface_Flag field specifies the behavior of a call to a command line interface.

Values
CLI_OverlapWithConflict = 0x1
If CLI_OverlapWithConflict is set if output buffer of the new command is already in use by another command which is still executing, the older command relinquishes control @@ -347,14 +347,14 @@ This token array must be previously allocated with cpp_make_token_array



Cpp_Token_Array lex_file(char *file_name){
    File_Data file = read_whole_file(file_name);
    
    // This array will be automatically grown if it runs
    // out of memory.
    Cpp_Token_Array array = cpp_make_token_array(100);
    
    cpp_lex_file(file.data, file.size, &array);
    
    return(array);
}
See Also

§5.5 Lexer Type Descriptions

§5.5.1: Cpp_Token_Type

enum Cpp_Token_Type;
Description
A Cpp_Token_Type classifies a token to make parsing easier. Some types are not actually output by the lexer, but exist because parsers will also make use of token -types in their own output.

Values
CPP_TOKEN_JUNK
CPP_TOKEN_COMMENT
CPP_PP_INCLUDE
CPP_PP_DEFINE
CPP_PP_UNDEF
CPP_PP_IF
CPP_PP_IFDEF
CPP_PP_IFNDEF
CPP_PP_ELSE
CPP_PP_ELIF
CPP_PP_ENDIF
CPP_PP_ERROR
CPP_PP_IMPORT
CPP_PP_USING
CPP_PP_LINE
CPP_PP_PRAGMA
CPP_PP_STRINGIFY
CPP_PP_CONCAT
CPP_PP_UNKNOWN
CPP_PP_DEFINED
CPP_PP_INCLUDE_FILE
CPP_PP_ERROR_MESSAGE
CPP_TOKEN_KEY_TYPE
CPP_TOKEN_KEY_MODIFIER
CPP_TOKEN_KEY_QUALIFIER
CPP_TOKEN_KEY_OPERATOR
This type is not stored in token output from the lexer.

CPP_TOKEN_KEY_CONTROL_FLOW
CPP_TOKEN_KEY_CAST
CPP_TOKEN_KEY_TYPE_DECLARATION
CPP_TOKEN_KEY_ACCESS
CPP_TOKEN_KEY_LINKAGE
CPP_TOKEN_KEY_OTHER
CPP_TOKEN_IDENTIFIER
CPP_TOKEN_INTEGER_CONSTANT
CPP_TOKEN_CHARACTER_CONSTANT
CPP_TOKEN_FLOATING_CONSTANT
CPP_TOKEN_STRING_CONSTANT
CPP_TOKEN_BOOLEAN_CONSTANT
CPP_TOKEN_STATIC_ASSERT
CPP_TOKEN_BRACKET_OPEN
CPP_TOKEN_BRACKET_CLOSE
CPP_TOKEN_PARENTHESE_OPEN
CPP_TOKEN_PARENTHESE_CLOSE
CPP_TOKEN_BRACE_OPEN
CPP_TOKEN_BRACE_CLOSE
CPP_TOKEN_SEMICOLON
CPP_TOKEN_ELLIPSIS
CPP_TOKEN_STAR
This is an 'ambiguous' token type because it requires - parsing to determine the full nature of the token.

CPP_TOKEN_AMPERSAND
This is an 'ambiguous' token type because it requires - parsing to determine the full nature of the token.

CPP_TOKEN_TILDE
This is an 'ambiguous' token type because it requires - parsing to determine the full nature of the token.

CPP_TOKEN_PLUS
This is an 'ambiguous' token type because it requires - parsing to determine the full nature of the token.

CPP_TOKEN_MINUS
This is an 'ambiguous' token type because it requires - parsing to determine the full nature of the token.

CPP_TOKEN_INCREMENT
This is an 'ambiguous' token type because it requires - parsing to determine the full nature of the token.

CPP_TOKEN_DECREMENT
This is an 'ambiguous' token type because it requires - parsing to determine the full nature of the token.

CPP_TOKEN_SCOPE
CPP_TOKEN_POSTINC
This type is for parser use, it is not output by the lexer.

CPP_TOKEN_POSTDEC
This type is for parser use, it is not output by the lexer.

CPP_TOKEN_FUNC_STYLE_CAST
This type is for parser use, it is not output by the lexer.

CPP_TOKEN_CPP_STYLE_CAST
CPP_TOKEN_CALL
This type is for parser use, it is not output by the lexer.

CPP_TOKEN_INDEX
This type is for parser use, it is not output by the lexer.

CPP_TOKEN_DOT
CPP_TOKEN_ARROW
CPP_TOKEN_PREINC
This token is for parser use, it is not output by the lexer.

CPP_TOKEN_PREDEC
This token is for parser use, it is not output by the lexer.

CPP_TOKEN_POSITIVE
This token is for parser use, it is not output by the lexer.

CPP_TOKEN_NEGAITVE
This token is for parser use, it is not output by the lexer.

CPP_TOKEN_NOT
CPP_TOKEN_BIT_NOT
This type is for parser use, it is not output by the lexer.

CPP_TOKEN_CAST
This type is for parser use, it is not output by the lexer.

CPP_TOKEN_DEREF
This type is for parser use, it is not output by the lexer.

CPP_TOKEN_TYPE_PTR
This type is for parser use, it is not output by the lexer.

CPP_TOKEN_ADDRESS
This type is for parser use, it is not output by the lexer.

CPP_TOKEN_TYPE_REF
This type is for parser use, it is not output by the lexer.

CPP_TOKEN_SIZEOF
CPP_TOKEN_ALIGNOF
CPP_TOKEN_DECLTYPE
CPP_TOKEN_TYPEID
CPP_TOKEN_NEW
CPP_TOKEN_DELETE
CPP_TOKEN_NEW_ARRAY
This type is for parser use, it is not output by the lexer.

CPP_TOKEN_DELETE_ARRAY
This type is for parser use, it is not output by the lexer.

CPP_TOKEN_PTRDOT
CPP_TOKEN_PTRARROW
CPP_TOKEN_MUL
This type is for parser use, it is not output by the lexer.

CPP_TOKEN_DIV
CPP_TOKEN_MOD
CPP_TOKEN_ADD
This type is for parser use, it is not output by the lexer.

CPP_TOKEN_SUB
This type is for parser use, it is not output by the lexer.

CPP_TOKEN_LSHIFT
CPP_TOKEN_RSHIFT
CPP_TOKEN_LESS
CPP_TOKEN_GRTR
CPP_TOKEN_GRTREQ
CPP_TOKEN_LESSEQ
CPP_TOKEN_EQEQ
CPP_TOKEN_NOTEQ
CPP_TOKEN_BIT_AND
This type is for parser use, it is not output by the lexer.

CPP_TOKEN_BIT_XOR
CPP_TOKEN_BIT_OR
CPP_TOKEN_AND
CPP_TOKEN_OR
CPP_TOKEN_TERNARY_QMARK
CPP_TOKEN_COLON
CPP_TOKEN_THROW
CPP_TOKEN_EQ
CPP_TOKEN_ADDEQ
CPP_TOKEN_SUBEQ
CPP_TOKEN_MULEQ
CPP_TOKEN_DIVEQ
CPP_TOKEN_MODEQ
CPP_TOKEN_LSHIFTEQ
CPP_TOKEN_RSHIFTEQ
CPP_TOKEN_ANDEQ
CPP_TOKEN_OREQ
CPP_TOKEN_XOREQ
CPP_TOKEN_COMMA
CPP_TOKEN_EOF
This type is for parser use, it is not output by the lexer.

CPP_TOKEN_TYPE_COUNT

§5.5.2: Cpp_Token

struct Cpp_Token {
Cpp_Token_Type type;
int32_t start;
int32_t size;
uint16_t state_flags;
uint16_t flags;
};
Description
Cpp_Token represents a single lexed token. +types in their own output.

Values
CPP_TOKEN_JUNK = 0
CPP_TOKEN_COMMENT = 1
CPP_PP_INCLUDE = 2
CPP_PP_DEFINE = 3
CPP_PP_UNDEF = 4
CPP_PP_IF = 5
CPP_PP_IFDEF = 6
CPP_PP_IFNDEF = 7
CPP_PP_ELSE = 8
CPP_PP_ELIF = 9
CPP_PP_ENDIF = 10
CPP_PP_ERROR = 11
CPP_PP_IMPORT = 12
CPP_PP_USING = 13
CPP_PP_LINE = 14
CPP_PP_PRAGMA = 15
CPP_PP_STRINGIFY = 16
CPP_PP_CONCAT = 17
CPP_PP_UNKNOWN = 18
CPP_PP_DEFINED = 19
CPP_PP_INCLUDE_FILE = 20
CPP_PP_ERROR_MESSAGE = 21
CPP_TOKEN_KEY_TYPE = 22
CPP_TOKEN_KEY_MODIFIER = 23
CPP_TOKEN_KEY_QUALIFIER = 24
CPP_TOKEN_KEY_OPERATOR = 25
This type is not stored in token output from the lexer.

CPP_TOKEN_KEY_CONTROL_FLOW = 26
CPP_TOKEN_KEY_CAST = 27
CPP_TOKEN_KEY_TYPE_DECLARATION = 28
CPP_TOKEN_KEY_ACCESS = 29
CPP_TOKEN_KEY_LINKAGE = 30
CPP_TOKEN_KEY_OTHER = 31
CPP_TOKEN_IDENTIFIER = 32
CPP_TOKEN_INTEGER_CONSTANT = 33
CPP_TOKEN_CHARACTER_CONSTANT = 34
CPP_TOKEN_FLOATING_CONSTANT = 35
CPP_TOKEN_STRING_CONSTANT = 36
CPP_TOKEN_BOOLEAN_CONSTANT = 37
CPP_TOKEN_STATIC_ASSERT = 38
CPP_TOKEN_BRACKET_OPEN = 39
CPP_TOKEN_BRACKET_CLOSE = 40
CPP_TOKEN_PARENTHESE_OPEN = 41
CPP_TOKEN_PARENTHESE_CLOSE = 42
CPP_TOKEN_BRACE_OPEN = 43
CPP_TOKEN_BRACE_CLOSE = 44
CPP_TOKEN_SEMICOLON = 45
CPP_TOKEN_ELLIPSIS = 46
CPP_TOKEN_STAR = 47
This is an 'ambiguous' token type because it requires + parsing to determine the full nature of the token.

CPP_TOKEN_AMPERSAND = 48
This is an 'ambiguous' token type because it requires + parsing to determine the full nature of the token.

CPP_TOKEN_TILDE = 49
This is an 'ambiguous' token type because it requires + parsing to determine the full nature of the token.

CPP_TOKEN_PLUS = 50
This is an 'ambiguous' token type because it requires + parsing to determine the full nature of the token.

CPP_TOKEN_MINUS = 51
This is an 'ambiguous' token type because it requires + parsing to determine the full nature of the token.

CPP_TOKEN_INCREMENT = 52
This is an 'ambiguous' token type because it requires + parsing to determine the full nature of the token.

CPP_TOKEN_DECREMENT = 53
This is an 'ambiguous' token type because it requires + parsing to determine the full nature of the token.

CPP_TOKEN_SCOPE = 54
CPP_TOKEN_POSTINC = 55
This type is for parser use, it is not output by the lexer.

CPP_TOKEN_POSTDEC = 56
This type is for parser use, it is not output by the lexer.

CPP_TOKEN_FUNC_STYLE_CAST = 57
This type is for parser use, it is not output by the lexer.

CPP_TOKEN_CPP_STYLE_CAST = 58
CPP_TOKEN_CALL = 59
This type is for parser use, it is not output by the lexer.

CPP_TOKEN_INDEX = 60
This type is for parser use, it is not output by the lexer.

CPP_TOKEN_DOT = 61
CPP_TOKEN_ARROW = 62
CPP_TOKEN_PREINC = 63
This token is for parser use, it is not output by the lexer.

CPP_TOKEN_PREDEC = 64
This token is for parser use, it is not output by the lexer.

CPP_TOKEN_POSITIVE = 65
This token is for parser use, it is not output by the lexer.

CPP_TOKEN_NEGAITVE = 66
This token is for parser use, it is not output by the lexer.

CPP_TOKEN_NOT = 67
CPP_TOKEN_BIT_NOT = 68
This type is for parser use, it is not output by the lexer.

CPP_TOKEN_CAST = 69
This type is for parser use, it is not output by the lexer.

CPP_TOKEN_DEREF = 70
This type is for parser use, it is not output by the lexer.

CPP_TOKEN_TYPE_PTR = 71
This type is for parser use, it is not output by the lexer.

CPP_TOKEN_ADDRESS = 72
This type is for parser use, it is not output by the lexer.

CPP_TOKEN_TYPE_REF = 73
This type is for parser use, it is not output by the lexer.

CPP_TOKEN_SIZEOF = 74
CPP_TOKEN_ALIGNOF = 75
CPP_TOKEN_DECLTYPE = 76
CPP_TOKEN_TYPEID = 77
CPP_TOKEN_NEW = 78
CPP_TOKEN_DELETE = 79
CPP_TOKEN_NEW_ARRAY = 80
This type is for parser use, it is not output by the lexer.

CPP_TOKEN_DELETE_ARRAY = 81
This type is for parser use, it is not output by the lexer.

CPP_TOKEN_PTRDOT = 82
CPP_TOKEN_PTRARROW = 83
CPP_TOKEN_MUL = 84
This type is for parser use, it is not output by the lexer.

CPP_TOKEN_DIV = 85
CPP_TOKEN_MOD = 86
CPP_TOKEN_ADD = 87
This type is for parser use, it is not output by the lexer.

CPP_TOKEN_SUB = 88
This type is for parser use, it is not output by the lexer.

CPP_TOKEN_LSHIFT = 89
CPP_TOKEN_RSHIFT = 90
CPP_TOKEN_LESS = 91
CPP_TOKEN_GRTR = 92
CPP_TOKEN_GRTREQ = 93
CPP_TOKEN_LESSEQ = 94
CPP_TOKEN_EQEQ = 95
CPP_TOKEN_NOTEQ = 96
CPP_TOKEN_BIT_AND = 97
This type is for parser use, it is not output by the lexer.

CPP_TOKEN_BIT_XOR = 98
CPP_TOKEN_BIT_OR = 99
CPP_TOKEN_AND = 100
CPP_TOKEN_OR = 101
CPP_TOKEN_TERNARY_QMARK = 102
CPP_TOKEN_COLON = 103
CPP_TOKEN_THROW = 104
CPP_TOKEN_EQ = 105
CPP_TOKEN_ADDEQ = 106
CPP_TOKEN_SUBEQ = 107
CPP_TOKEN_MULEQ = 108
CPP_TOKEN_DIVEQ = 109
CPP_TOKEN_MODEQ = 110
CPP_TOKEN_LSHIFTEQ = 111
CPP_TOKEN_RSHIFTEQ = 112
CPP_TOKEN_ANDEQ = 113
CPP_TOKEN_OREQ = 114
CPP_TOKEN_XOREQ = 115
CPP_TOKEN_COMMA = 116
CPP_TOKEN_EOF = 117
This type is for parser use, it is not output by the lexer.

CPP_TOKEN_TYPE_COUNT = 118

§5.5.2: Cpp_Token

struct Cpp_Token {
Cpp_Token_Type type;
int32_t start;
int32_t size;
uint16_t state_flags;
uint16_t flags;
};
Description
Cpp_Token represents a single lexed token. It is the primary output of the lexing system.

Fields
type
The type field indicates the type of the token. All tokens have a type no matter the circumstances.

start
The start field indicates the index of the first character of this token's lexeme.

size
The size field indicates the number of bytes in this token's lexeme.

state_flags
The state_flags should not be used outside of the lexer's implementation.

flags
The flags field contains extra useful information about the token.

See Also

§5.5.3: Cpp_Token_Flag

enum Cpp_Token_Flag;
Description
The Cpp_Token_Flags are used to mark up tokens with additional information.

Values
CPP_TFLAG_PP_DIRECTIVE = 0x1
Indicates that the token is a preprocessor directive.

CPP_TFLAG_PP_BODY = 0x2
Indicates that the token is on the line of a preprocessor directive.

CPP_TFLAG_MULTILINE = 0x4
Indicates that the token spans across multiple lines. This can show up @@ -367,6 +367,6 @@ and the count should be initialized to zero.

See Also

§5.5.6: Cpp_Lex_Data

struct Cpp_Lex_Data { /* non-public internals */ } ;
Description
Cpp_Lex_Data represents the state of the lexer so that the system may be resumable and the user can manage the lexer state and decide when to resume lexing with it. To create a new lexer state that has not begun doing any lexing work call cpp_lex_data_init.

-The internals of the lex state should not be treated as a part of the public API.

See Also

§5.5.7: Cpp_Lex_Result

enum Cpp_Lex_Result;
Description
Cpp_Lex_Result is returned from the lexing engine to indicate why it stopped lexing.

Values
LexResult_Finished
This indicates that the system got to the end of the file and will not accept more input.

LexResult_NeedChunk
This indicates that the system got to the end of an input chunk and is ready to receive the - next input chunk.

LexResult_NeedTokenMemory
This indicates that the output array ran out of space to store tokens and needs to be - replaced or expanded before continuing.

LexResult_HitTokenLimit
This indicates that the maximum number of output tokens as specified by the user was hit.


\ No newline at end of file +The internals of the lex state should not be treated as a part of the public API.

See Also
cpp_lex_data_init

§5.5.7: Cpp_Lex_Result

enum Cpp_Lex_Result;
Description
Cpp_Lex_Result is returned from the lexing engine to indicate why it stopped lexing.

Values
LexResult_Finished = 0
This indicates that the system got to the end of the file and will not accept more input.

LexResult_NeedChunk = 1
This indicates that the system got to the end of an input chunk and is ready to receive the + next input chunk.

LexResult_NeedTokenMemory = 2
This indicates that the output array ran out of space to store tokens and needs to be + replaced or expanded before continuing.

LexResult_HitTokenLimit = 3
This indicates that the maximum number of output tokens as specified by the user was hit.


\ No newline at end of file diff --git a/4coder_default_include.cpp b/4coder_default_include.cpp index fa60fd3b..10d0f2f6 100644 --- a/4coder_default_include.cpp +++ b/4coder_default_include.cpp @@ -2338,9 +2338,7 @@ CUSTOM_COMMAND_SIG(replace_in_range){ if (!query_user_string(app, &with)) return; - String r, w; - r = replace.string; - w = with.string; + String r = replace.string, w = with.string; uint32_t access = AccessOpen; View_Summary view = app->get_active_view(app, access); diff --git a/4coder_types.h b/4coder_types.h index e415814b..17c839a8 100644 --- a/4coder_types.h +++ b/4coder_types.h @@ -224,15 +224,15 @@ to it's file or loading the buffer from the file both act as sync points.) */ ENUM(uint32_t, Dirty_State){ /* DOC(DirtyState_UpToDate indicates that there are no unsaved changes and the underlying system file still agrees with the buffer's state.) */ - DirtyState_UpToDate, + DirtyState_UpToDate = 0, /* DOC(DirtyState_UnsavedChanges indicates that there have been changes in the buffer since the last sync point.) */ - DirtyState_UnsavedChanges, + DirtyState_UnsavedChanges = 1, /* DOC(DirtyState_UnsavedChanges indicates that the underlying file has been edited since the last sync point with the buffer.) */ - DirtyState_UnloadedChanges + DirtyState_UnloadedChanges = 2 }; /* DOC(A Seek_Boundary_Flag field specifies a set of "boundary" types used in seeks for the diff --git a/4cpp_lexer.h b/4cpp_lexer.h index be0057a7..1ce4134d 100644 --- a/4cpp_lexer.h +++ b/4cpp_lexer.h @@ -276,9 +276,6 @@ cpp_pp_directive_to_state(Cpp_Token_Type type){ token_array_out->count = token_i; \ *S_ptr = S; S_ptr->__pc__ = -1; return(n); } -enum Lex_Result{ -}; - FCPP_INTERNAL Cpp_Lex_Result cpp_lex_nonalloc_null_end_no_limit(Cpp_Lex_Data *S_ptr, char *chunk, int32_t size, Cpp_Token_Array *token_array_out){ diff --git a/4cpp_lexer_types.h b/4cpp_lexer_types.h index 3341c2c1..fae2b8b4 100644 --- a/4cpp_lexer_types.h +++ b/4cpp_lexer_types.h @@ -20,216 +20,218 @@ actually output by the lexer, but exist because parsers will also make use of token types in their own output.) */ ENUM(uint32_t, Cpp_Token_Type){ - CPP_TOKEN_JUNK, - CPP_TOKEN_COMMENT, - CPP_PP_INCLUDE, - CPP_PP_DEFINE, - CPP_PP_UNDEF, - CPP_PP_IF, - CPP_PP_IFDEF, - CPP_PP_IFNDEF, - CPP_PP_ELSE, - CPP_PP_ELIF, - CPP_PP_ENDIF, - CPP_PP_ERROR, - CPP_PP_IMPORT, - CPP_PP_USING, - CPP_PP_LINE, - CPP_PP_PRAGMA, - CPP_PP_STRINGIFY, - CPP_PP_CONCAT, - CPP_PP_UNKNOWN, + // IGNORE THIS + CPP_TOKEN_JUNK = 0, + CPP_TOKEN_COMMENT = 1, - CPP_PP_DEFINED, - CPP_PP_INCLUDE_FILE, - CPP_PP_ERROR_MESSAGE, + CPP_PP_INCLUDE = 2, + CPP_PP_DEFINE = 3, + CPP_PP_UNDEF = 4, + CPP_PP_IF = 5, + CPP_PP_IFDEF = 6, + CPP_PP_IFNDEF = 7, + CPP_PP_ELSE = 8, + CPP_PP_ELIF = 9, + CPP_PP_ENDIF = 10, + CPP_PP_ERROR = 11, + CPP_PP_IMPORT = 12, + CPP_PP_USING = 13, + CPP_PP_LINE = 14, + CPP_PP_PRAGMA = 15, + CPP_PP_STRINGIFY = 16, + CPP_PP_CONCAT = 17, + CPP_PP_UNKNOWN = 18, - CPP_TOKEN_KEY_TYPE, - CPP_TOKEN_KEY_MODIFIER, - CPP_TOKEN_KEY_QUALIFIER, + CPP_PP_DEFINED = 19, + CPP_PP_INCLUDE_FILE = 20, + CPP_PP_ERROR_MESSAGE = 21, + + CPP_TOKEN_KEY_TYPE = 22, + CPP_TOKEN_KEY_MODIFIER = 23, + CPP_TOKEN_KEY_QUALIFIER = 24, /* DOC(This type is not stored in token output from the lexer.) */ - CPP_TOKEN_KEY_OPERATOR, - CPP_TOKEN_KEY_CONTROL_FLOW, - CPP_TOKEN_KEY_CAST, - CPP_TOKEN_KEY_TYPE_DECLARATION, - CPP_TOKEN_KEY_ACCESS, - CPP_TOKEN_KEY_LINKAGE, - CPP_TOKEN_KEY_OTHER, + CPP_TOKEN_KEY_OPERATOR = 25, + CPP_TOKEN_KEY_CONTROL_FLOW = 26, + CPP_TOKEN_KEY_CAST = 27, + CPP_TOKEN_KEY_TYPE_DECLARATION = 28, + CPP_TOKEN_KEY_ACCESS = 29, + CPP_TOKEN_KEY_LINKAGE = 30, + CPP_TOKEN_KEY_OTHER = 31, - CPP_TOKEN_IDENTIFIER, - CPP_TOKEN_INTEGER_CONSTANT, - CPP_TOKEN_CHARACTER_CONSTANT, - CPP_TOKEN_FLOATING_CONSTANT, - CPP_TOKEN_STRING_CONSTANT, - CPP_TOKEN_BOOLEAN_CONSTANT, + CPP_TOKEN_IDENTIFIER = 32, + CPP_TOKEN_INTEGER_CONSTANT = 33, + CPP_TOKEN_CHARACTER_CONSTANT = 34, + CPP_TOKEN_FLOATING_CONSTANT = 35, + CPP_TOKEN_STRING_CONSTANT = 36, + CPP_TOKEN_BOOLEAN_CONSTANT = 37, - CPP_TOKEN_STATIC_ASSERT, + CPP_TOKEN_STATIC_ASSERT = 38, - CPP_TOKEN_BRACKET_OPEN, - CPP_TOKEN_BRACKET_CLOSE, - CPP_TOKEN_PARENTHESE_OPEN, - CPP_TOKEN_PARENTHESE_CLOSE, - CPP_TOKEN_BRACE_OPEN, - CPP_TOKEN_BRACE_CLOSE, - CPP_TOKEN_SEMICOLON, - CPP_TOKEN_ELLIPSIS, + CPP_TOKEN_BRACKET_OPEN = 39, + CPP_TOKEN_BRACKET_CLOSE = 40, + CPP_TOKEN_PARENTHESE_OPEN = 41, + CPP_TOKEN_PARENTHESE_CLOSE = 42, + CPP_TOKEN_BRACE_OPEN = 43, + CPP_TOKEN_BRACE_CLOSE = 44, + CPP_TOKEN_SEMICOLON = 45, + CPP_TOKEN_ELLIPSIS = 46, /* DOC(This is an 'ambiguous' token type because it requires parsing to determine the full nature of the token.) */ - CPP_TOKEN_STAR, + CPP_TOKEN_STAR = 47, /* DOC(This is an 'ambiguous' token type because it requires parsing to determine the full nature of the token.) */ - CPP_TOKEN_AMPERSAND, + CPP_TOKEN_AMPERSAND = 48, /* DOC(This is an 'ambiguous' token type because it requires parsing to determine the full nature of the token.) */ - CPP_TOKEN_TILDE, + CPP_TOKEN_TILDE = 49, /* DOC(This is an 'ambiguous' token type because it requires parsing to determine the full nature of the token.) */ - CPP_TOKEN_PLUS, + CPP_TOKEN_PLUS = 50, /* DOC(This is an 'ambiguous' token type because it requires parsing to determine the full nature of the token.) */ - CPP_TOKEN_MINUS, + CPP_TOKEN_MINUS = 51, /* DOC(This is an 'ambiguous' token type because it requires parsing to determine the full nature of the token.) */ - CPP_TOKEN_INCREMENT, + CPP_TOKEN_INCREMENT = 52, /* DOC(This is an 'ambiguous' token type because it requires parsing to determine the full nature of the token.) */ - CPP_TOKEN_DECREMENT, + CPP_TOKEN_DECREMENT = 53, // NOTE(allen): Precedence 1, LtoR - CPP_TOKEN_SCOPE, + CPP_TOKEN_SCOPE = 54, // NOTE(allen): Precedence 2, LtoR /* DOC(This type is for parser use, it is not output by the lexer.) */ - CPP_TOKEN_POSTINC, + CPP_TOKEN_POSTINC = 55, /* DOC(This type is for parser use, it is not output by the lexer.) */ - CPP_TOKEN_POSTDEC, + CPP_TOKEN_POSTDEC = 56, /* DOC(This type is for parser use, it is not output by the lexer.) */ - CPP_TOKEN_FUNC_STYLE_CAST, - CPP_TOKEN_CPP_STYLE_CAST, + CPP_TOKEN_FUNC_STYLE_CAST = 57, + CPP_TOKEN_CPP_STYLE_CAST = 58, /* DOC(This type is for parser use, it is not output by the lexer.) */ - CPP_TOKEN_CALL, + CPP_TOKEN_CALL = 59, /* DOC(This type is for parser use, it is not output by the lexer.) */ - CPP_TOKEN_INDEX, - CPP_TOKEN_DOT, - CPP_TOKEN_ARROW, + CPP_TOKEN_INDEX = 60, + CPP_TOKEN_DOT = 61, + CPP_TOKEN_ARROW = 62, // NOTE(allen): Precedence 3, RtoL /* DOC(This token is for parser use, it is not output by the lexer.) */ - CPP_TOKEN_PREINC, + CPP_TOKEN_PREINC = 63, /* DOC(This token is for parser use, it is not output by the lexer.) */ - CPP_TOKEN_PREDEC, + CPP_TOKEN_PREDEC = 64, /* DOC(This token is for parser use, it is not output by the lexer.) */ - CPP_TOKEN_POSITIVE, + CPP_TOKEN_POSITIVE = 65, /* DOC(This token is for parser use, it is not output by the lexer.) */ - CPP_TOKEN_NEGAITVE, - CPP_TOKEN_NOT, + CPP_TOKEN_NEGAITVE = 66, + CPP_TOKEN_NOT = 67, /* DOC(This type is for parser use, it is not output by the lexer.) */ - CPP_TOKEN_BIT_NOT, + CPP_TOKEN_BIT_NOT = 68, /* DOC(This type is for parser use, it is not output by the lexer.) */ - CPP_TOKEN_CAST, + CPP_TOKEN_CAST = 69, /* DOC(This type is for parser use, it is not output by the lexer.) */ - CPP_TOKEN_DEREF, + CPP_TOKEN_DEREF = 70, /* DOC(This type is for parser use, it is not output by the lexer.) */ - CPP_TOKEN_TYPE_PTR, + CPP_TOKEN_TYPE_PTR = 71, /* DOC(This type is for parser use, it is not output by the lexer.) */ - CPP_TOKEN_ADDRESS, + CPP_TOKEN_ADDRESS = 72, /* DOC(This type is for parser use, it is not output by the lexer.) */ - CPP_TOKEN_TYPE_REF, - CPP_TOKEN_SIZEOF, - CPP_TOKEN_ALIGNOF, - CPP_TOKEN_DECLTYPE, - CPP_TOKEN_TYPEID, - CPP_TOKEN_NEW, - CPP_TOKEN_DELETE, + CPP_TOKEN_TYPE_REF = 73, + CPP_TOKEN_SIZEOF = 74, + CPP_TOKEN_ALIGNOF = 75, + CPP_TOKEN_DECLTYPE = 76, + CPP_TOKEN_TYPEID = 77, + CPP_TOKEN_NEW = 78, + CPP_TOKEN_DELETE = 79, /* DOC(This type is for parser use, it is not output by the lexer.) */ - CPP_TOKEN_NEW_ARRAY, + CPP_TOKEN_NEW_ARRAY = 80, /* DOC(This type is for parser use, it is not output by the lexer.) */ - CPP_TOKEN_DELETE_ARRAY, + CPP_TOKEN_DELETE_ARRAY = 81, // NOTE(allen): Precedence 4, LtoR - CPP_TOKEN_PTRDOT, - CPP_TOKEN_PTRARROW, + CPP_TOKEN_PTRDOT = 82, + CPP_TOKEN_PTRARROW = 83, // NOTE(allen): Precedence 5, LtoR /* DOC(This type is for parser use, it is not output by the lexer.) */ - CPP_TOKEN_MUL, - CPP_TOKEN_DIV, - CPP_TOKEN_MOD, + CPP_TOKEN_MUL = 84, + CPP_TOKEN_DIV = 85, + CPP_TOKEN_MOD = 86, // NOTE(allen): Precedence 6, LtoR /* DOC(This type is for parser use, it is not output by the lexer.) */ - CPP_TOKEN_ADD, + CPP_TOKEN_ADD = 87, /* DOC(This type is for parser use, it is not output by the lexer.) */ - CPP_TOKEN_SUB, + CPP_TOKEN_SUB = 88, // NOTE(allen): Precedence 7, LtoR - CPP_TOKEN_LSHIFT, - CPP_TOKEN_RSHIFT, + CPP_TOKEN_LSHIFT = 89, + CPP_TOKEN_RSHIFT = 90, // NOTE(allen): Precedence 8, LtoR - CPP_TOKEN_LESS, - CPP_TOKEN_GRTR, - CPP_TOKEN_GRTREQ, - CPP_TOKEN_LESSEQ, + CPP_TOKEN_LESS = 91, + CPP_TOKEN_GRTR = 92, + CPP_TOKEN_GRTREQ = 93, + CPP_TOKEN_LESSEQ = 94, // NOTE(allen): Precedence 9, LtoR - CPP_TOKEN_EQEQ, - CPP_TOKEN_NOTEQ, + CPP_TOKEN_EQEQ = 95, + CPP_TOKEN_NOTEQ = 96, // NOTE(allen): Precedence 10, LtoR /* DOC(This type is for parser use, it is not output by the lexer.) */ - CPP_TOKEN_BIT_AND, + CPP_TOKEN_BIT_AND = 97, // NOTE(allen): Precedence 11, LtoR - CPP_TOKEN_BIT_XOR, + CPP_TOKEN_BIT_XOR = 98, // NOTE(allen): Precedence 12, LtoR - CPP_TOKEN_BIT_OR, + CPP_TOKEN_BIT_OR = 99, // NOTE(allen): Precedence 13, LtoR - CPP_TOKEN_AND, + CPP_TOKEN_AND = 100, // NOTE(allen): Precedence 14, LtoR - CPP_TOKEN_OR, + CPP_TOKEN_OR = 101, // NOTE(allen): Precedence 15, RtoL - CPP_TOKEN_TERNARY_QMARK, - CPP_TOKEN_COLON, - CPP_TOKEN_THROW, - CPP_TOKEN_EQ, - CPP_TOKEN_ADDEQ, - CPP_TOKEN_SUBEQ, - CPP_TOKEN_MULEQ, - CPP_TOKEN_DIVEQ, - CPP_TOKEN_MODEQ, - CPP_TOKEN_LSHIFTEQ, - CPP_TOKEN_RSHIFTEQ, - CPP_TOKEN_ANDEQ, - CPP_TOKEN_OREQ, - CPP_TOKEN_XOREQ, + CPP_TOKEN_TERNARY_QMARK = 102, + CPP_TOKEN_COLON = 103, + CPP_TOKEN_THROW = 104, + CPP_TOKEN_EQ = 105, + CPP_TOKEN_ADDEQ = 106, + CPP_TOKEN_SUBEQ = 107, + CPP_TOKEN_MULEQ = 108, + CPP_TOKEN_DIVEQ = 109, + CPP_TOKEN_MODEQ = 110, + CPP_TOKEN_LSHIFTEQ = 111, + CPP_TOKEN_RSHIFTEQ = 112, + CPP_TOKEN_ANDEQ = 113, + CPP_TOKEN_OREQ = 114, + CPP_TOKEN_XOREQ = 115, // NOTE(allen): Precedence 16, LtoR - CPP_TOKEN_COMMA, + CPP_TOKEN_COMMA = 116, /* DOC(This type is for parser use, it is not output by the lexer.) */ - CPP_TOKEN_EOF, + CPP_TOKEN_EOF = 117, - CPP_TOKEN_TYPE_COUNT + CPP_TOKEN_TYPE_COUNT = 118 }; /* DOC(Cpp_Token represents a single lexed token. @@ -354,18 +356,18 @@ struct Cpp_Lex_Data{ /* DOC(Cpp_Lex_Result is returned from the lexing engine to indicate why it stopped lexing.) */ ENUM(int32_t, Cpp_Lex_Result){ /* DOC(This indicates that the system got to the end of the file and will not accept more input.) */ - LexResult_Finished, + LexResult_Finished = 0, /* DOC(This indicates that the system got to the end of an input chunk and is ready to receive the next input chunk.) */ - LexResult_NeedChunk, + LexResult_NeedChunk = 1, /* DOC(This indicates that the output array ran out of space to store tokens and needs to be replaced or expanded before continuing.) */ - LexResult_NeedTokenMemory, + LexResult_NeedTokenMemory = 2, /* DOC(This indicates that the maximum number of output tokens as specified by the user was hit.) */ - LexResult_HitTokenLimit, + LexResult_HitTokenLimit = 3, }; ENUM_INTERNAL(uint16_t, Cpp_Preprocessor_State){ diff --git a/4ed_file_view.cpp b/4ed_file_view.cpp index 6292fbba..ab0549a7 100644 --- a/4ed_file_view.cpp +++ b/4ed_file_view.cpp @@ -1941,7 +1941,7 @@ internal void file_edit_cursor_fix(System_Functions *system, Partition *part, General_Memory *general, Editing_File *file, Editing_Layout *layout, - Cursor_Fix_Descriptor desc){ + Cursor_Fix_Descriptor desc, i32 *shift_out){ Temp_Memory cursor_temp = begin_temp_memory(part); i32 cursor_max = layout->panel_max_count * 2; @@ -1967,13 +1967,20 @@ file_edit_cursor_fix(System_Functions *system, if (cursor_count > 0){ buffer_sort_cursors(cursors, cursor_count); if (desc.is_batch){ - buffer_batch_edit_update_cursors(cursors, cursor_count, - desc.batch, desc.batch_size); + i32 shift_total = + buffer_batch_edit_update_cursors(cursors, cursor_count, + desc.batch, desc.batch_size); + if (shift_out){ + *shift_out = shift_total; + } } else{ buffer_update_cursors(cursors, cursor_count, desc.start, desc.end, desc.shift_amount + (desc.end - desc.start)); + if (shift_out){ + *shift_out = desc.shift_amount; + } } buffer_unsort_cursors(cursors, cursor_count); @@ -2088,7 +2095,7 @@ file_do_single_edit(System_Functions *system, desc.end = end; desc.shift_amount = shift_amount; - file_edit_cursor_fix(system, part, general, file, layout, desc); + file_edit_cursor_fix(system, part, general, file, layout, desc, 0); #if BUFFER_EXPERIMENT_SCALPEL <= 0 // NOTE(allen): token fixing @@ -2132,7 +2139,9 @@ file_do_batch_edit(System_Functions *system, Models *models, Editing_File *file, new_data = general_memory_allocate(general, request_amount); } void *old_data = buffer_edit_provide_memory(&file->state.buffer, new_data, request_amount); - if (old_data) general_memory_free(general, old_data); + if (old_data){ + general_memory_free(general, old_data); + } } // NOTE(allen): meta data @@ -2141,18 +2150,21 @@ file_do_batch_edit(System_Functions *system, Models *models, Editing_File *file, i16 font_id = file->settings.font_id; Render_Font *font = get_font_info(models->font_set, font_id)->font; float *advance_data = 0; - if (font) advance_data = font->advance_data; + if (font){ + advance_data = font->advance_data; + } buffer_measure_starts_widths(&state, &file->state.buffer, advance_data); } // NOTE(allen): cursor fixing + i32 shift_total = 0; { Cursor_Fix_Descriptor desc = {}; desc.is_batch = 1; desc.batch = batch; desc.batch_size = batch_size; - file_edit_cursor_fix(system, part, general, file, layout, desc); + file_edit_cursor_fix(system, part, general, file, layout, desc, &shift_total); } // NOTE(allen): token fixing @@ -2160,15 +2172,11 @@ file_do_batch_edit(System_Functions *system, Models *models, Editing_File *file, case BatchEdit_Normal: { if (file->settings.tokens_exist){ - Buffer_Edit *edit = batch; - for (i32 i = 0; i < batch_size; ++i, ++edit){ - i32 start = edit->start; - i32 end = edit->end; - i32 shift_amount = edit->len - (end - start); - if (!file_relex_parallel(system, mem, file, start, end, shift_amount)){ - break; - } - } + // TODO(allen): Write a smart fast one here someday. + Buffer_Edit *first_edit = batch; + Buffer_Edit *last_edit = batch + batch_size - 1; + file_relex_parallel(system, mem, file, first_edit->start, last_edit->end, shift_total); + } }break; diff --git a/buffer/4coder_shared.cpp b/buffer/4coder_shared.cpp index 481aa0ed..50252bc5 100644 --- a/buffer/4coder_shared.cpp +++ b/buffer/4coder_shared.cpp @@ -208,7 +208,7 @@ buffer_batch_edit_max_shift(Buffer_Edit *sorted_edits, int edit_count){ return(shift_max); } -internal_4tech void +internal_4tech int buffer_batch_edit_update_cursors(Cursor_With_Index *sorted_positions, int count, Buffer_Edit *sorted_edits, int edit_count){ Cursor_With_Index *position, *end_position; Buffer_Edit *edit, *end_edit; @@ -241,6 +241,12 @@ buffer_batch_edit_update_cursors(Cursor_With_Index *sorted_positions, int count, for (; position < end_position; ++position){ position->pos += shift_amount; } + + for (; edit < end_edit; ++edit){ + shift_amount += (edit->len - (edit->end - edit->start)); + } + + return(shift_amount); } internal_4tech int diff --git a/power/4coder_experiments.cpp b/power/4coder_experiments.cpp index 5b31f27e..bad55531 100644 --- a/power/4coder_experiments.cpp +++ b/power/4coder_experiments.cpp @@ -309,6 +309,257 @@ CUSTOM_COMMAND_SIG(cursor_to_surrounding_scope){ } } +// NOTE(allen): Some basic code manipulation ideas. + +CUSTOM_COMMAND_SIG(rename_parameter){ + uint32_t access = AccessOpen; + View_Summary view = app->get_active_view(app, access); + Buffer_Summary buffer = app->get_buffer(app, view.buffer_id, access); + + Partition *part = &global_part; + + Temp_Memory temp = begin_temp_memory(part); + Cpp_Token_Array array = buffer_get_all_tokens(app, part, &buffer); + Cpp_Get_Token_Result result = cpp_get_token(&array, view.cursor.pos); + if (!result.in_whitespace && result.token_index < array.count){ + Cpp_Token *token_ptr = &array.tokens[result.token_index]; + Cpp_Token *token_end = array.tokens + array.count - 1; + if (token_ptr->type == CPP_TOKEN_IDENTIFIER){ + char old_lexeme_base[128]; + String old_lexeme = make_fixed_width_string(old_lexeme_base); + if (token_ptr->size < sizeof(old_lexeme_base)){ + + Cpp_Token original_token = *token_ptr; + old_lexeme.size = token_ptr->size; + app->buffer_read_range(app, &buffer, token_ptr->start, + token_ptr->start+token_ptr->size, + old_lexeme.str); + + int32_t proc_body_found = 0; + for (++token_ptr; token_ptr < token_end; ++token_ptr){ + switch (token_ptr->type){ + case CPP_TOKEN_BRACE_OPEN: + { + proc_body_found = 1; + goto doublebreak; + }break; + + case CPP_TOKEN_BRACE_CLOSE: + case CPP_TOKEN_PARENTHESE_OPEN: + { + goto doublebreak; + }break; + } + } + doublebreak:; + + if (proc_body_found){ + + Query_Bar with; + char with_space[1024]; + with.prompt = make_lit_string("New Name: "); + with.string = make_fixed_width_string(with_space); + if (!query_user_string(app, &with)) return; + + String replace_string = with.string; + + Cpp_Token *token_start_ptr = token_ptr+1; + + Buffer_Edit *edits = (Buffer_Edit*)partition_current(part); + int32_t edit_max = (partition_remaining(part))/sizeof(Buffer_Edit); + int32_t edit_count = 0; + + if (edit_max >= 1){ + Buffer_Edit edit; + edit.str_start = 0; + edit.len = replace_string.size; + edit.start = original_token.start; + edit.end = original_token.start + original_token.size; + + edits[edit_count] = edit; + ++edit_count; + } + + int32_t nesting_level = 0; + int32_t closed_correctly = 0; + token_ptr = token_start_ptr; + for (; token_ptr < token_end; ++token_ptr){ + switch (token_ptr->type){ + case CPP_TOKEN_IDENTIFIER: + { + if (token_ptr->size == old_lexeme.size){ + char other_lexeme_base[128]; + String other_lexeme = make_fixed_width_string(other_lexeme_base); + other_lexeme.size = old_lexeme.size; + app->buffer_read_range(app, &buffer, token_ptr->start, + token_ptr->start+token_ptr->size, + other_lexeme.str); + + if (match(old_lexeme, other_lexeme)){ + Buffer_Edit edit; + edit.str_start = 0; + edit.len = replace_string.size; + edit.start = token_ptr->start; + edit.end = token_ptr->start + token_ptr->size; + + if (edit_count < edit_max){ + edits[edit_count] = edit; + ++edit_count; + } + else{ + goto doublebreak2; + } + } + } + }break; + + case CPP_TOKEN_BRACE_OPEN: + { + ++nesting_level; + }break; + + case CPP_TOKEN_BRACE_CLOSE: + { + if (nesting_level == 0){ + closed_correctly = 1; + goto doublebreak2; + } + else{ + --nesting_level; + } + }break; + } + } + doublebreak2:; + + if (closed_correctly){ + app->buffer_batch_edit(app, &buffer, replace_string.str, replace_string.size, + edits, edit_count, BatchEdit_Normal); + } + } + } + } + } + end_temp_memory(temp); +} + +CUSTOM_COMMAND_SIG(write_explicit_enum_values){ + uint32_t access = AccessOpen; + View_Summary view = app->get_active_view(app, access); + Buffer_Summary buffer = app->get_buffer(app, view.buffer_id, access); + + Partition *part = &global_part; + + Temp_Memory temp = begin_temp_memory(part); + Cpp_Token_Array array = buffer_get_all_tokens(app, part, &buffer); + Cpp_Get_Token_Result result = cpp_get_token(&array, view.cursor.pos); + if (!result.in_whitespace && result.token_index < array.count){ + Cpp_Token *token_ptr = &array.tokens[result.token_index]; + Cpp_Token *token_end = array.tokens + array.count; + if (token_ptr->type == CPP_TOKEN_BRACE_OPEN){ + + ++token_ptr; + + int32_t closed_correctly = 0; + Cpp_Token *token_seeker = token_ptr; + for (; token_seeker < token_end; ++token_seeker){ + switch (token_seeker->type){ + case CPP_TOKEN_BRACE_CLOSE: + closed_correctly = 1; + goto finished_seek; + + case CPP_TOKEN_BRACE_OPEN: + goto finished_seek; + } + } + finished_seek:; + + if (closed_correctly){ + int32_t count_estimate = 1 + (int32_t)(token_seeker - token_ptr)/2; + + Buffer_Edit *edits = push_array(part, Buffer_Edit, count_estimate); + int32_t edit_count = 0; + + char *string_base = (char*)partition_current(part); + String string = make_string(string_base, 0, partition_remaining(part)); + + int32_t value = 0; + closed_correctly = 0; + for (;token_ptr < token_end; ++token_ptr){ + switch (token_ptr->type){ + case CPP_TOKEN_IDENTIFIER: + { + int32_t edit_start = token_ptr->start + token_ptr->size; + int32_t edit_stop = edit_start; + + int32_t edit_is_good = 0; + for (++token_ptr; token_ptr < token_end; ++token_ptr){ + switch (token_ptr->type){ + case CPP_TOKEN_COMMA: + { + edit_stop = token_ptr->start; + edit_is_good = 1; + goto good_edit; + }break; + + case CPP_TOKEN_BRACE_CLOSE: + { + edit_stop = token_ptr->start; + closed_correctly = 1; + edit_is_good = 1; + goto good_edit; + }break; + } + } + + good_edit:; + if (edit_is_good){ + int32_t str_pos = string.size; + + append(&string, " = "); + append_int_to_str(&string, value); + if (closed_correctly){ + append(&string, "\n"); + } + ++value; + + int32_t str_size = string.size - str_pos; + + Buffer_Edit edit; + edit.str_start = str_pos; + edit.len = str_size; + edit.start = edit_start; + edit.end = edit_stop; + + assert(edit_count < count_estimate); + edits[edit_count] = edit; + ++edit_count; + } + if (!edit_is_good || closed_correctly){ + goto finished; + } + }break; + + case CPP_TOKEN_BRACE_CLOSE: + { + closed_correctly = 1; + goto finished; + }break; + } + } + + finished:; + if (closed_correctly){ + app->buffer_batch_edit(app, &buffer, string_base, string.size, + edits, edit_count, BatchEdit_Normal); + } + } + } + } + + end_temp_memory(temp); +} + // TODO(allen): Query theme settings #if 0 CUSTOM_COMMAND_SIG(save_theme_settings){ @@ -402,8 +653,10 @@ get_bindings(void *data, int size){ end_map(context); begin_map(context, my_code_map); - bind(context, ']', MDFR_ALT, mark_matching_brace); bind(context, '[', MDFR_ALT, cursor_to_surrounding_scope); + bind(context, ']', MDFR_ALT, mark_matching_brace); + bind(context, key_insert, MDFR_CTRL, write_explicit_enum_values); + bind(context, 'p', MDFR_ALT, rename_parameter); end_map(context); BIND_4CODER_TESTS(context);