Am I evil for this?

Timon Gehr timon.gehr at gmx.ch
Sun Oct 16 19:53:06 UTC 2022


On 10/15/22 20:22, Walter Bright wrote:
> On 10/15/2022 10:42 AM, Timon Gehr wrote:
>> On 15.10.22 18:45, Walter Bright wrote:
>>> On 10/15/2022 5:41 AM, Timon Gehr wrote:
>>>> You can parse it as a single "operator expression" and resolve 
>>>> precedence during semantic analysis.
>>>
>>> The operator precedence drives the parse.
>>
>> It does not _have_ to work that way.
> 
> I know. The tokens can be "parsed" by just storing them in an array, 
> deferring constructing the AST until the semantics are known.
> 
> But that isn't really parsing,

You can parse everything except operator precedence, no need to store a 
token stream. In general, aspects of the AST that depend on semantic 
information should be resolved during semantic analysis, and if that is 
the case for operator precedence that's how you parse it. There's no 
need to have any feedback from semantic to the parser.

> and makes 3rd party tools much more complex.

Depends a bit on the tool. I guess it is true for a tool whose only 
purpose is to parenthesize expressions according to operator precedence. 
:) It's not adding much complexity to tools that already need to run 
full semantic.


More information about the Digitalmars-d mailing list