I am working on modifying a syntax highlighter written in
javascript and it uses several regexes. I need to add a
language to the avail highlighters and need the following regexes
modified to parse the new language, Delphi/Pascal. Source to the
highlighter is avail here:
http://www.dreamprojections.com/Synt...r/Default.aspx
**********************************************
COMMENTS
**********************************************
regex = new RegExp('//.*$|/\\*[^\\*]*(.)*?\\*/', 'gm');
Matches- single line comment: '// ' until end of line
multi line comment '{' until closing '}'
Example:
// This is a Comment
{
This is
a multiline comment
}
**********************************************
STRINGS
**********************************************
regex = new RegExp('"(?:\\.|[^\\""])*"', 'g');
Matches - any text enclosed in single quotes
if the string contains single quotes it will be
escaped like this:
'isn''t that grand'
Example:
'this is a string'
**********************************************
DIRECTIVES/REGIONS
**********************************************
regex = new RegExp('^\\s*{/$.*', 'gm');
Matches - '{' followed by '$' followed by 1+ Alpha chars
closed with '}'
Example:
{$IFDEF YAHOO} // this is a directive
{$ELSE YAHOO} // this is a directive
{$ENDDEF YAHOO} // this is a directive
{$R *.res} // this is a directive
**********************************************
NUMBERS
**********************************************
regex = new RegExp('/[^\d]/gi', 'g');
Matches - integer = numeric chars only
float = numerics and decimal only, no commas
hex = '$' foloewd by any combination of 'A'-'F'
and/or 0-9
Example:
x := x + 1234; // example of a number
y := y + 1.0; // example of a float number
z := $FFAA; // example of a hex number
for instance, in the first example:
regex = new RegExp('//.*$|/\\*[^\\*]*(.)*?\\*/', 'gm');
Matches - single line comment: '// ' until end of line
multi line comment '{' until closing '}'
Example:
// This is a Comment
{
This is
a multiline comment
}
the line:
regex = new RegExp('//.*$|/\\*[^\\*]*(.)*?\\*/', 'gm');
is the current regex.
the line(s):
- single line comment: '// ' until end of line
multi line comment '{' until closing '}'
spell out what I want the regex to match
and this:
Example:
// This is a Comment
{
This is
a multiline comment
}
Here is another one that I can't figure out.
Source:
asm
MOV AX,1234H
MOV Number,AX
end;
Need to match everything between the 'asm' and 'end;'