Announcement

Collapse
No announcement yet.

Grammar rule that can handle multiple lines

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Grammar rule that can handle multiple lines

    I'm trying to write a grammar rule to specify that smake-line opening brace and next-line opening brace are unimportant differences e.g.

    module A1_3_data_classes_prov_ext_2 {

    /* Anonymous documentation */

    and

    module A1_3_data_classes_prov_ext_2
    {

    // Anonymous documentation

    I can get the expression to detect space + { + newline for the top one but putting the rule in for the bottom one - which would be newline + { + newline doesn't work. Here are the two regexps I've used:

    \s+[{]\xd\s*

    That one works

    [{]\xd+

    That's what I'm having to use for the second one but really I want it to look like this:

    \xd[{]\xd+

    so that it detects the newline before the brace.

    Am I doing something wrong or is BC3 not able to handle this sort of thing?

    Many thanks for any help you can provide

  • #2
    Hello,

    The RegEx cannot span multiple lines, but if you want to define that any { at the beginning of a line is unimportant, you can use:
    ^[{]
    or
    ^\s*[{]

    Line breaks that separate text are always important since we align by line. Alternatively, you could use an external conversion to Tidy your data, so your brackets are in the same locations. We have a couple of these formats for download on our Alternatives download page, such as Java Tidied:
    Beyond Compare is a multi-platform utility that combines directory compare and file compare functions in one package. Use it to manage source code, keep directories in sync, compare program output, etc.


    Or an Example KB article, here:
    Beyond Compare is a multi-platform utility that combines directory compare and file compare functions in one package. Use it to manage source code, keep directories in sync, compare program output, etc.


    Please note that saving a converted file will save the text in the new format.
    Aaron P Scooter Software

    Comment

    Working...
    X