improv: updates for full syntax highlighting and to allow interactive compilation errors marked using squiggles under the location of the errors which show the message when hovered. #83
This is the pattern language side of the improvements only. The rest will be submitted to another PR in the ImHex repo. Although the full implementation of the features needs both sides each side can be applied independently to the current master branches of each repo without compile or runtime errors and pass all unit tests, but some of the previous implementation aspects of the features added may not work correctly or at all.
The following changes are included and some bugs were fixed:
Syntax highlights are created using the lexer and the parser and it is completely independent of the text editor. The coloring itself is handled by the editor using a simple interface that is documented using doc comments. The syntax information is collected by the pattern language viewer and updated as the code is being typed which requires the creation of background tasks where the code is lexed and parsed. If errors are generated during lex-parsing they are used to mark the code using under-squiggles and the content of the errors pops up when the affected area is hovered.
Added error size detection and display to the errors raised by the lexer so that source code can be properly marked.
Added comparison operators to Location values to facilitate algorithms.
Preprocessor now handles ifdefs using excluded locations which are positions in the code that mark the beggining and the end of excluded code.
The token classes for comments and identifiers now include fields to help identify their different types. For all comments a singleLine boolean and for doc comments an isGlobal boolean. Due to the high number of identifier types an enumeration was created to help classification.
Excessive and unneeded scope qualifiers were removed when found.
Numeric literals that included a sign (-1, or 1e-4f) were not accepted by the lexer.
Comments were not parsed correctly by lexer. It skipped too many input chars.
The parser has an active role in identifier classification. It does this by adding the appropiate identifier type value to the token when it knows for certain what the type is. For the other cases it adds an approximation (eg function vs member) or just makes the type unknown. Those need to be resolved so that highlighting can be done.
The preprocessor sets the identifier types to all Macro variables defined and/or used.
This is the pattern language side of the improvements only. The rest will be submitted to another PR in the ImHex repo. Although the full implementation of the features needs both sides each side can be applied independently to the current master branches of each repo without compile or runtime errors and pass all unit tests, but some of the previous implementation aspects of the features added may not work correctly or at all.
The following changes are included and some bugs were fixed: