Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

#204 LUA syntax highlighting with \" or \' (pre15)

closed-accepted
None
5
2013-01-11
2008-09-24
stone1343
No

I don't think this bug has been reported, I hope this is the correct way to submit it. Thanks.

In this string,

s = "part1\"part2\'part3"

jEdit gets really confused. It doesn't properly recognize the escaped " or ' as just another character. Instead, you end up with 2 strings, "part1\" and the other which starts with "part3" and continues until the next ' in the file, so the syntax highlighting is all wrong.

If you change the closing " to ', the 2nd string becomes "part3" and the rest of the syntax highlighting appears ok, but this is misleading because your program is not syntactically correct anymore.

I'm using jEdit 4.3pre15 with Java 1.6.0_03.

Thanks, BTW outstanding editor!!!

Jeff

Discussion

  • stone1343
    stone1343
    2008-09-24

    • summary: LUA syntax highlighting for strings with \" or \' --> LUA syntax highlighting with \" or \' (pre15)
     
  • stone1343
    stone1343
    2008-09-26

    comparing jEdit/trunk/modes/lua.xml and java.xml, I noticed 'ESCAPE="\"' in the <SPAN> tag for LITERAL1. I'd like to try the fix, and see if this is the solution. How can I do that?

     
  • stone1343
    stone1343
    2008-09-26

    Ok, I answered my own question. I downloaded lua.xml (the head revision), renamed it to lua2.xml and defined a new type, tested it - it seems to work fine when I added ESCAPE="\" NO_LINE_BREAK="TRUE" in the <SPAN> tag as described above.

     
  • stone1343
    stone1343
    2008-09-26

    I'm looking at LUA.XML for potentially upgrading it to Lua 5.1. The first thing I looked at is the new format of long brackets, (see http://www.lua.org/manual/5.1/manual.html#2.1 ).

    Instead of just [[ and ]], Lua 5.1 allows [=[ ]=], [==[ ]==], etc. i.e. any number of = between the brackets, as long as they match. It works fine to make copies of the <SPAN> tag, but this isn't the ideal solution. There's nothing in the spec that says you can't use

    text = [==========[
    This is some text
    ]==========]

    ESCAPE = "=" is obviously not the solution. There's no attribute for SPAN that allows it to ignore an arbitrary number of =. Unless the some regexp magic that could be done, it seems the best compromise is just to support a finite number, say [[, [=[, [==[ and [===[ hard-coded in lua.xml.

    Thanks again

     
  • stone1343
    stone1343
    2009-01-31

    Corrected LUA.XML

     
    Attachments
  • stone1343
    stone1343
    2009-01-31

    File Added: lua.xml

     
  • stone1343
    stone1343
    2009-01-31

    File Added: jEditBug2126692.lua

     
  • stone1343
    stone1343
    2009-01-31

    trivially simple test case

     
    Attachments
  • stone1343
    stone1343
    2009-01-31

    Here is the DIFF output between the current lua.xml in SVN, and mine.

    1c1
    < <?xml version="1.0"?>
    ---
    > <?xml version="1.0" encoding="UTF-8"?>
    31,34c31,34
    < <SPAN TYPE="COMMENT1">
    < <BEGIN>--[[</BEGIN>
    < <END>]]</END>
    < </SPAN>
    ---
    > <SPAN_REGEXP TYPE="COMMENT1" HASH_CHARS="--[">
    > <BEGIN>--\[(=*)\[</BEGIN>
    > <END>]$1]</END>
    > </SPAN_REGEXP>
    39c39
    < <SPAN TYPE="LITERAL1">
    ---
    > <SPAN TYPE="LITERAL1" ESCAPE="\">
    43c43
    < <SPAN TYPE="LITERAL1">
    ---
    > <SPAN TYPE="LITERAL1" ESCAPE="\">
    48,51c48,51
    < <SPAN TYPE="LITERAL1">
    < <BEGIN>[[</BEGIN>
    < <END>]]</END>
    < </SPAN>
    ---
    > <SPAN_REGEXP TYPE="LITERAL1" HASH_CHAR="[">
    > <BEGIN>\[(=*)\[</BEGIN>
    > <END>]$1]</END>
    > </SPAN_REGEXP>
    239d238
    <

     
  • Alan Ezust
    Alan Ezust
    2012-02-24

    • labels: 102669 -->
    • milestone: 101609 -->
     
  • Alan Ezust
    Alan Ezust
    2012-02-24

    Moving to patches tracker.

     
  • Alan Ezust
    Alan Ezust
    2012-09-02

    • assigned_to: nobody --> kpouer
     
  • Accepted in rev 22667

     
    • status: open --> closed-accepted