Wiki

Ticket #37 (closed defect: fixed)

Opened 16 years ago

Last modified 16 years ago

Suppress warnings

Reported by: hopscc Owned by: Chuck
Priority: major Milestone:
Component: Cobra Compiler Version: 0.8.0
Keywords: Cc:

Description

First cut at warning suppression - ad hoc suppression on individual lines.
Add a trailing comment to the offending warning generating line containing '.nowarn.' or '.no-warn.' (case insensitive) directly after the #.
e.g.

raise anEvent, this, MyArgs     #.noWarn.

Attachments

noWarn.patch Download (11.8 KB) - added by hopscc 16 years ago.

Change History

Changed 16 years ago by hopscc

Changed 16 years ago by hopscc

  • status changed from new to assigned
  • owner set to Chuck

Later augmentation might include a switch to suppress all warnings (? probably not desirable) and/or some way of suppressing particular classes of warnings (e.g all warnings about unneeded parens) - the latter will probably need some pretty widespread changes to the warning generation code (tagging).

Changed 16 years ago by Chuck

  • status changed from assigned to closed
  • resolution set to fixed

Done. The directive is:

# .no-warnings.

The space between # and . is not relevant. Case-sensitive.

Also, I set up a reg-ex for this format. If we have other future directives, it will be easy to recognize them.

Maybe "%% foo" should be converted over?

Changed 16 years ago by hopscc

  • status changed from closed to reopened
  • type changed from enhancement to defect
  • resolution fixed deleted

The regex is a little too liberal with leading whitespace.
commented out codelines Lines like this

#				.compiler.nameStack.peek.pushName(varr)

cause an unwarranted compiler error re unknown compiler directive...
You get two immediate examples compiling the compiler source code..
(Node.cobra(1014) and Statements.cobra(567) so its hardly uncommon

Leave it as none or single leading space token after the #...
( I tmp changed the regex to begin with 'r'#\s?\.' but thats still liable to cause probs with commented lines with a leading tab)

Probab better to have it as (initial) fixed position in comment if you're goanna do compiler directives this way anyway

Changed 16 years ago by Chuck

So it's ambiguous with the code ".foo.bar". This issue is independent with how many spaces come after the # as seen in the following "commented out code":

    #.foo.bar
    # .foo.bar
    #  .foo.bar

Ideas:

  • Use a different leading character than # (in which case we also don't need the surrounding dots)
  • Use a different punctuation other than period.
  • Change the regex to not match .foo. when followed by a non-space character

Changed 16 years ago by hopscc

yah its ambiguous with arbitrary number of spaces but addressable by only allowing 0 ( or perhaps 1) space before the directive...
i.e directive is only '#.whatever. rest ignored. ( or perhaps '# .whatever. ignored')
commented real code with compiler appearance .whatever. always easily disambiguated with commenting with '# '
allowing leading spaces is (only) for pretty formatting anyway

I'm comfortable with the compiler-directive-as-special-format-comment direction ( especially for per line specs) and I also
like the .[.]*. syntax - easy on the eye and easy to search for (hilite)

The last idea would also work fine - so long as .foo. isnt valid (uncommented) code
# <whitespace> . [<not .>]+ . [<whitespace> <any>|<eoln> is directive, anything else
#<whitespace> . [<not .>]+ . [not <whitespace>]+ is not

Changed 16 years ago by Chuck

  • status changed from reopened to closed
  • resolution set to fixed
Note: See TracTickets for help on using tickets.