The grouping is different in the two examples, in particular the second one is equivelent to:

[source language = F#]
let rec parens2() =
parse { let! _ = char '('
let! _ = parens2()
let! _ = char ')'
return!
( parens2()
<|> parser { return () }) }
[/source]

What you want is to group the return! parens2() with the let!'s, like in the following (note the extra parenthesis):

[source language = F#]
let rec parens2() =
parse { (let! _ = char '('
let! _ = parens2()
let! _ = char ')'
return! parens2())
return () }
[/source]

By on 10/2/2007 12:32 AM ()

Thanks, I wrongly assumed the other precedence. Your proposed syntactic solution does not work however, it seems that you can't use parentheses in this simple way inside the "monad". I think I'll just stick with my explicit <|> operator which in this context maybe is also more clear, allthough slightly more verbose.

Regards Per

By on 10/2/2007 4:39 AM ()

Hi Per,

I'd like to look into this - can you post the full code of your sample?

Thanks

don

By on 10/2/2007 5:06 AM ()

Couldn't computation expressions be made to accept expressions of the right type directly, so that

parse {return! string "a"
return! string "b"
return! string "c"}

becomes

parse {string "a"
string "b"
string "c"}

which is much easier on the eyes?

Stephan

By on 11/8/2007 1:03 AM ()

Hi Stephan,

Yes, we're looking at making the use of "return!" optional.

Kind regards

Don

By on 11/8/2007 2:12 AM ()

Btw, what is the "heavy" syntax for the Combine constructs? While all other constructs have syntactic delimiters like "in", I failed to find how to write this "comprehension expressions" without #light.

By on 11/8/2007 4:28 AM ()

I haven't checked, however, I believe it is ';', the same as with sequence expressions when not using a computation expression/monadic combinator/workflow syntax.

By on 11/8/2007 6:09 AM ()

Apologies for taking a while to answer this.

There is currently no corresponding non-#light version of this feature as yet. It should, of course, logically be ";" but adding that takes real care and testing in the grammar with regard to the precedence rules. We plan on doing this work over the coming month.

This is one reason why "combine" is currently marked experimental.

Kind regards

Don

By on 11/11/2007 9:26 AM ()
IntelliFactory Offices Copyright (c) 2011-2012 IntelliFactory. All rights reserved.
Home | Products | Consulting | Trainings | Blogs | Jobs | Contact Us | Terms of Use | Privacy Policy | Cookie Policy
Built with WebSharper