Trimming behavior of the Pollen Preprocessor #180

Closed
opened 6 years ago by joergen7 · 10 comments
joergen7 commented 6 years ago (Migrated from github.com)

Hello,

I'm trying to use the Pollen preprocessor to augment a programming language I created. I have realized that the Pollen preprocessor trims leading whitespace of its input file. Is there a way to make the preprocessor skip the trimming?

The problem is that the trimming mixes up the line-positions in the source file which makes interpreting error messages a bit of a hassle.

Hello, I'm trying to use the Pollen preprocessor to augment a programming language I created. I have realized that the Pollen preprocessor trims leading whitespace of its input file. Is there a way to make the preprocessor skip the trimming? The problem is that the trimming mixes up the line-positions in the source file which makes interpreting error messages a bit of a hassle.
mbutterick commented 6 years ago (Migrated from github.com)

Possibly, but are you sure you want #lang pollen/pre and not #lang scribble/text?

Possibly, but are you sure you want `#lang pollen/pre` and not `#lang scribble/text`?
joergen7 commented 6 years ago (Migrated from github.com)

Thanks for the hint, I tried out #lang scribble/text. It also trims the leading new lines XD. While I get results, I had to get rid of all occurrences of th @ symbol in my source file to make scribble/text swallow the input.

So if in doubt, I would stay with Pollen because the lozenge syntax is pretty much exactly what I need since it does not interfere with anything else.

Anyway, I just wanted to know whether there is already something in Pollen to retain the line numbers in the output. I guess if you do trim the leading new-lines, you do it for a reason. I don't intend to break anyone's workflow.

Thanks for the hint, I tried out `#lang scribble/text`. It also trims the leading new lines XD. While I get results, I had to get rid of all occurrences of th `@` symbol in my source file to make `scribble/text` swallow the input. So if in doubt, I would stay with Pollen because the lozenge syntax is pretty much exactly what I need since it does not interfere with anything else. Anyway, I just wanted to know whether there is already something in Pollen to retain the line numbers in the output. I guess if you do trim the leading new-lines, you do it for a reason. I don't intend to break anyone's workflow.
mbutterick commented 6 years ago (Migrated from github.com)

OK. Would it suffice to add a setup value that controls whitespace trimming? Meaning, you’d need to supply a "pollen.rkt" with a setup submodule that overrides the value.

OK. Would it suffice to add a `setup` value that controls whitespace trimming? Meaning, you’d need to supply a `"pollen.rkt"` with a `setup` submodule that overrides the value.
joergen7 commented 6 years ago (Migrated from github.com)

I'm not sure if I truly understand the feature. Would the pollen.rkt file need to be located in a fixed position in my file system or would I supply it to raco along with the source file name?

In the setup submodule, I guess I would have to redefine a parameter. Something like (trim-leading-ws #f)?

I'm not sure if I truly understand the feature. Would the `pollen.rkt` file need to be located in a fixed position in my file system or would I supply it to raco along with the source file name? In the setup submodule, I guess I would have to redefine a parameter. Something like `(trim-leading-ws #f)`?
mbutterick commented 6 years ago (Migrated from github.com)

Right. When pollen runs, it looks in the setup submodule of "pollen.rkt" for configuration values. You would put the "pollen.rkt" in the same folder as the Pollen source files, with something like this:

#lang racket/base

(module setup racket/base
  (provide trim-whitespace?)
  (define trim-whitespace? #f))
Right. When `pollen` runs, it looks in the `setup` submodule of `"pollen.rkt"` for configuration values. You would put the `"pollen.rkt"` in the same folder as the Pollen source files, with something like this: ```racket #lang racket/base (module setup racket/base (provide trim-whitespace?) (define trim-whitespace? #f)) ```
mbutterick commented 6 years ago (Migrated from github.com)
[See also](https://docs.racket-lang.org/pollen/Setup.html?q=pollen%2Fsetup)
joergen7 commented 6 years ago (Migrated from github.com)

Ah, I see. Well, since there are already a number of things you can configure this way, I guess one more is not too drastic of a change wrt the user interface.

btw, I don't intend to make your life miserable with my petty problems. If you don't find the time for it or it takes a long time, that's completely fine with me. It's not that anything is broken.

I should probably just go out of my own way and make a proper hashlang already (instead of hijacking other people's preprocessors).

Ah, I see. Well, since there are already a number of things you can configure this way, I guess one more is not too drastic of a change wrt the user interface. btw, I don't intend to make your life miserable with my petty problems. If you don't find the time for it or it takes a long time, that's completely fine with me. It's not that anything is broken. I should probably just go out of my own way and make a proper hashlang already (instead of hijacking other people's preprocessors).
mbutterick commented 6 years ago (Migrated from github.com)

I was very miserable for the three minutes it took to fix this for you ;)

Try this update and see if it does what you want. The sample code above should work.

I was very miserable for the three minutes it took to fix this for you ;) Try this update and see if it does what you want. The sample code above should work.
joergen7 commented 6 years ago (Migrated from github.com)

crazy stuff!

crazy stuff!
joergen7 commented 6 years ago (Migrated from github.com)

Works beautifully. 249 lines go in and 249 lines come out.

Works beautifully. 249 lines go in and 249 lines come out.
Sign in to join this conversation.
No Label
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: mbutterick/pollen#180
Loading…
There is no content yet.