On Thu, Jun 13, 2019 at 1:02 AM Andre Roberge <[email protected]> wrote:
>
>
>
> On Wed, Jun 12, 2019 at 7:56 PM Yanghao Hua <[email protected]> wrote:
>>
>> On Wed, Jun 12, 2019 at 11:27 PM Chris Angelico <[email protected]> wrote:
>> > Yes, you would need some sort of syntactic parser. There are a couple
>> > of ways to go about it. One is to make use of Python's own tools, like
>> > the ast module; the other is to mandate that your specific syntax be
>> > "tidier" than the rest of the Python code, which would permit you to
>> > use a more naive and simplistic parser (even a regex).
>>
>> Yep ... I just tried to use MacroPy3 to handle this but failed, seems
>> MacroPy3 does expect valid Python syntax in the first place for
>> anything else to happen. I also tried the raw ast module which seems
>> also the case. So it means if one want to use python ast module to
>> parse user input, the user input has to be valid python syntax (e.g.
>> no <==) at the first place. Seems this is a chicken-egg problem.
>
>
> As I mentioned very early on in this seemingly-never-ending discussion,
> there is a way to do things similar to what you want to do, by doing 
> transformations
> on the source code prior to execution (prior to constructing an AST).
>
> Here's the link to the set of examples which I have done as demonstrations of 
> this technique:
> https://github.com/aroberge/experimental/tree/master/experimental/transformers

I think your readme file self explains why already, I do have a
solution (multiple solution actually), this is the quest for the final
miles to make it look concise, intuitive and ***easy to implement***.

    Given two mathematical terms or expressions a and b, they can occur:

    - on a single line
    - immediately following an assert keyword
    - immediately following an if keyword

    However, in the current implementation, anything else will fail.
_______________________________________________
Python-ideas mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/[email protected]/message/J5IUQ46Z7TNBGDKJJYWQTPYTSMVG6VJT/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to