Re: language design for parsing, was C++ intermediate representation.

mefrill@yandex.ru (Vladimir)
19 May 2005 21:45:22 -0400

          From comp.compilers

Related articles
Re: language design for parsing, was C++ intermediate representation. mefrill@yandex.ru (2005-05-18)
RE: language design for parsing, was C++ intermediate representation. quinn-j@shaw.ca (Quinn Tyler Jackson) (2005-05-18)
Re: language design for parsing, was C++ intermediate representation. mefrill@yandex.ru (2005-05-19)
| List of all articles for this month |

From: mefrill@yandex.ru (Vladimir)
Newsgroups: comp.compilers
Date: 19 May 2005 21:45:22 -0400
Organization: Compilers Central
References: 05-05-162 05-05-167
Keywords: syntax, design
Posted-Date: 19 May 2005 21:45:22 EDT

Quinn Tyler Jackson <quinn-j@shaw.ca> wrote


> Whether or not such constructions as these *should* exist in
> programming languages or not is a religious issue. The fact is --
> they do, and they must be parsed. Whether or not they are handled in
> the formal specification or the "code" is another issue: a
> technological one.


As I understood this sentence may be the illustration and the resume
of your message. And I absolutely agree: the best parsing should be
the question of comfort, not the question of religion. But, the
problem we discussed was "using GLR (prefer) parsing algorithm for C++
instead LALR(k) (do not prefer)". I beleave it is true. And I'll try
explain why. The main argument I heard was: "why I cannot use C++
grammar rules that are written in ANSI C++ Standard document"? Why
should we use grammar, which does not reflect C++ language as it is
described in Standard? The answer is: because of LALR(1) algorithm.
Very well, lets drop out LALR(k) algorithm and start using something
else! There are two main approaches here: the first one is wrinting
parser by hand as (I heard) it was done by Comea compiler developers.
The second approach, which is preferes by me because I am very lazy
man, using some parser generator, but the algorithm used it should
support rules that are declared in C++ Standard. So, we come to GLR,
for example. The choice between these two approaches is a matter of
taste a developer. But, as I said befroe I am very lazy man, so I
prefer using parser generator, but the generator to easy parse C++
sentences.


And several words about your example with C++ class definition. I
beleave it is the best illustration of my view. The problem you
described cleary reflects the difference between syntactic and
semantic analysis. You, probably, know the typical solution, which is
making syntax analysis, but do not make semantic one. So, firstly
parse the class' definition, produce build tree (or some another
intermediate representation), but do not do semantic analysis. And
then, do semantic analysis, but not on the input text, only on build
tree. This approach works well on templates declaration analysis as
well. So, I prefer "the golden mean" - some kind of semantics, some
kind of syntactics. And, as I said before, I cannot see any question
for discussion for us. I think there was some misunderstanding, not
really problem.


Regards,
Vladimir.


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.