[clean-list] understanding a right-associative parser combinator

terrence.brannon terrence.x.brannon at jpmchase.com
Tue Aug 26 19:06:06 MEST 2008


(&>) is right associative:
// and-combinator that only retains the right hand side result
(&>)	infixr 6 // :: (Parser s r t) (Parser s r` t) -> Parser s r` t
(&>) p1 p2 :== p1 <&> const p2


So when I read this expression:
p =  twoDigits &> twoDigits &> (<!?> twoDigits undef undef) &> (symbol 'Z')

I should rewrite it to this:
p =  ( twoDigits &> ( twoDigits &> ( (<!?> twoDigits undef undef) &> (symbol
'Z') ) ) )

But then I get confused about order of execution...
won't the innermost parenthetical expression execute first and the parse
will attempt to execute this first:
( (<!?> twoDigits undef undef) &> (symbol 'Z') ) 

Which would not be the desired parsing order.

-- 
View this message in context: http://www.nabble.com/understanding-a-right-associative-parser-combinator-tp19165664p19165664.html
Sent from the Clean mailing list archive at Nabble.com.



More information about the clean-list mailing list