Quantcast

Parentheses

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

Parentheses

fschmidt
Administrator
I want to handle white space differently inside parentheses.  I tried using a counter to track nesting but this doesn't work when an error is encountered.  See this program:

TParser.java

Here the error is reported in the wrong place.

How do you suggest I handle this?
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Parentheses

fschmidt
Administrator
Should I wait for an answer or should I start looking through the parboiled code to suggest a solution?

fschmidt wrote
I want to handle white space differently inside parentheses.  I tried using a counter to track nesting but this doesn't work when an error is encountered.  See this program:

TParser.java

Here the error is reported in the wrong place.

How do you suggest I handle this?
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Parentheses

mathias
Administrator
>> I want to handle white space differently inside parentheses.  I tried
>> using a counter to track nesting but this doesn't work when an error is
>> encountered.  See this program:
>> TParser.java <http://users.parboiled.org/file/n4024125/TParser.java>  
>>
>> Here the error is reported in the wrong place.
>>
>> How do you suggest I handle this?


Sorry, I somehow missed your question.

I would always try to handle such things in the grammar first and only to resort to "hacks" like counters, etc., if a grammar-level solution is either impossible or really impractical.
A grammar-level solution could be, for example, that you pass the white-space handling rules as arguments to the higher-level rules that you'd like to apply inside of parens.
This allows you to reuse the higher-level rules for both "normal" white-sprace section of your grammar as well as "special" things.

HTH and cheers,
Mathias

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

On 17.01.2013, at 02:49, "fschmidt [via parboiled users]" <[hidden email]> wrote:

>
>
> Should I wait for an answer or should I start looking through the parboiled
> code to suggest a solution?
>
>
> fschmidt wrote
>> I want to handle white space differently inside parentheses.  I tried
>> using a counter to track nesting but this doesn't work when an error is
>> encountered.  See this program:
>> TParser.java <http://users.parboiled.org/file/n4024125/TParser.java>  
>>
>> Here the error is reported in the wrong place.
>>
>> How do you suggest I handle this?
>
>
>
>
>
> _______________________________________________
> If you reply to this email, your message will be added to the discussion below:
> http://users.parboiled.org/Parentheses-tp4024125p4024135.html
> To start a new topic under parboiled users, email [hidden email]
> To unsubscribe from parboiled users, visit
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Parentheses

fschmidt
Administrator
mathias wrote
I would always try to handle such things in the grammar first and only to resort to "hacks" like counters, etc., if a grammar-level solution is either impossible or really impractical.
A grammar-level solution could be, for example, that you pass the white-space handling rules as arguments to the higher-level rules that you'd like to apply inside of parens.
This allows you to reuse the higher-level rules for both "normal" white-sprace section of your grammar as well as "special" things.
I tried this and now I get a StackOverflowError.  Here is what I have:

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

Re: Parentheses

mathias
Administrator
You don't need to use the `Var<…>` construct, since you are not setting any values at parser run-time.
Just use Booleans.
This should already make it much easier to debug your grammar...

Cheers,
Mathias

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

On 17.01.2013, at 22:26, "fschmidt [via parboiled users]" <[hidden email]> wrote:

>
>
> mathias wrote
>> I would always try to handle such things in the grammar first and only to
>> resort to "hacks" like counters, etc., if a grammar-level solution is
>> either impossible or really impractical.
>> A grammar-level solution could be, for example, that you pass the
>> white-space handling rules as arguments to the higher-level rules that
>> you'd like to apply inside of parens.
>> This allows you to reuse the higher-level rules for both "normal"
>> white-sprace section of your grammar as well as "special" things.
>
> I tried this and now I get a StackOverflowError.  Here is what I have:
>
> TParser.java <http://users.parboiled.org/file/n4024139/TParser.java>  
>
>
>
>
> _______________________________________________
> If you reply to this email, your message will be added to the discussion below:
> http://users.parboiled.org/Parentheses-tp4024125p4024139.html
> To start a new topic under parboiled users, email [hidden email]
> To unsubscribe from parboiled users, visit
Loading...