Syntax highlighting - hakakou/optiperl GitHub Wiki
Syntax highlighting means color coding the script's elements in the editor. The following elements of programming can be colored:
- Whitespace
- String
- Comment
- Identifier
- Integer
- Float (like
2.55
) - Reserved words (like
if, ne, use
etc.) - Delimiters (
.{}[]()
) - Regular Expressions (the pattern in
~, m
) - RegExp Replacement (the replacing text in
s, tr, y
) - Perl Declared Identifier (see below)
- Perl Internal Functions (coloring of internal functions like
print, flock
etc) - Pod (pod text)
- Pod Tags (the tags in pod like
=head 1, =item
) - Perl Variables (color of private variables)
About Perl syntax coding
OptiPerl's perl syntax coding is extremely fast and can color code almost any possible perl code. This includes:
- Multiline q print statements with nested brackets. If html code is actually detected, then html color syntax is used for the string. The same also applies for here-documents.
- Multiline regular expressions. The matching pattern is colored using style "Regular Expressions" and if the pattern is
s, tr, y
then the replacement part is "RegExp Replacement" style
Used identifier coloring. If enabled from Options dialog, this colors all instances of variables and subroutines, with the "Perl Declared Identifier" style only if the identifier has been declared in the same script. However private variables in subroutines, and variables from other modules, are colored using style "Perl Variables". Subroutines used from other modules are colored using style "Identifiers".
Use this unique feature of OptiPerl to minimize errors when calling subroutines and using variables. If while typing the code to call a pre-defined subroutine in the same script, the sub's name does not change to the "Perl Declared Identifier" style (the default is a bold font), then you know that you have a misspelling.
About the "Whitespace" element
The whitespace element has to do with the spacing between words. So the color of the text you select for this element does not affect the colors in the Main and Code Librarian editor, but affects the text color in other editors used in OptiPerl, like RegExp tester, Perl printer etc. This is important if you have selected a dark background for the editor under Options / Editor.
Syntax Coding for other languages
OptiPerl can also color syntax HTML, XML and a plethora of other languages. When you load or create a file, according to its extension OptiPerl decides on the parser it should use. You can also select one while editing from the File Menu / Other Languages. About how OptiPerl makes the decision about the correlation the extension and the default and not default parsers, see Special Files
For HTML documents with / or without scripting languages, instead of the above the following are used:
- Html tags
- Html params
- Script Whitespace
- Script Number
- Script Comment
- Script String
- Script ResWord
- Script Delimiters
- Emphasis
- System Variable
- Assembler
Special are the following elements:
- Breakpoint: Coloring of the breakpoint lines.
- Error line: When double clicking a line in the "Syntax Check" window.
- Debugger: Line that is about to be executed when debugging.
- Search result: When double clicking a line from the Search Results node in Code Explorer
- Bracket matching: Coloring of brackets when the Bracket Highlighting has been enabled.