Ticket #50 (assigned feature request)

Opened 8 years ago

Last modified 7 years ago

please reject unhandled LANGUAGE pragmas

Reported by: ganesh Owned by: nibro
Priority: minor Milestone: Blue Sky
Component: parser Version: 1.9.x
Keywords: Cc: ganesh


If a LANGUAGE pragma is unrecognised, I think it should be treated as a parse error. This would make it very clear what is going wrong with a file that requires that extension.

Change History

Changed 8 years ago by nibro

  • priority changed from major to minor
  • status changed from new to assigned
  • milestone changed from Full code support to Full document support

After some thinking on this, I think the right way to do this would be to give the programmer the choice, i.e. put another field in the ParseMode? record for how to act on unrecognised pragmas.

Note though that there's a difference between unhandled pragmas (such as UnicodeSyntax?) and unrecognised pragmas. It would probably make sense to fail by default for unhandled pragmas, but accept by default for unrecognised ones.

Further input appreciated.

Changed 8 years ago by ganesh

If an unhandled or unrecognised pragma doesn't affect syntax, then there is an upside to accepting it, since the file can still be parsed fine.

However if it does affect syntax, then I can't see any such upside, since parsing is very likely to fail later with a more cryptic error, or produce a bad result.

So for unhandled pragmas known to affect syntax, failing by default makes perfect sense. If there are any unhandled pragmas known not to affect syntax, then accepting by default would be reasonable, but do any such things exist? As far as unrecognised pragmas go, obviously HSE can't know whether they do affect syntax or not, but my guess is that most pragmas do affect syntax and so I think the default should still be to reject.

Overall it seems to me like it would simplest just to default to rejecting anything unhandled or unrecognised, and have a flag to override this as suggested.

Changed 8 years ago by ganesh

  • cc ganesh added

Changed 7 years ago by nibro

  • milestone changed from Full document support to Blue Sky

Changed 7 years ago by nibro

  • version changed from 1.0.0 to 1.9.x
Note: See TracTickets for help on using tickets.