Quantcast

"Free spacing" matching?

classic Classic list List threaded Threaded
3 messages Options
fge
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

"Free spacing" matching?

fge

Hello,

A lot of parsing is done on files where spacing is of no importance at all between tokens (most programming languages, with a notable exception being COBOL, err... python, nearly all HTML-related technologies, etc).

Is there a shortcut to allow to write, for instance, Sequence(Token1(), Token2()) instead of Sequence(Token1(), Spaces(), Token2())? I was thinking about an annotation, maybe, named FreeSpacing, where you could write something like @FreeSpacing(charset=" \n\r\t\f") in front of a rule, or even a whole parser. Thoughts?
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: "Free spacing" matching?

mathias
Administrator
One trick is to override the `fromStringLiteral` method.
Check [this page](https://github.com/sirthias/parboiled/wiki/Handling-Whitespace) of the documentation...

Cheers,
Mathias

---
[hidden email]
http://www.parboiled.org

On 28.12.2011, at 11:12, fge [via parboiled users] wrote:

> Hello,
>
> A lot of parsing is done on files where spacing is of no importance at all between tokens (most programming languages, with a notable exception being COBOL, err... python, nearly all HTML-related technologies, etc).
>
> Is there a shortcut to allow to write, for instance, Sequence(Token1(), Token2()) instead of Sequence(Token1(), Spaces(), Token2())? I was thinking about an annotation, maybe, named `FreeSpacing`, where you could write something like `@FreeSpacing(charset=" \n\r\t\f")` in front of a rule, or even a whole parser. Thoughts?
>
> If you reply to this email, your message will be added to the discussion below:
> http://users.parboiled.org/Free-spacing-matching-tp3616140p3616140.html
> To start a new topic under parboiled users, email [hidden email]
> To unsubscribe from parboiled users, click here.
> NAML

fge
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: "Free spacing" matching?

fge
mathias wrote
One trick is to override the `fromStringLiteral` method.
Check [this page](https://github.com/sirthias/parboiled/wiki/Handling-Whitespace) of the documentation...

Cheers,
Mathias
OK, will do. Thanks!
Loading...