Dangling else (original) (raw)

About DBpedia

Nepovinné else (anglicky dangling else) v podmíněném příkazu způsobuje, že mnoho programovacích jazyků je nejednoznačných. Formální příčinou je, že bezkontextová gramatika příslušného jazyka je nejednoznačná, což znamená, že pro některé programy existuje více než jeden správný derivační strom.

Property Value
dbo:abstract Nepovinné else (anglicky dangling else) v podmíněném příkazu způsobuje, že mnoho programovacích jazyků je nejednoznačných. Formální příčinou je, že bezkontextová gramatika příslušného jazyka je nejednoznačná, což znamená, že pro některé programy existuje více než jeden správný derivační strom. (cs) Das Problem des dangling else (englisch dangling ‚baumelnd‘) ist ein Beispiel für eine scheinbare Mehrdeutigkeit einer Programmiersprache, die für Verwirrung sorgen kann, insbesondere bei falscher Einrückung. Tatsächlich ist die Semantik in den meisten Sprachen eindeutig definiert, schon weil die Grammatik der Sprache sonst nicht eindeutig zerlegbar wäre. Das Problem taucht in einigen Programmiersprachen (wie C, C++, Java) auf, wenn zwei verschachtelten if-Anweisungen nur ein else-Zweig gegenübersteht. Es kann nur auftreten, wenn eine optionale Klammerung weggelassen wird. (de) The dangling else is a problem in programming of parser generators in which an optional else clause in an if–then(–else) statement results in nested conditionals being ambiguous. Formally, the reference context-free grammar of the language is ambiguous, meaning there is more than one correct parse tree. In many programming languages one may write conditionally executed code in two forms: the if-then form, and the if-then-else form – the else clause is optional: if a then sif b then s1 else s2 This gives rise to an ambiguity in interpretation when there are nested statements, specifically whenever an if-then form appears as s1 in an if-then-else form: if a then if b then s else s2 In this example, s is unambiguously executed when a is true and b is true, but one may interpret s2 as being executed when a is false (thus attaching the else to the first if) or when a is true and b is false (thus attaching the else to the second if). In other words, one may see the previous statement as either of the following expressions: if a then (if b then s) else s2if a then (if b then s else s2) The dangling else problem dates to ALGOL 60, and has been resolved in various ways in subsequent languages. In LR parsers, the dangling else is the archetypal example of a shift-reduce conflict. (en) En informatique, et notamment dans la conception et l'analyse des langages de programmation, le problème du dangling else (anglais que l'on pourrait traduire par le problème du « sinon pendant ») est un problème de programmation informatique qui résulte de l'ambiguïté de l'interprétation de la clause sinon dans l'imbrication de deux instructions conditionnelles de la forme si-alors-sinon. Formellement, la grammaire non contextuelle du langage est ambiguë, ce qui signifie qu'il peut y avoir plusieurs arbres d'analyse corrects pour une même instruction. (fr) Dangling else problem to problem niejednoznaczności spotykanych w praktyce gramatyk bezkontekstowych. Niech polecenie redukuje się do if (warunek) polecenie, do if (warunek) polecenie else polecenie oraz do jakiegoś innego polecenia, np. zmienna = wyrażenie. Weźmy teraz polecenie: if (warunek1) if (warunek2) zmienna = wyrażenie else zmienna = wyrażenie Gramatyka w żaden sposób nie rozstrzyga do którego if odnosi się to else: if (warunek1) { if (warunek2) zmienna = wyrażenie else zmienna = wyrażenie } czy też: if (warunek1) { if (warunek2) zmienna = wyrażenie } else zmienna = wyrażenie Gramatykę taką zawsze można przekształcić w gramatykę jednoznaczną, zwykle zakładając że else dotyczy najwewnętrzniejszego wolnego if (czyli pierwsza z podanych wyżej interpretacji). Jest to również rozwiązanie najlepsze ze względu na strukturę analizatora składni: aby skojarzyć napotkany else z właściwym if nie potrzeba sprawdzać liczby else-ów następujących w dalszej części analizowanego napisu. (pl)
dbo:wikiPageID 648096 (xsd:integer)
dbo:wikiPageLength 10203 (xsd:nonNegativeInteger)
dbo:wikiPageRevisionID 1093054780 (xsd:integer)
dbo:wikiPageWikiLink dbr:Python_(programming_language) dbr:Scannerless_parsing dbr:Scheme_(programming_language) dbr:Conditional_(computer_programming) dbr:Context-free_grammar dbr:S-algol dbr:Eiffel_(programming_language) dbr:Modula-2 dbr:The_lexer_hack dbr:LR_parser dbr:AppleScript dbc:Conditional_constructs dbr:Computer_programming dbr:Parsing_expression_grammar dbr:C_(programming_language) dbc:Computer_programming dbr:ALGOL_60 dbr:ALGOL_68 dbr:Ada_(programming_language) dbr:Ambiguous_grammar dbr:PL/SQL dbc:Ambiguity dbc:Parsing dbr:Swift_(programming_language) dbr:Parse_tree dbr:Racket_(programming_language) dbr:Most_vexing_parse dbr:Visual_Basic dbr:Compiler_design dbr:Programming_language dbr:Shift-reduce_conflict dbr:Parser_generator
dbp:wikiPageUsesTemplate dbt:Reflist dbt:Short_description
dct:subject dbc:Conditional_constructs dbc:Computer_programming dbc:Ambiguity dbc:Parsing
gold:hypernym dbr:Problem
rdf:type yago:Abstraction100002137 yago:Communication100033020 yago:Language106282651 dbo:Disease yago:WikicatFormalLanguages
rdfs:comment Nepovinné else (anglicky dangling else) v podmíněném příkazu způsobuje, že mnoho programovacích jazyků je nejednoznačných. Formální příčinou je, že bezkontextová gramatika příslušného jazyka je nejednoznačná, což znamená, že pro některé programy existuje více než jeden správný derivační strom. (cs) Das Problem des dangling else (englisch dangling ‚baumelnd‘) ist ein Beispiel für eine scheinbare Mehrdeutigkeit einer Programmiersprache, die für Verwirrung sorgen kann, insbesondere bei falscher Einrückung. Tatsächlich ist die Semantik in den meisten Sprachen eindeutig definiert, schon weil die Grammatik der Sprache sonst nicht eindeutig zerlegbar wäre. Das Problem taucht in einigen Programmiersprachen (wie C, C++, Java) auf, wenn zwei verschachtelten if-Anweisungen nur ein else-Zweig gegenübersteht. Es kann nur auftreten, wenn eine optionale Klammerung weggelassen wird. (de) En informatique, et notamment dans la conception et l'analyse des langages de programmation, le problème du dangling else (anglais que l'on pourrait traduire par le problème du « sinon pendant ») est un problème de programmation informatique qui résulte de l'ambiguïté de l'interprétation de la clause sinon dans l'imbrication de deux instructions conditionnelles de la forme si-alors-sinon. Formellement, la grammaire non contextuelle du langage est ambiguë, ce qui signifie qu'il peut y avoir plusieurs arbres d'analyse corrects pour une même instruction. (fr) The dangling else is a problem in programming of parser generators in which an optional else clause in an if–then(–else) statement results in nested conditionals being ambiguous. Formally, the reference context-free grammar of the language is ambiguous, meaning there is more than one correct parse tree. In many programming languages one may write conditionally executed code in two forms: the if-then form, and the if-then-else form – the else clause is optional: if a then sif b then s1 else s2 if a then if b then s else s2 if a then (if b then s) else s2if a then (if b then s else s2) (en) Dangling else problem to problem niejednoznaczności spotykanych w praktyce gramatyk bezkontekstowych. Niech polecenie redukuje się do if (warunek) polecenie, do if (warunek) polecenie else polecenie oraz do jakiegoś innego polecenia, np. zmienna = wyrażenie. Weźmy teraz polecenie: if (warunek1) if (warunek2) zmienna = wyrażenie else zmienna = wyrażenie Gramatyka w żaden sposób nie rozstrzyga do którego if odnosi się to else: if (warunek1) { if (warunek2) zmienna = wyrażenie else zmienna = wyrażenie } czy też: if (warunek1) { if (warunek2) zmienna = wyrażenie } else zmienna = wyrażenie (pl)
rdfs:label Nepovinné else (cs) Dangling else (de) Dangling else (en) Dangling else (fr) Dangling else problem (pl)
owl:sameAs freebase:Dangling else yago-res:Dangling else wikidata:Dangling else dbpedia-cs:Dangling else dbpedia-de:Dangling else dbpedia-fr:Dangling else dbpedia-pl:Dangling else https://global.dbpedia.org/id/Crt5
prov:wasDerivedFrom wikipedia-en:Dangling_else?oldid=1093054780&ns=0
foaf:isPrimaryTopicOf wikipedia-en:Dangling_else
is dbo:wikiPageRedirects of dbr:Hanging_else dbr:Dangling_else_ambiguity dbr:Dangling_else_problem dbr:If-else_ambiguity dbr:If–else_ambiguity
is dbo:wikiPageWikiLink of dbr:Lexer_hack dbr:Conditional_(computer_programming) dbr:S-algol dbr:GNU_Bison dbr:LR_parser dbr:Parsing_expression_grammar dbr:Garden-path_sentence dbr:ALGOL_58 dbr:ALGOL_68 dbr:Ada_(programming_language) dbr:Ambiguous_grammar dbr:Pascal_(programming_language) dbr:Hanging_else dbr:Semicolon dbr:Off-side_rule dbr:Dangling_else_ambiguity dbr:Dangling_else_problem dbr:If-else_ambiguity dbr:If–else_ambiguity
is foaf:primaryTopic of wikipedia-en:Dangling_else