« home   paste   Anonymous | Login | Signup for a new account 08-24-2019 16:13 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
0000085 [GeSHi] core feature N/A 06-06-06 05:26 09-13-06 12:56
Reporter BenBE View Status public  
Assigned To nigel
Priority low Resolution open  
Status assigned   Product Version
Summary 0000085: Preview and Postview Functions for Code Parsers
Description In some (rare) cases it might be useful to have the opportunity for the CodeParser to "preview" the source it has to highlight.

This should be realized by letting the CP preview the source it's going to highlight in an order simular to this:
--- Example source ---

function Test(argname: argtype): Foo;
        DEC DWIRD PTR [argname]
        CMP DWORD PTR [argname], $00000000
        JZ @@Finish
        CALL Test

    Result := 0;

        DEC DWIRD PTR [argname]
        CMP DWORD PTR [argname], $00000000
        JZ @@Finish
        CALL Test
--- Example Call Order ---

CP_preview(delphi/delphi) //Introduce the top-most context
CP_parsedata(delphi/delphi) //Process all data up to the first subcontext
CP_preview(delphi/asm) //Introduce the first ASM Block
CP_parsedata(delphi/asm) //Process the first ASM Block
CP_postview(delphi/asm) //Remove the context data of the ASM block
CP_parsedata(delphi/delphi) //Process all data up to the second subcontext
CP_preview(delphi/asm) //Introduce the second ASM Block
CP_parsedata(delphi/asm) //Process the second ASM Block
CP_postview(delphi/asm) //Remove the context data of the ASM block
CP_postview(delphi/delphi) //Remove the context data of the topmost block
--- Example End ---

Within the iterator subcontexts are returned unparsed, i.e. if there was an ASM block or another context that needs subdividing, the preview function would see it as a single string.

This feature then could easily be used to prepare highlighting of source, e.g. to detect variable names or the exact context of tokens that were contextually ambiguous otherwise (cf. the example below).
Additional Information This feature would require the token iterator of 0000084 or at least could be based on that feature.

An example where "look-behind highlighting" along wont do is the following Delphi source:


type TSomeProcType = Procedure;
const Ptr: TSomeProcType = @Foo;
procedure Foo;

with //... being loads of source. If this source was highlighted using simple look-behind highlighting (as the current CP could do) you would have to store nearly all information of the source snippet on the highlighting stack before you knew that Foo in the const declaration was a procedure name instead of a simple variable. TSomeProcType is a type declaration, not a procedure name and Ptr a variable name (Procedure reference, but no procedure!).

If you could skim over the source before going to highlight it, the CP could extract such information beforehand and handle them correctly.
Attached Files

- Relationships

SYSTEM WARNING: Creating default object from empty value

SYSTEM WARNING: Creating default object from empty value

related to 0000081closed nigel Source preprocessing may come in handy for some highlighting difficulties 
parent of 0000084assigned nigel Provide access to tokens through an iterator 
child of 0000033assigned BenBE Highlight Labels after certain instructions 
Not all the children of this issue are yet resolved or closed.

There are no notes attached to this issue.

- Issue History
Date Modified Username Field Change
06-06-06 05:26 BenBE New Issue
06-06-06 05:26 BenBE Status new => assigned
06-06-06 05:26 BenBE Assigned To  => nigel
06-06-06 05:26 BenBE Relationship added parent of 0000084
06-06-06 05:28 BenBE Description Updated
06-06-06 05:28 BenBE Steps to Reproduce Updated
06-06-06 05:28 BenBE Additional Information Updated
06-06-06 05:33 BenBE Additional Information Updated
09-13-06 12:56 BenBE Relationship added related to 0000081
09-13-06 12:57 BenBE Relationship added child of 0000033


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