home *** CD-ROM | disk | FTP | other *** search
- /*
- * TSyntaxMemoParser Script
- * ------------------------
- *
- * Author : David Brock
- * Date : October 18 1997
- * Language: Object Pascal
- *
- */
-
-
- //--------------------------------------------------------------------------------------------------------------------
- //
- //
- //
- // Macro definitions. Parameters may be specified and the replacement text terminates with the end of
- // line (watch trailing blanks).
- //
- #define pt_DEFAULT 0
- #define pt_COMMENT_LINE 1
- #define pt_IDENTIFIER 2
- #define pt_STRING 3
- #define pt_NUMBER 4
- #define pt_COMMENT 5
- #define pt_HEXNUMBER 6
- #define pt_RESERVED 7
- #define pt_COMMENT_BRACE 8
- #define pt_COMMENT_STAR 9
- #define pt_SYMBOL 10
- #define pt_CHAR_DECIMAL 11
- #define pt_CHAR_HEX 12
-
-
- #define pt_SEMICOLON 20
- #define pt_PROPERTY 21
- #define pt_DEFAULT_TOKEN 22
- #define pt_READ 23
- #define pt_WRITE 24
- #define pt_STORED 25
- #define pt_EXPORTS 26
- #define pt_NAME 27
- #define pt_INDEX 28
- #define pt_RESIDENT 29
-
- #define _non_alpha_ '[^_A-Za-z0-9]'
- #define _all_chars_ '[\x00-\xFF]'
- #define _dec_digit_ '[0-9]'
- #define _hex_digit_ '[a-fA-F0-9]'
- #define _no_chars_ '[]'
- #define _dont_care_ _all_chars_
- #define _DEFAULT_BACKGROUND clWhite
- #define _DEFAULT_FOREGROUND clBlack
-
- #define ss_START 0
- #define ss_PROPERTY 1
- #define ss_EXPORTS 2
-
-
-
- //--------------------------------------------------------------------------------------------------------------------
- //
- // %%language section
- //
- // Header section. Describes the textual name of the language, case sensitivity and options used by the language.
- //
- %%language
- Name = 'Object Pascal'
- Case = __INSENSITIVE
- Options = __DEFAULT_OPTIONS
- WordWrapColumn = _EDGE
- Gutter = _DEFAULT_GUTTER
- Anchor = _DEFAULT_START_ANCHOR
- MarginWidth = 8
- MarginColor = [*]clWhite
- GutterColor = [*]clYellow
- SelTextColor = [*]clWhite
- SelTextBack = [*]clBlue
- ExampleText = '(* Syntax Highlighting *)\n\
- \program test;\n\
- \var a: string;\n\
- \ b: integer;\n\
- \begin\n\
- \ b := 0;\n\
- \ a := \'\';\n\
- \ while b < 10 do begin\n\
- \ a := a + IntoToStr(b);\n\
- \ inc(b);\n\
- \ end;\n\
- \end.\n'
- EditableStyles ('Reserved word', pt_RESERVED),
- ('Comment', pt_COMMENT),
- ('Identifier', pt_IDENTIFIER),
- ('String', pt_STRING),
- ('Number', pt_NUMBER),
- ('Symbols', pt_SYMBOL),
- ('Default', pt_DEFAULT)
-
-
-
-
-
- //--------------------------------------------------------------------------------------------------------------------
- //
- // %%words section
- //
- // Used to specify simple languge keywords. These are constant value lexemes that always contain the same characters
- // and only require the end style to be specified. The words present here will always be tried first. If they fail
- // then the entries in the %%tokens section will be allowed to try a match.
- //
- // %%words table entries have 3 columns:
- // Column 1 Quoted string giving the characters that make up the word
- // Column 2 Quoted string that specifies how the word is terminated
- // Column 3 Token value returned when word is recognised
- //
- %%words
- '\/\/' _dont_care_ pt_COMMENT_LINE
- '{' _dont_care_ pt_COMMENT_BRACE
- '(*' _dont_care_ pt_COMMENT_STAR
- ':=' _dont_care_ pt_SYMBOL
- '+' _dont_care_ pt_SYMBOL
- '-' _dont_care_ pt_SYMBOL
- '*' _dont_care_ pt_SYMBOL
- '\/' _dont_care_ pt_SYMBOL
- '=' _dont_care_ pt_SYMBOL
- '<>' _dont_care_ pt_SYMBOL
- '<' _dont_care_ pt_SYMBOL
- '>' _dont_care_ pt_SYMBOL
- '<=' _dont_care_ pt_SYMBOL
- '>=' _dont_care_ pt_SYMBOL
- '(' _dont_care_ pt_SYMBOL
- ')' _dont_care_ pt_SYMBOL
- '[' _dont_care_ pt_SYMBOL
- ']' _dont_care_ pt_SYMBOL
- '.' _dont_care_ pt_SYMBOL
- '..' _dont_care_ pt_SYMBOL
- '^' _dont_care_ pt_SYMBOL
- ',' _dont_care_ pt_SYMBOL
- ';' _dont_care_ pt_SEMICOLON [ss_START ss_PROPERTY]
- ':' _dont_care_ pt_SYMBOL
- '@' _dont_care_ pt_SYMBOL
- '#' _dec_digit_ pt_CHAR_DECIMAL
- '#$' _hex_digit_ pt_CHAR_HEX
-
- //
- // TSyntaxMemo v2 introduced keyword tables. These are sets of common language
- // keywords (normally reserved words in the source language) that share a common
- // lexeme definition.
- //
- // Keyword tables are separated by the active states of the parser. It is possible
- // to specify a set of states that must be present for a given keyword table to
- // be used. If no state specification is given then the keyword table will be
- // used in all cases.
- //
- // Keyword tables may be changed at run-time by specifying the state(s) in which
- // the keywords are valid via the DefineKeywordTable method.
- //
- %%kwtables
-
- ForState [ss_PROPERTY] endswith _non_alpha_
- ( pt_DEFAULT_TOKEN is 'default'
- pt_READ is 'read'
- pt_STORED is 'stored'
- pt_WRITE is 'write')
-
- ForState [ss_EXPORTS] endswith _non_alpha_
- ( pt_INDEX is 'index'
- pt_NAME is 'name'
- pt_RESIDENT is 'resident')
-
- //
- // Default keyword table
- //
- ForState [] endswith _non_alpha_
- ( pt_RESERVED is 'and', 'array', 'as', 'asm', 'absolute', 'abstract', 'assembler', 'at', 'automated',
- 'begin',
- 'case', 'const', 'class', 'constructor', 'cdecl',
- 'div', 'do', 'downto', 'destructor', 'dispid', 'dynamic',
- 'else', 'end', 'except', 'external',
- 'false', 'file', 'for', 'forward', 'function', 'finalization', 'finally',
- 'goto',
- 'if', 'in', 'implementation', 'interface', 'inherited', 'initialization', 'inline', 'is',
- 'label', 'library',
- 'mod', 'message',
- 'nil', 'not', 'nodefault',
- 'of', 'or', 'on', 'object', 'override',
- 'procedure', 'program', 'packed', 'pascal', 'private', 'protected', 'public', 'published',
- 'record', 'repeat', 'raise', 'read', 'register', 'resident', 'resourcestring',
- 'set', 'string', 'shl', 'shr', 'stdcall',
- 'then', 'to', 'true', 'type', 'threadvar', 'try',
- 'until', 'unit', 'uses',
- 'var', 'virtual',
- 'while', 'with',
- 'xor'
-
- pt_EXPORTS is 'exports'
- pt_PROPERTY is 'property')
-
-
-
- //--------------------------------------------------------------------------------------------------------------------
- //
- // %%handler section
- //
- // The %%handler section gives rules to be applied once an entry in the %%words table has been recognised. Normally
- // no further processing is required but sometimes a token starts with a fixed set of characters but may be followed
- // by a character class rather than a known sequence.
- //
- // %%handler table entries have 4 columns:
- // Column 1 Token value to be processed
- // Column 2 Character specifier that follows recognised word
- // Column 3 Quoted string specifying end sequence
- // Column 4 Whether end sequence is part of lexeme
- //
- // The <character specifier> is defined as:
- // Column 2 A single character specifier or pre-defined system character macro:
- // _PASCAL_CHAR Pascal style character specifier
- // _C_CHAR C style character specifier
- // If the lexeme can optionally have these characters then append '?' to the end
- // of the quoted string.
- // Column 3 Up to 2 characters may be given as a sequence to terminate the lexeme.
- // Characters are specified using a simplified regular expression. If this
- // string is empty then the lexeme will never be matched.
- //
- %%handler
- pt_COMMENT_LINE '[^\n]'? '\n' _discard_
- pt_COMMENT_BRACE '[^}]'? '}' _use_
- pt_COMMENT_STAR _all_chars_? '*)' _use_
- pt_CHAR_DECIMAL _dec_digit_ '[^0-9]' _discard_
- pt_CHAR_HEX _hex_digit_ '[^a-fA-F0-9]' _discard_
-
- //--------------------------------------------------------------------------------------------------------------------
- //
- // %%tokens section
- //
- // Used to specify how to recognise non-fixed lexemes. Non-fixed lexemes are only tried if the table entries in the
- // %%words section have failed. The non-fixed lexeme is defiened by 5 columns as below:
- // Column 1 Token value
- // Column 2 Single start character specifier
- // Column 3 Single contains character specifier
- // Column 4 End sequence specifier
- // Column 5 Whether end sequence is part of lexeme
- // Pre-defined token styles are implemented. If used they should be specified in Column 2. The implemented ones
- // are:
- // __STD_PASCALSTRING Pascal string -- starts with ' ands with ' and uses '' to represent
- // ' within a string. Does not extend beywond end of line.
- // __STD_IDENTIFIER Standard identifier. Starts with [_a-zA-Z], contains [_a-zA-Z0-9] and ends with
- // a non-alpha numeric character that is not part of the lexeme
- // __STD_NUMBER_OR_FP Integer or floating point constant of syntax:
- // <Digit String> [ '.' <Digit string> ] [ e|E [+-] <Digit string> ]
- //
- %%tokens
- pt_HEXNUMBER '$' '[0-9a-fA-F]' '[^0-9a-fA-F]' _discard_
- pt_STRING __STD_PASCALSTRING
- pt_IDENTIFIER __STD_IDENTIFIER [ss_START ss_PROPERTY]
- pt_NUMBER __STD_NUMBER_OR_FP
- pt_DEFAULT '[\s\t\n]' '[\s\t\n]'? '[^\s\t\n]' _discard_
-
-
- //--------------------------------------------------------------------------------------------------------------------
- //
- // %%effects section
- //
- // Used to specify the default colors and font styles used for each token
- //
- // Column 1 Token value
- // Column 2 Font styles
- // Column 3 Foreground color
- // Column 4 Background color
- // Column 5 Optional column specifying whether map entry is a 'hotspot'
- //
- // Columns 1-4 must be completed for all rows, Column 5 defaults to non-hotspot.
- //
- %%effects
- #ifdef ver200
- //
- // Version 2 introduced the overlay of a default color scheme for effects. When active an effect
- // will use the colors in effect slot zero (the default color scheme).
- // To specify effects that use the default color scheme to override their normal colors, append
- // an asterisk to the end of the color value in either the foreground or background column or both.
- //
- pt_DEFAULT [] _DEFAULT_FOREGROUND* _DEFAULT_BACKGROUND*
- pt_IDENTIFIER [] _DEFAULT_FOREGROUND* _DEFAULT_BACKGROUND*
- pt_STRING [fsItalic] _DEFAULT_FOREGROUND* _DEFAULT_BACKGROUND*
- pt_COMMENT [fsItalic] clBlue _DEFAULT_BACKGROUND*
- pt_RESERVED [fsBold] _DEFAULT_FOREGROUND* _DEFAULT_BACKGROUND*
- pt_NUMBER [] clGreen _DEFAULT_BACKGROUND*
- pt_SYMBOL [] _DEFAULT_FOREGROUND* _DEFAULT_BACKGROUND*
- #else
-
- pt_DEFAULT [] _DEFAULT_FOREGROUND _DEFAULT_BACKGROUND
- pt_IDENTIFIER [] _DEFAULT_FOREGROUND _DEFAULT_BACKGROUND
- pt_STRING [fsItalic] _DEFAULT_FOREGROUND _DEFAULT_BACKGROUND
- pt_COMMENT [fsItalic] clBlue _DEFAULT_BACKGROUND
- pt_RESERVED [fsBold] _DEFAULT_FOREGROUND _DEFAULT_BACKGROUND
- pt_NUMBER [] clGreen _DEFAULT_BACKGROUND
- pt_SYMBOL [] _DEFAULT_FOREGROUND _DEFAULT_BACKGROUND
- #endif
-
-
- //--------------------------------------------------------------------------------------------------------------------
- //
- // %%map section
- //
- // Used to specify which entry in the %%effects table each token value uses. By default all token values map onto
- // __DEFAULT_TOKEN which is defined as zero. Table has 2 columns:
- // Column 1 Recognised token value
- // Column 2 Map table entry (i.e. %%effects table entry)
- // Normally the %%map table consists of identical value entries.
- %%map
- pt_IDENTIFIER pt_IDENTIFIER
- pt_STRING pt_STRING
- pt_HEXNUMBER pt_NUMBER
- pt_NUMBER pt_NUMBER
- pt_COMMENT pt_COMMENT
- pt_COMMENT_LINE pt_COMMENT
- pt_COMMENT_STAR pt_COMMENT
- pt_COMMENT_BRACE pt_COMMENT
- pt_RESERVED pt_RESERVED
- pt_SYMBOL pt_SYMBOL
- pt_SEMICOLON pt_SYMBOL
- pt_PROPERTY pt_RESERVED
- pt_READ pt_RESERVED
- pt_WRITE pt_RESERVED
- pt_DEFAULT_TOKEN pt_RESERVED
- pt_STORED pt_RESERVED
- pt_EXPORTS pt_RESERVED
- pt_NAME pt_RESERVED
- pt_INDEX pt_RESERVED
- pt_RESIDENT pt_RESERVED
- pt_CHAR_DECIMAL pt_STRING
- pt_CHAR_HEX pt_STRING
-
- %%states
- pt_PROPERTY (+[ss_PROPERTY] -[ss_START])
- pt_SEMICOLON (+[ss_START] -[ss_PROPERTY ss_EXPORTS])
- pt_EXPORTS (+[ss_EXPORTS])
-
- //
- // v2 specific key assignments separated by conditional compilation
- //
- %%keys
- caLEFT ([] Left) 'Cursor Left'
- caRIGHT ([] Right) 'Cursor Right'
- caLINEHOME ([] Home) 'Line start'
- caLINEEND ([] End) 'Line end'
- caUP ([] Up) 'Line up'
- caDOWN ([] Down) 'Line down'
- caPAGEUP ([] PgUp) 'Page up'
- caPAGEDOWN ([] PgDn) 'Page down'
- caWORDLEFT ([Ctrl] Left) 'Word left'
- caWORDRIGHT ([Ctrl] Right) 'Word right'
- caDOCSTART ([Ctrl] Home) 'Document start'
- caDOCEND ([Ctrl] End) 'Document end'
- caCUT ([Ctrl] 'X') 'Cut to clipboard'
- caCOPY ([Ctrl] 'C' |
- [Ctrl] INSERT) 'Copy to clipboard'
- caPASTE ([Ctrl] 'V' |
- [Shift] INSERT) 'Paste from clipboard'
- caDELETE ([] Delete) 'Delete at cursor'
- caBACKSPACE ([] Backspace) 'Delete before cursor'
- caBLOCKIND ([Ctrl] 'K', 'I') 'Indent block'
- caBLOCKUND ([Ctrl] 'K', 'U') 'Un-Indent block'
- caINSTOGGLE ([] Insert) 'Toggle insert / override mode'
- caSETBOOKMARK0 ([Ctrl] 'K', '0') 'Set bookmark 0'
- caSETBOOKMARK1 ([Ctrl] 'K', '1') 'Set bookmark 1'
- caSETBOOKMARK2 ([Ctrl] 'K', '2') 'Set bookmark 2'
- caSETBOOKMARK3 ([Ctrl] 'K', '3') 'Set bookmark 3'
- caSETBOOKMARK4 ([Ctrl] 'K', '4') 'Set bookmark 4'
- caSETBOOKMARK5 ([Ctrl] 'K', '5') 'Set bookmark 5'
- caSETBOOKMARK6 ([Ctrl] 'K', '6') 'Set bookmark 6'
- caSETBOOKMARK7 ([Ctrl] 'K', '7') 'Set bookmark 7'
- caSETBOOKMARK8 ([Ctrl] 'K', '8') 'Set bookmark 8'
- caSETBOOKMARK9 ([Ctrl] 'K', '9') 'Set bookmark 9'
- caGOTOBOOKMARK0 ([Ctrl] 'Q', '0') 'Goto bookmark 0'
- caGOTOBOOKMARK1 ([Ctrl] 'Q', '1') 'Goto bookmark 1'
- caGOTOBOOKMARK2 ([Ctrl] 'Q', '2') 'Goto bookmark 2'
- caGOTOBOOKMARK3 ([Ctrl] 'Q', '3') 'Goto bookmark 3'
- caGOTOBOOKMARK4 ([Ctrl] 'Q', '4') 'Goto bookmark 4'
- caGOTOBOOKMARK5 ([Ctrl] 'Q', '5') 'Goto bookmark 5'
- caGOTOBOOKMARK6 ([Ctrl] 'Q', '6') 'Goto bookmark 6'
- caGOTOBOOKMARK7 ([Ctrl] 'Q', '7') 'Goto bookmark 7'
- caGOTOBOOKMARK8 ([Ctrl] 'Q', '8') 'Goto bookmark 8'
- caGOTOBOOKMARK9 ([Ctrl] 'Q', '9') 'Goto bookmark 9'
- caUNDO ([Ctrl] 'Z') 'Undo'
- caREDO ([Ctrl Shift] 'Z') 'Redo'
- caPRINTSEL ([CTRL] 'K', 'P') 'Print selection'
- //
- // Auto-replace specifiers
- //
- // Format:
- // ActionKeys = <string>
- // <source string> = <replacement string>
- //
- // Notes: If ActionKeys is not specified then it will default to ';,:.=[]\n\t\s'
- //
- %%autoreplace ActionKeys = ';,:.=()[]\{Return}\{Tab}\{Space}'
- 'teh' = 'the'
- '(c)' = '⌐'
- '(r)' = '«'
- '(tm)' = 'Ö'
-
-
- //
- // Code-template specifiers
- //
- // Format:
- // Hotkey = <Key specifier>
- // <template short name> [ <template description> ] <template value>
- //
- // Notes: Within the <template value> specifier, the position of the first '|' (vertical bar) character indicates
- // the position of the caret after the replacement has taken place. If there is no '|' character then the
- // caret will be at the end of the template
- // If Hotkey is not specified then it will default to CTRL J
- //
- %%templates
- Hotkey = ([Ctrl] 'J')
- 'headgp' ( 'Procedure header - general' ) = '///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////\n\
- \//\n\
- \// @procedure |\n\
- \// @author David Brock - dbrock@cqm.co.uk\n\
- \//\n\
- \//\n\
- \//\n\
- \///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////\n\
- procedure '
-
- 'casee' ( 'Case with else clause' ) = 'case | of\n\
- \ :\n\
- \ :\n\
- \ else\n\
- \ end;\n'
-
-