#92 Run-Time Stack in the Syntax Highlighter


This patch changes the implementation of subroutines in the syntax highlighter to use a run-time stack instead of "template instantiation". This removes the hard limit on the depth of the call graph and allows recursion. See the thread at https://sourceforge.net/forum/forum.php?thread_id=2459171&forum_id=74214 for details.

In addition to the changes described in that thread, I also pulled the parsing of transition options into its own function, and instead of duplicating most of the option parsing code within the [i]strings case, I called the parse_options function recursively and added an argument to indicate whether we are currently parsing a list of strings. Now you no longer have to scroll horizontally to read the [i]strings code. :-)

Let me know if you have any questions about any of the other changes.


  • Charles J. Tabony

    patch to implement subroutines in the syntax highlighter with a run-time stack

  • Charles J. Tabony

    example jsf that does nested delimiter matching

  • Charles J. Tabony

    text to be highlighted with matching.jsf

  • Charles J. Tabony

    example jsf that highlights complete parenthesized expressions and rotates colors

  • Charles J. Tabony

    text to be highlighted with expr.jsf

  • Charles J. Tabony

    text that demonstrates nested comments in Haskell

  • Charles J. Tabony

    The patch has the changes for both versions of JOE in CVS. Testing my changes with the co-routines version of JOE is a bit harder, because it segfaults before it gets to my code if I try to load a syntax file using the options. If I modify ftyperc to load the right syntax automatically, then it works.

  • Joe Allen

    Joe Allen - 2008-11-01
    • status: open --> closed
  • Joe Allen

    Joe Allen - 2008-11-01

    I think the problem with the co-routines versions of joe is fixed (but coroutines joe is still not ready for release).

  • Charles J. Tabony

    I added the "stack = syntax->stack_base;" line at the last minute, without thinking about it enough, and it turns out it's wrong. That points the stack at the frame for the first subroutine that was called. There is no root frame. "stack" should be set to NULL.

    Also, you forgot to increment "stack_count" in the co-routines version.

    Patch attached.


Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

No, thanks