Quantcast

A question

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

A question

Freewind
Please see:

https://gist.github.com/1086452

I want to use `DoctypeNode` to capture `!!! ABC`, but it only captures ` ABC`, how to solve it?

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

Re: A question

mathias
Administrator
You need to explicitly group the rules that you'd like to get the match over:

    def Doctype = rule {
        group(str("!!!") ~ optional(WhiteSpace ~ Inline)) ~> DoctypeNode
    }

If you just say (as you did):

    def Doctype = rule {
        (str("!!!") ~ optional(WhiteSpace ~ Inline)) ~> DoctypeNode
    }

it is exactly equivalent to (by Scalas operator precedence rules)

   def Doctype = rule {
        str("!!!") ~ optional(WhiteSpace ~ Inline) ~> DoctypeNode
    }

which explains, why you are not seeing the "!!!" in your match extraction.

Cheers,
Mathias

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

On 16.07.2011, at 17:37, Freewind [via parboiled users] wrote:

> Please see:
>
> https://gist.github.com/1086452
>
> I want to use `DoctypeNode` to capture `!!! ABC`, but it only captures ` ABC`, how to solve it?
>
>
>
> If you reply to this email, your message will be added to the discussion below:
> http://users.parboiled.org/A-question-tp3174822p3174822.html
> To start a new topic under parboiled users, email [hidden email]
> To unsubscribe from parboiled users, click here.

Loading...