Re: Misplaced parenthesis
- From: "Bruce Roberts" <dontsendtober@xxxxxxxxxxxxxxxxxxxx>
- Date: Fri, 17 Mar 2006 10:37:22 -0500
"Hans-Peter Diettrich" <DrDiettrich@xxxxxxxxxxx> wrote in message
news:47vb7nFh4g3oU1@xxxxxxxxxxxxxxxxx
What's a grammar unless it's written down?
A grammar.
Hmmm. A parser is not restricted to syntax checks, it also can check
constraints (predicates...); this feature can be important in the
disambiguation of otherwise ambiguous syntax.
The entire purpose of the parser component of a compiler is syntax
verification. I refer you to http://en.wikipedia.org/wiki/Parser.
What went wrong when a sentence is accepted by the parser, but is
rejected by the compiler?
Any number of things. Perhaps a missing declaration, perhaps a type
conflict. Perhaps the program or structure is too large, or too small. None
of these things have anything to do with syntax.
In this case the parser accepts a different language than the compiler
accepts. Now the language, accepted by the compiler, is a subset of the
language, accepted by the parser.
Its not necessarily a subset. IIRC, regular grammars are a case in point.
But you are right as far as most programming languages. The syntax of a
programming language generally allows construction of sentences that are
semantically meaningless or invalid. This can be especially true in
strongly typed languages.
We can end our discussion immediately, if you are satisfied with an OPL
grammar that describes an superset of the OPL language. In this case I
can provide a trivial OPL grammar like this:
Goal -> { Keyword | Operator | Identifier | Literal } 'end' '.'
You could, but its absurd.
ISTM that you are thinking of parsing as the process of program validation.
This is, to my mind, incorrect. Validating a program requires lexical
analysis, syntactic analysis, and finally semantic analysis. The fact that
modern compilers interleave these tasks is not material to the fact that
the tasks are identifiably different.
.
- Follow-Ups:
- Re: Misplaced parenthesis
- From: Hans-Peter Diettrich
- Re: Misplaced parenthesis
- References:
- Misplaced parenthesis
- From: Tom de Neef
- Re: Misplaced parenthesis
- From: Bruce Roberts
- Re: Misplaced parenthesis
- From: Hans-Peter Diettrich
- Re: Misplaced parenthesis
- From: Bruce Roberts
- Re: Misplaced parenthesis
- From: Marco van de Voort
- Re: Misplaced parenthesis
- From: Bruce Roberts
- Re: Misplaced parenthesis
- From: Marco van de Voort
- Re: Misplaced parenthesis
- From: Bruce Roberts
- Re: Misplaced parenthesis
- From: Hans-Peter Diettrich
- Re: Misplaced parenthesis
- From: Bruce Roberts
- Re: Misplaced parenthesis
- From: Hans-Peter Diettrich
- Re: Misplaced parenthesis
- From: Bruce Roberts
- Re: Misplaced parenthesis
- From: Hans-Peter Diettrich
- Misplaced parenthesis
- Prev by Date: Re: Misplaced parenthesis
- Next by Date: Re: TlabelCombobox
- Previous by thread: Re: Misplaced parenthesis
- Next by thread: Re: Misplaced parenthesis
- Index(es):
Relevant Pages
|