Related articles |
---|
First vs Predict and LL(*) alexander.morou@gmail.com (2015-01-07) |
Re: First vs Predict and LL(*) alexander.morou@gmail.com (2015-01-07) |
Re: First vs Predict and LL(*) DrDiettrich1@netscape.net (Hans-Peter Diettrich) (2015-01-07) |
First vs Predict and LL(*) slkpg4@gmail.com (SLK Mail) (2015-01-07) |
Re: First vs Predict and LL(*) alexander.morou@gmail.com (Alexander Morou) (2015-01-09) |
Re: First vs Predict and LL(*) alexander.morou@gmail.com (Alexander Morou) (2015-01-09) |
Re: First vs Predict and LL(*) DrDiettrich1@netscape.net (Hans-Peter Diettrich) (2015-01-09) |
Re: First vs Predict and LL(*) alexander.morou@gmail.com (Alexander Morou) (2015-01-22) |
Re: First vs Predict and LL(*) DrDiettrich1@netscape.net (Hans-Peter Diettrich) (2015-01-22) |
Re: First vs Predict and LL(*) alexander.morou@gmail.com (Alexander Morou) (2015-01-23) |
From: | Hans-Peter Diettrich <DrDiettrich1@netscape.net> |
Newsgroups: | comp.compilers |
Date: | Fri, 09 Jan 2015 23:35:22 +0100 |
Organization: | Compilers Central |
References: | 15-01-003 15-01-005 15-01-007 |
Keywords: | parse, LL(1) |
Posted-Date: | 10 Jan 2015 15:03:46 EST |
Alexander Morou schrieb:
> On Wednesday, January 7, 2015 7:41:39 PM UTC-6, Hans-Peter Diettrich wrote:
>>> longest prevails, or first come first serve. So if you want [A-F] to be
>>> parsed in a 'Q' token, you'd have to specify it first, unless other letters
>>> are parsed that make 'Q' parse a longer sub-string.
>> Here I feel a need for some annotation, that tells the (human) generator
>> of a sentence how to go ahead, in order to reach the intended goal. I
>> think that you found the same need already, too?
>
> Could you perhaps give me a run-down of what the annotation would
> clarify?
It should make clear to the *user*, what's the intent behind and usage
of unclear syntax.
> I think the confusion here is that I didn't specify what my
> understanding was, so here goes: k in an LL(k) parser refers to the
> number of TOKENS of look-ahead necessary to deterministically predict
> what's next and parse the appropriate rule from that decision.
ACK
> In situations where 'k' is unbound because the same rule is referenced
> on multiple avenues, and that rule uses repetitions, you yield an
> unbound 'k' requirement. This would also occur when two rules are
> equivalent, in that they utilize the same set of tokens, which may or
> may not use repetitions. The second case is much much trickier, from
> what I can gather. The computational time necessary to find them is
> *fairly* high.
I wouldn't consider LL(*) as a valid LL grammar, because it looks
impossible to write an parser generator for such a grammar. In such
cases an LR parser were more efficient and economic WRT stack size.
> The other question that seems to puzzle me is what do you do in
> situations where the current rule is in an acceptable state,
> it has possible further tokens, but what do you do when what is
> valid next is also valid in the calling rule?
That's known as e.g. "dangling else", and such ambiguities IMO also are
invalid in LL grammars, or must be solved by additional rules.
IMO the requirement for a low and bounded k, and for an unambiguous
grammar, helps in constructing languages that are both easy to write and
easy to parse.
DoDi
Return to the
comp.compilers page.
Search the
comp.compilers archives again.