Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added: rule to objectpascal lexer #888

Merged
merged 4 commits into from
Nov 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions lexers/embedded/objectpascal.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<token type="Text"/>
</rule>
<!-- Compiler Directive -->
<rule pattern="\{[$].*?\}|\{[-](NOD|EXT|OBJ).*?\}">
<rule pattern="\{[$].*?\}|\{[-](NOD|EXT|OBJ).*?\}|\([*][$].*?[*]\)">
<token type="CommentPreproc" />
</rule>
<!-- Comment Single -->
Expand All @@ -50,8 +50,12 @@
<rule pattern="(?i:(\.\.))">
<token type="Operator" />
</rule>
<!-- Control Character -->
<rule pattern="[\#][0-9a-fA-F]*|[0-9]+[xX][0-9a-fA-F]*">
<token type="LiteralStringEscape" />
</rule>
<!-- Numbers -->
<rule pattern="[\$][0-9a-fA-F]*[xX][0-9a-fA-F]*|[\$][0-9a-fA-F]*|[\#][0-9a-fA-F]*|[0-9]+[xX][0-9a-fA-F]*|([0-9]+[0-9a-fA-F]+(?=[hH]))">
<rule pattern="[\$][0-9a-fA-F]*[xX][0-9a-fA-F]*|[\$][0-9a-fA-F]*|([0-9]+[0-9a-fA-F]+(?=[hH]))">
<token type="LiteralNumberHex" />
</rule>
<rule pattern="[0-9]+(\&#39;[0-9]+)*\.[0-9]+(\&#39;[0-9]+)*[eE][+-]?[0-9]+(\&#39;[0-9]+)*|[0-9]+(\&#39;[0-9]+)*\.[0-9]+(\&#39;[0-9]+)*|\d+[eE][+-]?[0-9]+">
Expand Down
2 changes: 2 additions & 0 deletions lexers/testdata/objectpascal.actual
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ var
{-NODEFINE string 'String' } {$OBJTYPENAME string 'NUnicodeString'} { defined in ustring.h }
{-EXTERNALSYM ShortInt 'signed char' } {-OBJTYPENAME ShortInt 'Bzc'}

(*$hints off*) // another valid compiler directive

const
CLineBreak = {$IFDEF POSIX} _AnsiStr(#10) {$ENDIF}
{$IFDEF MSWINDOWS} _AnsiStr(#13#10) {$ENDIF};
Expand Down
13 changes: 9 additions & 4 deletions lexers/testdata/objectpascal.expected
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,11 @@
{"type":"TextWhitespace","value":" "},
{"type":"CommentPreproc","value":"{-OBJTYPENAME ShortInt 'Bzc'}"},
{"type":"Text","value":"\n\n"},
{"type":"CommentPreproc","value":"(*$hints off*)"},
{"type":"TextWhitespace","value":" "},
{"type":"CommentSingle","value":"// another valid compiler directive"},
{"type":"TextWhitespace","value":"\n"},
{"type":"Text","value":"\n"},
{"type":"KeywordReserved","value":"const"},
{"type":"Text","value":"\n"},
{"type":"TextWhitespace","value":" "},
Expand All @@ -420,7 +425,7 @@
{"type":"TextWhitespace","value":" "},
{"type":"Text","value":"_AnsiStr"},
{"type":"Operator","value":"("},
{"type":"LiteralNumberHex","value":"#10"},
{"type":"LiteralStringEscape","value":"#10"},
{"type":"Operator","value":")"},
{"type":"TextWhitespace","value":" "},
{"type":"CommentPreproc","value":"{$ENDIF}"},
Expand All @@ -430,7 +435,7 @@
{"type":"TextWhitespace","value":" "},
{"type":"Text","value":"_AnsiStr"},
{"type":"Operator","value":"("},
{"type":"LiteralNumberHex","value":"#13#10"},
{"type":"LiteralStringEscape","value":"#13#10"},
{"type":"Operator","value":")"},
{"type":"TextWhitespace","value":" "},
{"type":"CommentPreproc","value":"{$ENDIF}"},
Expand Down Expand Up @@ -1725,7 +1730,7 @@
{"type":"TextWhitespace","value":" "},
{"type":"Text","value":"Ord"},
{"type":"Operator","value":"("},
{"type":"LiteralNumberHex","value":"#10"},
{"type":"LiteralStringEscape","value":"#10"},
{"type":"Operator","value":")"},
{"type":"Punctuation","value":"."},
{"type":"Text","value":"ToExtended"},
Expand Down Expand Up @@ -1947,7 +1952,7 @@
{"type":"Operator","value":"%"},
{"type":"Text","value":"fs"},
{"type":"Operator","value":":("},
{"type":"LiteralNumberHex","value":"0x2c"},
{"type":"LiteralStringEscape","value":"0x2c"},
{"type":"Operator","value":")"},
{"type":"Punctuation","value":","},
{"type":"Operator","value":"%"},
Expand Down
Loading