No announcement yet.

Brackets <Yada> vs Quotes "Yada" in txt vs. cpp

  • Filter
  • Time
  • Show
Clear All
new posts

  • Brackets <Yada> vs Quotes "Yada" in txt vs. cpp

    "Yada" yada
    <Yada> yada
    Diff shows:
    <Yada> Yada

    If I instead have File1.cpp and file2.cpp with same content, the diff shows:
    <Yada> Yada

    Is this intentional? Shouldn't the cpp rules also indicate that the words inside are same?
    Granted, the <> inclusion may search another location initially than the "" version... But IMHO it would, in that case, be more helpful to see if the filename inside brackets/quotes is identical.
    (I found this by comparing #include "Yada" vs #include <Yada> lines).

  • #2
    I believe that's because that section is going from a String, to a '<' followed by an Identifier followed by a '>'. If I teach the grammar about the preprocessor or about #includes, then it behaves as you expect.

    I haven't found a grammar entry I'm happy with, though. After playing with this, it seemed like having a preprocessor rule would be good, so I tried to make one for my general use. I can't get it to stop short of consuming comments. I'm using:


    I figured that I could get the comments by placing that rule either before or after the comment rules, but it seems to grab the whole line regardless. Any suggestions?


    • #3
      Michael is correct. Cirrus compares the character type (string/comment/identifier) in addition to the character value, so identical characters can appear as differences if they're different types.

      It looks like MSVC's syntax highlighting works by flagging <xxx> as a string if it's part of a #include directive, which would be best, but our parser can't support that. A decent alternative would be to create explicit #include "Compiler Directive" grammar items with these regular expressions:


      For some reason the "List" grammar category's "Regular Expression" option isn't working right, so you'll need to add those as two "Basic" regular expressions.
      Zoë P Scooter Software


      • #4
        Great thanks! (I didn't even know the grammar was customizable so that was a nice surprise).

        I ended up using these 2 new Grammar (Compiler Directive) regexes:


        (The [^\>]* handles comments like e.g. #include <Yada> //Yada>yada properly).