Related articles |
---|
How change grammar to equivalent LL(1) ? borucki.andrzej@gmail.com (Andy) (2019-12-22) |
Re: How change grammar to equivalent LL(1) ? lhp+news@toft-hp.dk (Lasse =?iso-8859-1?q?Hiller=F8e?= Petersen) (2019-12-23) |
Re: How change grammar to equivalent LL(1) ? christopher.f.clark@compiler-resources.com (Christopher F Clark) (2019-12-23) |
Re: How change grammar to equivalent LL(1) ? DrDiettrich1@netscape.net (Hans-Peter Diettrich) (2019-12-23) |
Re: How change grammar to equivalent LL(1) ? lhp+news@toft-hp.dk (Lasse =?iso-8859-1?q?Hiller=F8e?= Petersen) (2020-04-24) |
Re: How change grammar to equivalent LL(1) ? 773-297-7223@kylheku.com (Kaz Kylheku) (2020-04-24) |
Re: How change grammar to equivalent LL(1) ? Silas8642@hotmail.co.uk (silas poulson) (2020-11-11) |
From: | Hans-Peter Diettrich <DrDiettrich1@netscape.net> |
Newsgroups: | comp.compilers |
Date: | Mon, 23 Dec 2019 10:01:06 +0100 |
Organization: | Compilers Central |
References: | 19-12-019 |
Injection-Info: | gal.iecc.com; posting-host="news.iecc.com:2001:470:1f07:1126:0:676f:7373:6970"; logging-data="59733"; mail-complaints-to="abuse@iecc.com" |
Keywords: | parse, LL(1) |
Posted-Date: | 23 Dec 2019 21:53:54 EST |
Am 23.12.2019 um 00:55 schrieb Andy:
> Obviously if is possible.
> In Polish Wikipedia can we read, that even very simple grammar:
> expr->number '+' expr
> expr->number
> is not LL(1) bacause we must see '+' to distinguish
>
> But
> is posssible equivalent grammar:
> expr -> number optPlusExpr
> optPlusExpr -> epsilon
> optPlusExpr ->'+' expr
>
> What are general rules to change grammar to equivalent LL(1) grammar if possible?
Use EBNF:
expr -> number { '+' expr }
or
expr -> number { '+' number }
EBNF or "railroad diagrams" typically translate directly into LL
top-down parsers. Many problems vanish when the grammar does not allow
for too much freedom causing inobvious problems. E.g. in EBNF only a
single derivation of a (left hand) nonterminal is allowed.
DoDi
Return to the
comp.compilers page.
Search the
comp.compilers archives again.