Is D's grammar really context-free?

后端 未结 7 1132
萌比男神i
萌比男神i 2021-01-30 03:18

I\'ve posted this on the D newsgroup some months ago, but for some reason, the answer never really convinced me, so I thought I\'d ask it here.


The grammar of D is

相关标签:
7条回答
  • 2021-01-30 03:47

    There is a construct in D's lexer:

    string ::= q" Delim1 Chars newline Delim2 "
    

    where Delim1 and Delim2 are matching identifiers, and Chars does not contain newline Delim2.

    This construct is context sensitive, therefore D's lexer grammar is context sensitive.

    It's been a few years since I've worked with D's grammar much, so I can't remember all the trouble spots off the top of my head, or even if any of them make D's parser grammar context sensitive, but I believe they do not. From recall, I would say D's grammar is context free, not LL(k) for any k, and it has an obnoxious amount of ambiguity.

    0 讨论(0)
提交回复
热议问题