Well, I finally ran into a Python Unicode problem, sort of

BartC bc at freeuk.com
Sun Jul 3 20:39:58 EDT 2016


On 04/07/2016 01:24, Lawrence D’Oliveiro wrote:
> On Monday, July 4, 2016 at 12:17:47 PM UTC+12, BartC wrote:
>>
>> On 04/07/2016 01:00, Lawrence D’Oliveiro wrote:
>>>
>>> On Monday, July 4, 2016 at 11:47:26 AM UTC+12, eryk sun wrote:
>>>>
>>>> Python lacks a mechanism to add user-defined operators. (R has this
>>>> capability.) Maybe this feature could be added.
>>>
>>> That would be neat. But remember, you would have to define the operator
>>> precedence as well. So you could no longer use a recursive-descent parser.
>>
>> That wouldn't be a problem provided the new operator symbol and its
>> precedence is known at a compile time, and defined before use.
>
> That is how it is normally done. (E.g. Algol 68.)
>
> But you still couldn’t use a recursive-descent parser.

Why not?

The structure of such a parser doesn't need to exactly match the grammar 
with a dedicated block of code for each operator precedence. It can be 
table-driven so that an operator precedence value is just an attribute.

-- 
Bartc






More information about the Python-list mailing list