Has anyone tried modifying Pyke to allow expressions in assertions e.g., assuming $num is bound to a number, I am thinking of something like the following assert relation($num+1)
of course there is a way around this by using a python premise in the assert clause but the rules i am creating have numerous cases like this and it would be simpler not to have to bind numerous additional variables in the assert clause
On Thu, Dec 15, 2011 at 12:45 AM, Stacy <stacymarse...@gmail.com> wrote: > Has anyone tried modifying Pyke to allow expressions in assertions > e.g., assuming $num is bound to a number, I am thinking of something > like the following > assert > relation($num+1)
> of course there is a way around this by using a python premise in the > assert clause but the rules i am creating have numerous cases like > this and it would be simpler not to have to bind numerous additional > variables in the assert clause
> -- > You received this message because you are subscribed to the Google Groups "PyKE" group. > To post to this group, send email to pyke@googlegroups.com. > To unsubscribe from this group, send email to pyke+unsubscribe@googlegroups.com. > For more options, visit this group at http://groups.google.com/group/pyke?hl=en.
Right now, Pyke does not parse the python code snippets in the .krb files. It knows which lines are python code, and just does a simple scan on these strings looking for pattern variables (indicated by dollar signs, e.g., $num). I would like to avoid having Pyke having to fully parse python code. This would mean staying in sync with changes in the python grammar and probably would require mechanisms to support multiple grammars somehow so that Pyke would continue to run on multiple versions of python.
I suppose that the .krb parser could just take all the text up to the next comma (ignoring commas nested in parens, brackets or within string literals) as python code and do the same substitution as described above on it. But then a question arises about single values within parenthesis. What would ($num + 1) * 3 be when $num is 4? If the parenthesis have python meaning, it would be 15. But if the parenthesis have Pyke meaning, they would indicate a singleton tuple that would then be repeated 3 times giving (5, 5, 5), the same as doing (4 + 1,) * 3 in python.
On Wed, Dec 14, 2011 at 9:45 PM, Stacy <stacymarse...@gmail.com> wrote: > Has anyone tried modifying Pyke to allow expressions in assertions > e.g., assuming $num is bound to a number, I am thinking of something > like the following > assert > relation($num+1)
> of course there is a way around this by using a python premise in the > assert clause but the rules i am creating have numerous cases like > this and it would be simpler not to have to bind numerous additional > variables in the assert clause
> -- > You received this message because you are subscribed to the Google Groups > "PyKE" group. > To post to this group, send email to pyke@googlegroups.com. > To unsubscribe from this group, send email to > pyke+unsubscribe@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/pyke?hl=en.
I was wondering about the parentheses myself. Forget I asked. It adds complications and frankly it is not a critical problem since there are straightforward alternatives.
On Dec 15, 9:02 am, Bruce Frederiksen <dangy...@gmail.com> wrote:
> Right now, Pyke does not parse the python code snippets in the .krb files. > It knows which lines are python code, and just does a simple scan on these > strings looking for pattern variables (indicated by dollar signs, e.g., > $num). I would like to avoid having Pyke having to fully parse python > code. This would mean staying in sync with changes in the python grammar > and probably would require mechanisms to support multiple grammars somehow > so that Pyke would continue to run on multiple versions of python.
> I suppose that the .krb parser could just take all the text up to the next > comma (ignoring commas nested in parens, brackets or within string > literals) as python code and do the same substitution as described above on > it. But then a question arises about single values within parenthesis. > What would ($num + 1) * 3 be when $num is 4? If the parenthesis have > python meaning, it would be 15. But if the parenthesis have Pyke meaning, > they would indicate a singleton tuple that would then be repeated 3 times > giving (5, 5, 5), the same as doing (4 + 1,) * 3 in python.
> Any ideas how to deal with this unambiguously?
> -Bruce
> On Wed, Dec 14, 2011 at 9:45 PM, Stacy <stacymarse...@gmail.com> wrote: > > Has anyone tried modifying Pyke to allow expressions in assertions > > e.g., assuming $num is bound to a number, I am thinking of something > > like the following > > assert > > relation($num+1)
> > of course there is a way around this by using a python premise in the > > assert clause but the rules i am creating have numerous cases like > > this and it would be simpler not to have to bind numerous additional > > variables in the assert clause
> > -- > > You received this message because you are subscribed to the Google Groups > > "PyKE" group. > > To post to this group, send email to pyke@googlegroups.com. > > To unsubscribe from this group, send email to > > pyke+unsubscribe@googlegroups.com. > > For more options, visit this group at > >http://groups.google.com/group/pyke?hl=en.