&{predicate} and !{predicate} operators

159 views
Skip to first unread message

marco.v...@gmail.com

unread,
Feb 9, 2013, 7:28:56 AM2/9/13
to pe...@googlegroups.com
Hi,

I fail to understand how to use them. Here is what I have:

// ---------------
{
myPred = function() {
return true;
}
}

start = r

r = &{myPred} "bla"
// ---------------

This is not parsing the text "bla". Why?

Thanks!
Marco

David Majda

unread,
Mar 12, 2013, 3:36:40 PM3/12/13
to marcov...@gmail.com, pegjs
Hi,

2013/2/9 <marco.v...@gmail.com>:
Because you're not calling the function, you just mention its name.
The proper way is:

&{ return myPred(); }

You can also specify the condition directly in the predicate (which is
usually better, unless it is complicated and/or used at multiple
places).

--
David Majda
Entropy fighter
http://majda.cz/
Reply all
Reply to author
Forward
0 new messages