Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Documentation on line wrapping? #255

Open
cpitclaudel opened this issue Jul 30, 2017 · 4 comments
Open

Documentation on line wrapping? #255

cpitclaudel opened this issue Jul 30, 2017 · 4 comments

Comments

@cpitclaudel
Copy link

cpitclaudel commented Jul 30, 2017

It seems it's OK to write this:

pat1: \
  package(x), \
  package(y)

… but not this:

pat1 or \
pat2: package(x), package(y)

Is the syntax of the _tags file documented somewhere? The manual just says that each line should have a glob pattern and tags.

Thanks!

@gasche
Copy link
Member

gasche commented Jul 30, 2017

I'm afraid that line-wrappings are not documented because, as you notice, they are available somewhat inconsistently (it depends on the implementation of each lexer rule). I could try to make sure that all lexer rules accept it wherever whitespace is possible, and document this.

@cpitclaudel
Copy link
Author

That'd be nice :)

@gasche
Copy link
Member

gasche commented Jul 30, 2017

triaging comment: This is a continuation of MPR#6087.

@gasche
Copy link
Member

gasche commented Aug 15, 2017

I looked at implementing this (relaxing the line-escape rules) when the issue was submitted, but it turns out that this is not trivial, because currently there are two parsers, one for glob patterns and one for configuration files, where the latter calls the former but only the latter handles newline and linecount (this relies on the assumption that glob patterns always fit a line). Implemeting this feature requires some refactoring, to ensure that both parsers support a common position-tracking interface. It is not hard, but it would take time, and this work is not a priority for me right now.

(I think this would be a nice task for a evening hacking session.)

Note if someone looks at implementing this: one thing that is odd there is that none of the parsers (for glob patterns and for configuration files) uses a parser generator. Instead there use a somewhat weird scheme where the lexer calls itself recursively to parse a whole AST, not just a single token. It works fine (and is not an issue for the refactoring mentioned above).
I would prefer a more standard lexer+parser divide, but this would introduce on a parser library or generator, which ocamlbuild user would frown upon: I would naturally use Menhir, but we don't want the dependency, same for combinator libraries, and ocamlyacc is both unpalatable (in my developer opinion) and I think a heavier and less convincing depndency than ocamllex, that is a simple and relatively uncontroversial tool. (Concretely, I could foresee a future where "ocamlyacc" is not distributed by default as part of the OCaml distribution, although I am not currently aware of such a plan.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants