« home   paste   Anonymous | Login | Signup for a new account 09-17-2019 13:15 CEST
* X »
GeSHi - Generic Syntax Highlighter Syntax Coloriser for PHP

Viewing Issue Simple Details Jump to Notes ] View Advanced ] Issue History ] Print ]
ID Category Severity Reproducibility Date Submitted Last Update
0000026 [GeSHi] lang trivial sometimes 12-01-05 07:27 02-18-06 11:51
Reporter BenBE View Status public  
Assigned To BenBE
Priority low Resolution fixed  
Status closed   Product Version 1.1.1alpha2
Summary 0000026: Context-Dependent discarding of keywords
Description For Delphi there has to be done a context-dependend discarding of the register highlight under the circumstance that Register directly follows a procedure declaration.

The following case is very rare thus creating an extra context file doesn't seem very smart, although the only way I can think of handling this case was to create a subcontext for procedures, that will be far too much overhead for such a little exception.
Additional Information The difference between both situations is that in the first case Register is the name of a special procedure (namely to register a component within the Delphi IDE). Therefore it's the procedure name, not a directive.

In the second case Register is a call convention, i.e. a directive and therefore has to be highlighted as such.
Attached Files

- Relationships
related to 0000011closed BenBE "default" keyword after property context is not highlighted 
child of 0000006assigned BenBE Delphi support 

- Notes
12-01-05 09:53
edited on: 12-01-05 09:55

[cancel that - I missed the code].

Well you could easily use the CodeParser stuff for this.

If token is "register" then if previous token was ; then ? else ?.

Check out the codeparser examples to see how you could do it.

12-02-05 08:43

See the Steps for Reproduction for the source examples. Description of the cases as the last part.

procedure Register; //Don't highlight Register (It's a name)

procedure ABC; register; //Highlight Register (It's a directive)
procedure ABC(A: Integer); register; //Highlight Register (It's a directive)
function ABC: Integer; register; //Highlight Register (It's a directive)
function ABC(A: Integer); register; //Highlight Register (It's a directive)

procedure ABC(Register: Integer); register; //Highlight second register only (First one is var name), Second is highlighted (It's a directive).

The first example is the only syntax where Register is used as a identifier name. The last example should be syntacticly correct, but is not used IMHO. So don't worry if it is not handled correctly.


Well, the Code Parser might be an option ... Didn't remembered that this could be handy ;-) How far is support for it ATM?
12-02-05 09:58

Well last weekend I put a bit of work into it so you now have access to the "real" name if the token was aliased. We discussed this as being a requirement for fixing the default keyword bug.

I then edited the delphi code parser class to add support for this, and it works except for the reason I specified on the bug. It's assigned to you for fixing up, so you can get an idea of how it works.

This bug can be fixed in the same way, possibly by this psuedocode:

If token is ; then
  store it
end if
If token is "register" then
  if stored token is ; then
    modify register token to be "directive"
    do nothing
end if

It's up to you to implement it.
12-03-05 02:21

The Register Procedure now is detected as Ident, while the register Directive still get's highlighted correctly. Hope this bug is fixed ;-)
12-03-05 13:36

I detected some glitches in the old fix to this problem causing funny duplication of control symbols ;-) I uploaded a fix of the fix ... Maybe it's doing better.

At least

function ABC(A: Integer; Register: String): String; Register;
Procedure Register; Register; Register;
Property Register : TRegister read Register write Register index Register nodefault; default; register;
TRegister = type Register;

is now highlighted correctly (not fully syntactically correct).

A problem might appear if you do a call to the register procedure which would be
    Register; //errorniously highlighted as directive
But I guess this case is to care to be handled. It simply would require too much parsing thus I'll not handle this!

Revalidate if the changes work now.
12-03-05 18:15

Nope, it fails on this code:

        For X := High(LVal) Downto 0 Do
            LWeights := FWeights[LayerIndex, X];
            Sum := LWeights[High(LWeights)];
            For Y := High(InData) Downto 0 Do
                Sum := Sum + InData[Y] * LWeights[Y];
            LVal[X] := Sum;

At the second to last line, Sum is put after the ;.
12-04-05 02:08

Gotta look into that bug. I guess I already know the reason ;-) Should be done shortly ...
12-04-05 03:12

k, problem was fixed. I accidentially didn't check for stdprocs when ; was detected. I also reordered some LOC to do the Register-Detection bit more efficent.
12-04-05 13:13

I've retested and can confirm it looks like it's fixed.
02-18-06 11:51

Issue closed.

- Issue History
Date Modified Username Field Change
12-01-05 07:27 BenBE New Issue
12-01-05 07:27 BenBE Status new => assigned
12-01-05 07:27 BenBE Assigned To  => BenBE
12-01-05 07:28 BenBE Relationship added child of 0000006
12-01-05 07:37 BenBE Relationship added related to 0000011
12-01-05 09:53 nigel Note Added: 0000078
12-01-05 09:54 nigel Note Edited: 0000078
12-01-05 09:55 nigel Note Edited: 0000078
12-02-05 08:43 BenBE Note Added: 0000079
12-02-05 09:58 nigel Note Added: 0000080
12-02-05 10:20 BenBE Relationship added parent of 0000027
12-03-05 02:21 BenBE Status assigned => resolved
12-03-05 02:21 BenBE Fixed in Version  => 1.1.1alpha3
12-03-05 02:21 BenBE Resolution open => fixed
12-03-05 02:21 BenBE Note Added: 0000083
12-03-05 13:36 BenBE Status resolved => feedback
12-03-05 13:36 BenBE Resolution fixed => reopened
12-03-05 13:36 BenBE Note Added: 0000086
12-03-05 18:15 nigel Note Added: 0000087
12-04-05 02:08 BenBE Note Added: 0000089
12-04-05 03:12 BenBE Note Added: 0000090
12-04-05 13:13 nigel Note Added: 0000093
12-05-05 00:51 BenBE Status feedback => resolved
12-05-05 00:51 BenBE Resolution reopened => fixed
02-18-06 11:51 nigel Status resolved => closed
02-18-06 11:51 nigel Note Added: 0000336


Mantis 1.0.0rc2[^]
Copyright © 2000 - 2005 Mantis Group
60 total queries executed.
41 unique queries executed.
Powered by Mantis Bugtracker