Need help crafting a Peg rule to deal with strings that include escaped string delimiters

View: New views
14 Messages — Rating Filter:   Alert me  

Need help crafting a Peg rule to deal with strings that include escaped string delimiters

by Jeffery Olson :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


This is a valid string in boo:
'hello, i\'m a string'

Here is the current PegRule that I have to parse strings (based on
Rodrigo's string rule in the miniboo Pegs example):
SingleQuoteString = "'",--(not "'",
any()),"'",{$HandlePegMatch(PegTokenType.SingleQuoteString)}

the callable at the end is extraneous... anywho, i've tried several
approaches to try and get the above example string to parse. Under the
provided SingleQuoteString PegRule, it'd parse as:

'hello, i\' <-- string token
m <-- identifier
a <-- identifier
string <-- keyword (for purposes of syntax colorizing)
and the trailing single-quote would cause the parser to bail out...

this was my initial approach to this issue:
SingleQuoteString = "'",--("""\'""",not "'",
any()),"'",{$HandlePegMatch(PegTokenType.SingleQuoteString)}

this would cause the parser to fail on attempting to parse any
string... anywho.. any thoughts on how to approach this issue?

I just wanted to say that, besides dealing with this, working with
pegs thus far has gone quite well. I am quite taken with the system,
as a whole.

The only other gripe I have (Pegs-wise) is that this PegRule will fail:

Rule = ++("bar" / not "foo" / any() )

in this case, it will fail because of the 'not "foo" ' piece.. changing it to
Rule = ++("bar" / Foo / any() )
Foo = not "foo"

will allow it to compile...

Just wanted to share that.. anywho, any help concerning the string
issue above from anyone also working with Pegs would be greatly
appreciated.

Thanks,
Jeff

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Boo Programming Language" group.
To post to this group, send email to boolang@...
To unsubscribe from this group, send email to boolang-unsubscribe@...
For more options, visit this group at http://groups.google.com/group/boolang
-~----------~----~----~----~------~----~------~--~---


Re: Need help crafting a Peg rule to deal with strings that include escaped string delimiters

by Jeffery Olson :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


If anyone else would like to play around with Boo.Pegs and perhaps
help me in the process troubleshoot this issue, I have a complete
(only needs Boo.Pegs.dll) program at:

http://monoport.com/17851

You can run it, and it'll let you type in a line of code and it'll try
to parse the tokens out of the code.. so you can see for yourself what
i'm talking about with this line parsing issue.

Once again, any help would be greatly appreicated.

Also: yes, i know i used the dreaded goto. I'm lazy and it's just a prototype :P

Cheers,
Jeff

On Wed, Jun 11, 2008 at 4:37 PM, Jeffery Olson <olson.jeffery@...> wrote:

> This is a valid string in boo:
> 'hello, i\'m a string'
>
> Here is the current PegRule that I have to parse strings (based on
> Rodrigo's string rule in the miniboo Pegs example):
> SingleQuoteString = "'",--(not "'",
> any()),"'",{$HandlePegMatch(PegTokenType.SingleQuoteString)}
>
> the callable at the end is extraneous... anywho, i've tried several
> approaches to try and get the above example string to parse. Under the
> provided SingleQuoteString PegRule, it'd parse as:
>
> 'hello, i\' <-- string token
> m <-- identifier
> a <-- identifier
> string <-- keyword (for purposes of syntax colorizing)
> and the trailing single-quote would cause the parser to bail out...
>
> this was my initial approach to this issue:
> SingleQuoteString = "'",--("""\'""",not "'",
> any()),"'",{$HandlePegMatch(PegTokenType.SingleQuoteString)}
>
> this would cause the parser to fail on attempting to parse any
> string... anywho.. any thoughts on how to approach this issue?
>
> I just wanted to say that, besides dealing with this, working with
> pegs thus far has gone quite well. I am quite taken with the system,
> as a whole.
>
> The only other gripe I have (Pegs-wise) is that this PegRule will fail:
>
> Rule = ++("bar" / not "foo" / any() )
>
> in this case, it will fail because of the 'not "foo" ' piece.. changing it to
> Rule = ++("bar" / Foo / any() )
> Foo = not "foo"
>
> will allow it to compile...
>
> Just wanted to share that.. anywho, any help concerning the string
> issue above from anyone also working with Pegs would be greatly
> appreciated.
>
> Thanks,
> Jeff
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Boo Programming Language" group.
To post to this group, send email to boolang@...
To unsubscribe from this group, send email to boolang-unsubscribe@...
For more options, visit this group at http://groups.google.com/group/boolang
-~----------~----~----~----~------~----~------~--~---


Re: Need help crafting a Peg rule to deal with strings that include escaped string delimiters

by Ayende Rahien-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

What _is_ pegs?

On Thu, Jun 12, 2008 at 7:28 PM, Jeffery Olson <olson.jeffery@...> wrote:

If anyone else would like to play around with Boo.Pegs and perhaps
help me in the process troubleshoot this issue, I have a complete
(only needs Boo.Pegs.dll) program at:

http://monoport.com/17851

You can run it, and it'll let you type in a line of code and it'll try
to parse the tokens out of the code.. so you can see for yourself what
i'm talking about with this line parsing issue.

Once again, any help would be greatly appreicated.

Also: yes, i know i used the dreaded goto. I'm lazy and it's just a prototype :P

Cheers,
Jeff

On Wed, Jun 11, 2008 at 4:37 PM, Jeffery Olson <olson.jeffery@...> wrote:
> This is a valid string in boo:
> 'hello, i\'m a string'
>
> Here is the current PegRule that I have to parse strings (based on
> Rodrigo's string rule in the miniboo Pegs example):
> SingleQuoteString = "'",--(not "'",
> any()),"'",{$HandlePegMatch(PegTokenType.SingleQuoteString)}
>
> the callable at the end is extraneous... anywho, i've tried several
> approaches to try and get the above example string to parse. Under the
> provided SingleQuoteString PegRule, it'd parse as:
>
> 'hello, i\' <-- string token
> m <-- identifier
> a <-- identifier
> string <-- keyword (for purposes of syntax colorizing)
> and the trailing single-quote would cause the parser to bail out...
>
> this was my initial approach to this issue:
> SingleQuoteString = "'",--("""\'""",not "'",
> any()),"'",{$HandlePegMatch(PegTokenType.SingleQuoteString)}
>
> this would cause the parser to fail on attempting to parse any
> string... anywho.. any thoughts on how to approach this issue?
>
> I just wanted to say that, besides dealing with this, working with
> pegs thus far has gone quite well. I am quite taken with the system,
> as a whole.
>
> The only other gripe I have (Pegs-wise) is that this PegRule will fail:
>
> Rule = ++("bar" / not "foo" / any() )
>
> in this case, it will fail because of the 'not "foo" ' piece.. changing it to
> Rule = ++("bar" / Foo / any() )
> Foo = not "foo"
>
> will allow it to compile...
>
> Just wanted to share that.. anywho, any help concerning the string
> issue above from anyone also working with Pegs would be greatly
> appreciated.
>
> Thanks,
> Jeff
>




--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Boo Programming Language" group.
To post to this group, send email to boolang@...
To unsubscribe from this group, send email to boolang-unsubscribe@...
For more options, visit this group at http://groups.google.com/group/boolang
-~----------~----~----~----~------~----~------~--~---


Re: Need help crafting a Peg rule to deal with strings that include escaped string delimiters

by Jeffery Olson :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


http://blogs.codehaus.org/people/bamboo/archives/001688_towards_extensible_parsing.html


On Thu, Jun 12, 2008 at 9:37 AM, Ayende Rahien <ayende@...> wrote:

> What _is_ pegs?
>
> On Thu, Jun 12, 2008 at 7:28 PM, Jeffery Olson <olson.jeffery@...>
> wrote:
>>
>> If anyone else would like to play around with Boo.Pegs and perhaps
>> help me in the process troubleshoot this issue, I have a complete
>> (only needs Boo.Pegs.dll) program at:
>>
>> http://monoport.com/17851
>>
>> You can run it, and it'll let you type in a line of code and it'll try
>> to parse the tokens out of the code.. so you can see for yourself what
>> i'm talking about with this line parsing issue.
>>
>> Once again, any help would be greatly appreicated.
>>
>> Also: yes, i know i used the dreaded goto. I'm lazy and it's just a
>> prototype :P
>>
>> Cheers,
>> Jeff
>>
>> On Wed, Jun 11, 2008 at 4:37 PM, Jeffery Olson <olson.jeffery@...>
>> wrote:
>> > This is a valid string in boo:
>> > 'hello, i\'m a string'
>> >
>> > Here is the current PegRule that I have to parse strings (based on
>> > Rodrigo's string rule in the miniboo Pegs example):
>> > SingleQuoteString = "'",--(not "'",
>> > any()),"'",{$HandlePegMatch(PegTokenType.SingleQuoteString)}
>> >
>> > the callable at the end is extraneous... anywho, i've tried several
>> > approaches to try and get the above example string to parse. Under the
>> > provided SingleQuoteString PegRule, it'd parse as:
>> >
>> > 'hello, i\' <-- string token
>> > m <-- identifier
>> > a <-- identifier
>> > string <-- keyword (for purposes of syntax colorizing)
>> > and the trailing single-quote would cause the parser to bail out...
>> >
>> > this was my initial approach to this issue:
>> > SingleQuoteString = "'",--("""\'""",not "'",
>> > any()),"'",{$HandlePegMatch(PegTokenType.SingleQuoteString)}
>> >
>> > this would cause the parser to fail on attempting to parse any
>> > string... anywho.. any thoughts on how to approach this issue?
>> >
>> > I just wanted to say that, besides dealing with this, working with
>> > pegs thus far has gone quite well. I am quite taken with the system,
>> > as a whole.
>> >
>> > The only other gripe I have (Pegs-wise) is that this PegRule will fail:
>> >
>> > Rule = ++("bar" / not "foo" / any() )
>> >
>> > in this case, it will fail because of the 'not "foo" ' piece.. changing
>> > it to
>> > Rule = ++("bar" / Foo / any() )
>> > Foo = not "foo"
>> >
>> > will allow it to compile...
>> >
>> > Just wanted to share that.. anywho, any help concerning the string
>> > issue above from anyone also working with Pegs would be greatly
>> > appreciated.
>> >
>> > Thanks,
>> > Jeff
>> >
>>
>>
>
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Boo Programming Language" group.
To post to this group, send email to boolang@...
To unsubscribe from this group, send email to boolang-unsubscribe@...
For more options, visit this group at http://groups.google.com/group/boolang
-~----------~----~----~----~------~----~------~--~---


Re: Need help crafting a Peg rule to deal with strings that include escaped string delimiters

by Avishay Lavie :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Ayende, suffice to say that with PEGs, you can finally have your
custom operator. Now ain't that swell?

On Jun 12, 7:37 pm, "Ayende Rahien" <aye...@...> wrote:

> What _is_ pegs?
>
> On Thu, Jun 12, 2008 at 7:28 PM, Jeffery Olson <olson.jeff...@...>
> wrote:
>
>
>
> > If anyone else would like to play around with Boo.Pegs and perhaps
> > help me in the process troubleshoot this issue, I have a complete
> > (only needs Boo.Pegs.dll) program at:
>
> >http://monoport.com/17851
>
> > You can run it, and it'll let you type in a line of code and it'll try
> > to parse the tokens out of the code.. so you can see for yourself what
> > i'm talking about with this line parsing issue.
>
> > Once again, any help would be greatly appreicated.
>
> > Also: yes, i know i used the dreaded goto. I'm lazy and it's just a
> > prototype :P
>
> > Cheers,
> > Jeff
>
> > On Wed, Jun 11, 2008 at 4:37 PM, Jeffery Olson <olson.jeff...@...>
> > wrote:
> > > This is a valid string in boo:
> > > 'hello, i\'m a string'
>
> > > Here is the current PegRule that I have to parse strings (based on
> > > Rodrigo's string rule in the miniboo Pegs example):
> > > SingleQuoteString = "'",--(not "'",
> > > any()),"'",{$HandlePegMatch(PegTokenType.SingleQuoteString)}
>
> > > the callable at the end is extraneous... anywho, i've tried several
> > > approaches to try and get the above example string to parse. Under the
> > > provided SingleQuoteString PegRule, it'd parse as:
>
> > > 'hello, i\' <-- string token
> > > m <-- identifier
> > > a <-- identifier
> > > string <-- keyword (for purposes of syntax colorizing)
> > > and the trailing single-quote would cause the parser to bail out...
>
> > > this was my initial approach to this issue:
> > > SingleQuoteString = "'",--("""\'""",not "'",
> > > any()),"'",{$HandlePegMatch(PegTokenType.SingleQuoteString)}
>
> > > this would cause the parser to fail on attempting to parse any
> > > string... anywho.. any thoughts on how to approach this issue?
>
> > > I just wanted to say that, besides dealing with this, working with
> > > pegs thus far has gone quite well. I am quite taken with the system,
> > > as a whole.
>
> > > The only other gripe I have (Pegs-wise) is that this PegRule will fail:
>
> > > Rule = ++("bar" / not "foo" / any() )
>
> > > in this case, it will fail because of the 'not "foo" ' piece.. changing
> > it to
> > > Rule = ++("bar" / Foo / any() )
> > > Foo = not "foo"
>
> > > will allow it to compile...
>
> > > Just wanted to share that.. anywho, any help concerning the string
> > > issue above from anyone also working with Pegs would be greatly
> > > appreciated.
>
> > > Thanks,
> > > Jeff
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Boo Programming Language" group.
To post to this group, send email to boolang@...
To unsubscribe from this group, send email to boolang-unsubscribe@...
For more options, visit this group at http://groups.google.com/group/boolang
-~----------~----~----~----~------~----~------~--~---


Re: Need help crafting a Peg rule to deal with strings that include escaped string delimiters

by Ayende Rahien-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Yes, it is!

On Thu, Jun 12, 2008 at 10:32 PM, Avish <some.avish@...> wrote:

Ayende, suffice to say that with PEGs, you can finally have your
custom operator. Now ain't that swell?

On Jun 12, 7:37 pm, "Ayende Rahien" <aye...@...> wrote:
> What _is_ pegs?
>
> On Thu, Jun 12, 2008 at 7:28 PM, Jeffery Olson <olson.jeff...@...>
> wrote:
>
>
>
> > If anyone else would like to play around with Boo.Pegs and perhaps
> > help me in the process troubleshoot this issue, I have a complete
> > (only needs Boo.Pegs.dll) program at:
>
> >http://monoport.com/17851
>
> > You can run it, and it'll let you type in a line of code and it'll try
> > to parse the tokens out of the code.. so you can see for yourself what
> > i'm talking about with this line parsing issue.
>
> > Once again, any help would be greatly appreicated.
>
> > Also: yes, i know i used the dreaded goto. I'm lazy and it's just a
> > prototype :P
>
> > Cheers,
> > Jeff
>
> > On Wed, Jun 11, 2008 at 4:37 PM, Jeffery Olson <olson.jeff...@...>
> > wrote:
> > > This is a valid string in boo:
> > > 'hello, i\'m a string'
>
> > > Here is the current PegRule that I have to parse strings (based on
> > > Rodrigo's string rule in the miniboo Pegs example):
> > > SingleQuoteString = "'",--(not "'",
> > > any()),"'",{$HandlePegMatch(PegTokenType.SingleQuoteString)}
>
> > > the callable at the end is extraneous... anywho, i've tried several
> > > approaches to try and get the above example string to parse. Under the
> > > provided SingleQuoteString PegRule, it'd parse as:
>
> > > 'hello, i\' <-- string token
> > > m <-- identifier
> > > a <-- identifier
> > > string <-- keyword (for purposes of syntax colorizing)
> > > and the trailing single-quote would cause the parser to bail out...
>
> > > this was my initial approach to this issue:
> > > SingleQuoteString = "'",--("""\'""",not "'",
> > > any()),"'",{$HandlePegMatch(PegTokenType.SingleQuoteString)}
>
> > > this would cause the parser to fail on attempting to parse any
> > > string... anywho.. any thoughts on how to approach this issue?
>
> > > I just wanted to say that, besides dealing with this, working with
> > > pegs thus far has gone quite well. I am quite taken with the system,
> > > as a whole.
>
> > > The only other gripe I have (Pegs-wise) is that this PegRule will fail:
>
> > > Rule = ++("bar" / not "foo" / any() )
>
> > > in this case, it will fail because of the 'not "foo" ' piece.. changing
> > it to
> > > Rule = ++("bar" / Foo / any() )
> > > Foo = not "foo"
>
> > > will allow it to compile...
>
> > > Just wanted to share that.. anywho, any help concerning the string
> > > issue above from anyone also working with Pegs would be greatly
> > > appreciated.
>
> > > Thanks,
> > > Jeff



--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Boo Programming Language" group.
To post to this group, send email to boolang@...
To unsubscribe from this group, send email to boolang-unsubscribe@...
For more options, visit this group at http://groups.google.com/group/boolang
-~----------~----~----~----~------~----~------~--~---


Re: Need help crafting a Peg rule to deal with strings that include escaped string delimiters

by Jeffery Olson :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Meanwhile: if anyone wants to give some insight into getting strings
with escaped delimiters to parse.. id be very grateful :)

On Thu, Jun 12, 2008 at 12:43 PM, Ayende Rahien <ayende@...> wrote:

> Yes, it is!
>
> On Thu, Jun 12, 2008 at 10:32 PM, Avish <some.avish@...> wrote:
>>
>> Ayende, suffice to say that with PEGs, you can finally have your
>> custom operator. Now ain't that swell?
>>
>> On Jun 12, 7:37 pm, "Ayende Rahien" <aye...@...> wrote:
>> > What _is_ pegs?
>> >
>> > On Thu, Jun 12, 2008 at 7:28 PM, Jeffery Olson <olson.jeff...@...>
>> > wrote:
>> >
>> >
>> >
>> > > If anyone else would like to play around with Boo.Pegs and perhaps
>> > > help me in the process troubleshoot this issue, I have a complete
>> > > (only needs Boo.Pegs.dll) program at:
>> >
>> > >http://monoport.com/17851
>> >
>> > > You can run it, and it'll let you type in a line of code and it'll try
>> > > to parse the tokens out of the code.. so you can see for yourself what
>> > > i'm talking about with this line parsing issue.
>> >
>> > > Once again, any help would be greatly appreicated.
>> >
>> > > Also: yes, i know i used the dreaded goto. I'm lazy and it's just a
>> > > prototype :P
>> >
>> > > Cheers,
>> > > Jeff
>> >
>> > > On Wed, Jun 11, 2008 at 4:37 PM, Jeffery Olson
>> > > <olson.jeff...@...>
>> > > wrote:
>> > > > This is a valid string in boo:
>> > > > 'hello, i\'m a string'
>> >
>> > > > Here is the current PegRule that I have to parse strings (based on
>> > > > Rodrigo's string rule in the miniboo Pegs example):
>> > > > SingleQuoteString = "'",--(not "'",
>> > > > any()),"'",{$HandlePegMatch(PegTokenType.SingleQuoteString)}
>> >
>> > > > the callable at the end is extraneous... anywho, i've tried several
>> > > > approaches to try and get the above example string to parse. Under
>> > > > the
>> > > > provided SingleQuoteString PegRule, it'd parse as:
>> >
>> > > > 'hello, i\' <-- string token
>> > > > m <-- identifier
>> > > > a <-- identifier
>> > > > string <-- keyword (for purposes of syntax colorizing)
>> > > > and the trailing single-quote would cause the parser to bail out...
>> >
>> > > > this was my initial approach to this issue:
>> > > > SingleQuoteString = "'",--("""\'""",not "'",
>> > > > any()),"'",{$HandlePegMatch(PegTokenType.SingleQuoteString)}
>> >
>> > > > this would cause the parser to fail on attempting to parse any
>> > > > string... anywho.. any thoughts on how to approach this issue?
>> >
>> > > > I just wanted to say that, besides dealing with this, working with
>> > > > pegs thus far has gone quite well. I am quite taken with the system,
>> > > > as a whole.
>> >
>> > > > The only other gripe I have (Pegs-wise) is that this PegRule will
>> > > > fail:
>> >
>> > > > Rule = ++("bar" / not "foo" / any() )
>> >
>> > > > in this case, it will fail because of the 'not "foo" ' piece..
>> > > > changing
>> > > it to
>> > > > Rule = ++("bar" / Foo / any() )
>> > > > Foo = not "foo"
>> >
>> > > > will allow it to compile...
>> >
>> > > > Just wanted to share that.. anywho, any help concerning the string
>> > > > issue above from anyone also working with Pegs would be greatly
>> > > > appreciated.
>> >
>> > > > Thanks,
>> > > > Jeff
>>
>
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Boo Programming Language" group.
To post to this group, send email to boolang@...
To unsubscribe from this group, send email to boolang-unsubscribe@...
For more options, visit this group at http://groups.google.com/group/boolang
-~----------~----~----~----~------~----~------~--~---


Re: Need help crafting a Peg rule to deal with strings that include escaped string delimiters

by Avishay Lavie :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


I couldn't get Boo.Pegs to build. However, you should try specifically
including the escaped characters into the string, thus:

SingleQuoteString = "'",--(not "'",
"\\'", any()),"'",{$HandlePegMatch(PegTokenType.SingleQuoteString)}

On Jun 12, 10:45 pm, "Jeffery Olson" <olson.jeff...@...> wrote:
> Meanwhile: if anyone wants to give some insight into getting strings
> with escaped delimiters to parse.. id be very grateful :)


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Boo Programming Language" group.
To post to this group, send email to boolang@...
To unsubscribe from this group, send email to boolang-unsubscribe@...
For more options, visit this group at http://groups.google.com/group/boolang
-~----------~----~----~----~------~----~------~--~---


Re: Need help crafting a Peg rule to deal with strings that include escaped string delimiters

by Avishay Lavie :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


ok, now that I got Boo.Pegs to build, I can give a correct answer.
You need to have the backslash-quote sequence match before a "regular"
character. You can achieve it thus:

SingleQuoteString = "'", ("\\'" / (not "'", any())), "'",
{$HandlePegMatch(PegTokenType.SingleQuoteString)}

This will give you the text, including the backslash. You'll still
have to strip it out later, though, but that's not a problem.

Perhaps Bamboo can give a more elegant solution?

On Jun 13, 1:41 am, Avish <some.av...@...> wrote:

> I couldn't get Boo.Pegs to build. However, you should try specifically
> including the escaped characters into the string, thus:
>
> SingleQuoteString = "'",--(not "'",
> "\\'", any()),"'",{$HandlePegMatch(PegTokenType.SingleQuoteString)}
>
> On Jun 12, 10:45 pm, "Jeffery Olson" <olson.jeff...@...> wrote:
>
> > Meanwhile: if anyone wants to give some insight into getting strings
> > with escaped delimiters to parse.. id be very grateful :)
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Boo Programming Language" group.
To post to this group, send email to boolang@...
To unsubscribe from this group, send email to boolang-unsubscribe@...
For more options, visit this group at http://groups.google.com/group/boolang
-~----------~----~----~----~------~----~------~--~---


Re: Need help crafting a Peg rule to deal with strings that include escaped string delimiters

by Rodrigo B. de Oliveira :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


On Fri, Jun 13, 2008 at 1:24 PM, Avish <some.avish@...> wrote:
> ...
> SingleQuoteString = "'", ("\\'" / (not "'", any())), "'",
> {$HandlePegMatch(PegTokenType.SingleQuoteString)}
> ...
> Perhaps Bamboo can give a more elegant solution?
>

Nope :)

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Boo Programming Language" group.
To post to this group, send email to boolang@...
To unsubscribe from this group, send email to boolang-unsubscribe@...
For more options, visit this group at http://groups.google.com/group/boolang
-~----------~----~----~----~------~----~------~--~---


Re: Need help crafting a Peg rule to deal with strings that include escaped string delimiters

by Jeffery Olson :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Thanks for the solution, Avish. I appreciate the help :)

In this particular case, the PEG rules I'm crafting are meant to parse
tokens and provide meaningful colorization info to VS2008.. IOW, i'm
working on a lexer that is more appropriate my particular use case (I
think everyone has heard my bellyaching about how much it sucks to use
Boo.Lang.Parser.BooLexer as a colorizing lexer.. it's really not
suited to the task at all).. so i'm not really that concerned about
stripping out the slash :)

I've learned alot though, so far.. I kinda wonder, though, where on
the priorities/planning re-writing Boo.Lang.Parser to use Boo.Pegs is?
My thought would be to start with just re-working the namespace into a
non-interface-breaking implementation that was free of antlr's
generated code, but still returned the antlr types, then ease out the
changes from there into other parts of the code/compiler ... (to avoid
all of the uglyness that would need to happen in Boo.Lang.Compiler to
accomadate it, right off of the bat).. although going that route still
wouldn't get to the heart of the issue, since the compiler is
currently written to accommodate the antlr grammar's approach.

I'm curious what the thoughts of Rodrigo/others are on this thing.
Perhaps too early to discuss?

Cheers,
Jeff

On Fri, Jun 13, 2008 at 9:24 AM, Avish <some.avish@...> wrote:

>
> ok, now that I got Boo.Pegs to build, I can give a correct answer.
> You need to have the backslash-quote sequence match before a "regular"
> character. You can achieve it thus:
>
> SingleQuoteString = "'", ("\\'" / (not "'", any())), "'",
> {$HandlePegMatch(PegTokenType.SingleQuoteString)}
>
> This will give you the text, including the backslash. You'll still
> have to strip it out later, though, but that's not a problem.
>
> Perhaps Bamboo can give a more elegant solution?
>
> On Jun 13, 1:41 am, Avish <some.av...@...> wrote:
>> I couldn't get Boo.Pegs to build. However, you should try specifically
>> including the escaped characters into the string, thus:
>>
>> SingleQuoteString = "'",--(not "'",
>> "\\'", any()),"'",{$HandlePegMatch(PegTokenType.SingleQuoteString)}
>>
>> On Jun 12, 10:45 pm, "Jeffery Olson" <olson.jeff...@...> wrote:
>>
>> > Meanwhile: if anyone wants to give some insight into getting strings
>> > with escaped delimiters to parse.. id be very grateful :)
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Boo Programming Language" group.
To post to this group, send email to boolang@...
To unsubscribe from this group, send email to boolang-unsubscribe@...
For more options, visit this group at http://groups.google.com/group/boolang
-~----------~----~----~----~------~----~------~--~---


Re: Need help crafting a Peg rule to deal with strings that include escaped string delimiters

by Rodrigo B. de Oliveira :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


On Fri, Jun 13, 2008 at 2:19 PM, Jeffery Olson <olson.jeffery@...> wrote:
> ...
> I've learned alot though, so far.. I kinda wonder, though, where on
> the priorities/planning re-writing Boo.Lang.Parser to use Boo.Pegs is?

High.

> My thought would be to start with just re-working the namespace into a
> non-interface-breaking implementation that was free of antlr's

The compiler is not really dependent on the parser api or any of its
dependencies.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Boo Programming Language" group.
To post to this group, send email to boolang@...
To unsubscribe from this group, send email to boolang-unsubscribe@...
For more options, visit this group at http://groups.google.com/group/boolang
-~----------~----~----~----~------~----~------~--~---


Re: Need help crafting a Peg rule to deal with strings that include escaped string delimiters

by Jeffery Olson :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Avish,
I finally got some time to work on this rule a bit more, and this is
the working rule i've came up with (based upon your suggested
solution):

SingleQuoteString = "'",--("\\\\" / "\\'" / (not "'",
any())),"'",{$HandlePegMatch(PegTokenType.SingleQuoteString)}


The only thing I added was that I also have to catch a escaped-escape
characters used just before a closing delimiters.

If anyone can think of how to "perl golf" this statement into a more
succinct/efficient form, please let me know!

Cheers,
Jeff

On Fri, Jun 13, 2008 at 9:24 AM, Avish <some.avish@...> wrote:

>
> ok, now that I got Boo.Pegs to build, I can give a correct answer.
> You need to have the backslash-quote sequence match before a "regular"
> character. You can achieve it thus:
>
> SingleQuoteString = "'", ("\\'" / (not "'", any())), "'",
> {$HandlePegMatch(PegTokenType.SingleQuoteString)}
>
> This will give you the text, including the backslash. You'll still
> have to strip it out later, though, but that's not a problem.
>
> Perhaps Bamboo can give a more elegant solution?
>
> On Jun 13, 1:41 am, Avish <some.av...@...> wrote:
>> I couldn't get Boo.Pegs to build. However, you should try specifically
>> including the escaped characters into the string, thus:
>>
>> SingleQuoteString = "'",--(not "'",
>> "\\'", any()),"'",{$HandlePegMatch(PegTokenType.SingleQuoteString)}
>>
>> On Jun 12, 10:45 pm, "Jeffery Olson" <olson.jeff...@...> wrote:
>>
>> > Meanwhile: if anyone wants to give some insight into getting strings
>> > with escaped delimiters to parse.. id be very grateful :)
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Boo Programming Language" group.
To post to this group, send email to boolang@...
To unsubscribe from this group, send email to boolang-unsubscribe@...
For more options, visit this group at http://groups.google.com/group/boolang
-~----------~----~----~----~------~----~------~--~---


Re: Need help crafting a Peg rule to deal with strings that include escaped string delimiters

by Avishay Lavie :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


SingleQuoteString = "'", --SingleQuoteStringCharacter, "'", {...}
SingleQuoteStringCharacter = ("\\\\" / "\\'" / [other escape
characters] / (not "'", any()))

On Jun 17, 7:01 pm, "Jeffery Olson" <olson.jeff...@...> wrote:

> Avish,
> I finally got some time to work on this rule a bit more, and this is
> the working rule i've came up with (based upon your suggested
> solution):
>
> SingleQuoteString = "'",--("\\\\" / "\\'" / (not "'",
> any())),"'",{$HandlePegMatch(PegTokenType.SingleQuoteString)}
>
> The only thing I added was that I also have to catch a escaped-escape
> characters used just before a closing delimiters.
>
> If anyone can think of how to "perl golf" this statement into a more
> succinct/efficient form, please let me know!
>
> Cheers,
> Jeff
>
> On Fri, Jun 13, 2008 at 9:24 AM, Avish <some.av...@...> wrote:
>
> > ok, now that I got Boo.Pegs to build, I can give a correct answer.
> > You need to have the backslash-quote sequence match before a "regular"
> > character. You can achieve it thus:
>
> > SingleQuoteString = "'", ("\\'" / (not "'", any())), "'",
> > {$HandlePegMatch(PegTokenType.SingleQuoteString)}
>
> > This will give you the text, including the backslash. You'll still
> > have to strip it out later, though, but that's not a problem.
>
> > Perhaps Bamboo can give a more elegant solution?
>
> > On Jun 13, 1:41 am, Avish <some.av...@...> wrote:
> >> I couldn't get Boo.Pegs to build. However, you should try specifically
> >> including the escaped characters into the string, thus:
>
> >> SingleQuoteString = "'",--(not "'",
> >> "\\'", any()),"'",{$HandlePegMatch(PegTokenType.SingleQuoteString)}
>
> >> On Jun 12, 10:45 pm, "Jeffery Olson" <olson.jeff...@...> wrote:
>
> >> > Meanwhile: if anyone wants to give some insight into getting strings
> >> > with escaped delimiters to parse.. id be very grateful :)
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Boo Programming Language" group.
To post to this group, send email to boolang@...
To unsubscribe from this group, send email to boolang-unsubscribe@...
For more options, visit this group at http://groups.google.com/group/boolang
-~----------~----~----~----~------~----~------~--~---

LightInTheBox - Buy quality products at wholesale price