fluent icon indicating copy to clipboard operation
fluent copied to clipboard

Create a version-specific header for Fluent files

Open Pike opened this issue 6 years ago • 8 comments

For parsers, it's beneficial to be able to detect the version of a Fluent file.

Right now, we can use feature detection pretty well to distinguish 0.4 from 0.5-0.7 syntax.

Might make sense to add a header entry to denote syntax going forward.

I'd go with a semantic comment. # @syntax 1.0 for example.

Pike avatar Nov 07 '18 09:11 Pike

Thanks for filing this. I've had the tab open for a few days now...

Were you thinking about making this part of the syntax (optional or required) or encouraging it as a convention? If it's the former, would it make sense to introduce a new comment type for pragma comments, e.g. #!?

stasm avatar Nov 07 '18 13:11 stasm

I'd stick to the realm of semantic comments, whether we require it or not. Effectively, one could treat # @syntax the same way as #!, in particular in a well-known location in the file. Thinking about runtime here specifically.

As a first step, I think we should stake the claim, aka, where to put it, what to put there.

I'd add it generously to documentation, examples, and serializers for this iteration.

Pike avatar Nov 08 '18 13:11 Pike

Is this more of a docs-label issue than syntax, then?

stasm avatar Nov 08 '18 16:11 stasm

Should we already start adding them to tests that use 0.8 features? Namely call expressions and then also 6-hex unicode escapes? Also tests that check for non-\ text, astrals, etc?

Pike avatar Nov 09 '18 14:11 Pike

Why not just do it to all tests in a single PR?

stasm avatar Nov 09 '18 15:11 stasm

We could do that, too.

Pike avatar Nov 09 '18 18:11 Pike

Let's move this out of the Syntax 0.8 milestone and label it with the docs label. I'm not sure we'll actually end up needing the version pragma in 0.x versions of the syntax, but it's something that we could consider for 1.0 and later.

stasm avatar Dec 13 '18 12:12 stasm

It would probably not be a good idea to explicitly support #! pragma comments, as those would quite probably end up at the very beginning of the line, at which point it might get parsed as a shebang line. Or is that intentional, with usage a bit like this?

#!/usr/bin/env fluent-1.0

eemeli avatar Jun 02 '19 17:06 eemeli