<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Grammatik von C++]]></title><description><![CDATA[<p><a href="http://en.wikipedia.org/wiki/LR_parser" rel="nofollow">http://en.wikipedia.org/wiki/LR_parser</a> schreibt &quot; * Many programming languages can be parsed using some variation of an LR parser. Notable exceptions are C++ and Perl.&quot;</p>
<p>Warum geht das bei C++ nicht?</p>
<p>Kann man C++ mit einem LL(k)-Parser parsen?</p>
<p>C++ hat aber eine kontextfreie Grammatik?</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/156779/grammatik-von-c</link><generator>RSS for Node</generator><lastBuildDate>Fri, 10 Jul 2026 14:49:33 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/156779.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 20 Aug 2006 08:05:04 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Grammatik von C++ on Sun, 20 Aug 2006 08:05:04 GMT]]></title><description><![CDATA[<p><a href="http://en.wikipedia.org/wiki/LR_parser" rel="nofollow">http://en.wikipedia.org/wiki/LR_parser</a> schreibt &quot; * Many programming languages can be parsed using some variation of an LR parser. Notable exceptions are C++ and Perl.&quot;</p>
<p>Warum geht das bei C++ nicht?</p>
<p>Kann man C++ mit einem LL(k)-Parser parsen?</p>
<p>C++ hat aber eine kontextfreie Grammatik?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1120709</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1120709</guid><dc:creator><![CDATA[LL&#x2F;LR]]></dc:creator><pubDate>Sun, 20 Aug 2006 08:05:04 GMT</pubDate></item><item><title><![CDATA[Reply to Grammatik von C++ on Sun, 20 Aug 2006 08:35:13 GMT]]></title><description><![CDATA[<p><a href="http://www.nobugs.org/developer/parsingcpp/" rel="nofollow">http://www.nobugs.org/developer/parsingcpp/</a></p>
<p>den Link findet man uebrigens in 20s von deiner Seite aus ...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1120718</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1120718</guid><dc:creator><![CDATA[Bashar]]></dc:creator><pubDate>Sun, 20 Aug 2006 08:35:13 GMT</pubDate></item><item><title><![CDATA[Reply to Grammatik von C++ on Sun, 20 Aug 2006 08:43:25 GMT]]></title><description><![CDATA[<p>Sorry, aber ich habe die Seite durchgelesen und finde die Antworten nicht.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1120723</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1120723</guid><dc:creator><![CDATA[LL&#x2F;LR]]></dc:creator><pubDate>Sun, 20 Aug 2006 08:43:25 GMT</pubDate></item><item><title><![CDATA[Reply to Grammatik von C++ on Mon, 21 Aug 2006 11:16:49 GMT]]></title><description><![CDATA[<p>*push*</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1121406</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1121406</guid><dc:creator><![CDATA[LL&#x2F;LR]]></dc:creator><pubDate>Mon, 21 Aug 2006 11:16:49 GMT</pubDate></item><item><title><![CDATA[Reply to Grammatik von C++ on Wed, 23 Aug 2006 13:18:02 GMT]]></title><description><![CDATA[<p>*push*</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1122867</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1122867</guid><dc:creator><![CDATA[LL&#x2F;LR]]></dc:creator><pubDate>Wed, 23 Aug 2006 13:18:02 GMT</pubDate></item><item><title><![CDATA[Reply to Grammatik von C++ on Wed, 23 Aug 2006 13:22:19 GMT]]></title><description><![CDATA[<p>*pop*</p>
<p><a href="http://www.nobugs.org/developer/parsingcpp/" rel="nofollow">http://www.nobugs.org/developer/parsingcpp/</a> schrieb:</p>
<blockquote>
<p>A few web searches turned up an YACC-compatible LALR grammar written Jim Roskind which parses an early version of C++ (before namespaces, exceptions, templates and the bool type were added into the language). This is accompanied by a very useful discussion of the ambiguities in the C++ language, and how various conflicts in the grammar were resolved. This is just a grammar, and so doesn't build a full symbol table. It also uses a 'hack' to help the parsing -- enough semantic information is fed back to the lexer to allow the lexer to classify identifiers as either plain identifiers or typedef names, which makes parsing a bit easier at the expense of tangling the implementation a bit.</p>
<p>The next thing I came across was a C++ grammar for ANTLR. ANTLR is a parser generator which works on predicated LL(k) grammars. A predicated LL(k) grammar differs from an LL(1) grammar in the following respects. Firstly, it uses k symbols of lookahead. Theoretically, this would make the parser much slower, but in practise it doesn't slow things down much. Secondly, the choice of which production to use can be based on the next k terminals, and additionally, some syntactic predicate and/or a semantic predicate (such as 'lookup the identifier in the symbol table and if it's a type then use this production').</p>
</blockquote>
]]></description><link>https://www.c-plusplus.net/forum/post/1122870</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1122870</guid><dc:creator><![CDATA[ANTLR]]></dc:creator><pubDate>Wed, 23 Aug 2006 13:22:19 GMT</pubDate></item><item><title><![CDATA[Reply to Grammatik von C++ on Wed, 23 Aug 2006 13:26:33 GMT]]></title><description><![CDATA[<p>Da stehen doch keine Antworten auf meine Fragen?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1122874</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1122874</guid><dc:creator><![CDATA[LL&#x2F;LR]]></dc:creator><pubDate>Wed, 23 Aug 2006 13:26:33 GMT</pubDate></item><item><title><![CDATA[Reply to Grammatik von C++ on Wed, 23 Aug 2006 14:20:39 GMT]]></title><description><![CDATA[<p>Da sonst keiner Rät:</p>
<p>Ich tippe auf zwei Faktoren die dazu führen, dass man C++ nicht mit so einem Parser lesen kann/sollte:</p>
<ol>
<li>Pre-Prozessor und bedingte Makros - fiese Sache für Parsersachen</li>
<li>namespaces &amp; using namespace - macht es schwer bis Unmöglich den korrekten Typ eines Objektes nur aus dem AST heraus zu lesen.</li>
</ol>
<p>Macht Sinn?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1122908</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1122908</guid><dc:creator><![CDATA[Headhunter]]></dc:creator><pubDate>Wed, 23 Aug 2006 14:20:39 GMT</pubDate></item><item><title><![CDATA[Reply to Grammatik von C++ on Wed, 23 Aug 2006 14:24:56 GMT]]></title><description><![CDATA[<ol>
<li>klingt sehr gut. Dann sind also C und C++ nicht kontextfrei?</li>
<li>&quot;aus dem AST heraus zu lesen&quot; klingt nicht nach Parser, sondern nach semantischer Analyse?</li>
</ol>
]]></description><link>https://www.c-plusplus.net/forum/post/1122909</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1122909</guid><dc:creator><![CDATA[LL&#x2F;LR]]></dc:creator><pubDate>Wed, 23 Aug 2006 14:24:56 GMT</pubDate></item><item><title><![CDATA[Reply to Grammatik von C++ on Wed, 23 Aug 2006 14:32:00 GMT]]></title><description><![CDATA[<p>Headhunter schrieb:</p>
<blockquote>
<p>Ich tippe auf zwei Faktoren die dazu führen, dass man C++ nicht mit so einem Parser lesen kann/sollte:</p>
<ol>
<li>Pre-Prozessor und bedingte Makros - fiese Sache für Parsersachen</li>
</ol>
</blockquote>
<p>Das glaube ich eher nicht. Denn: Der Präprozessor ist ein einfacher Textersetzer, der eimal über die Datei läuft. Danach sind die ganzen #-Sachen weg. Die Datei die dabei rauskommt kriegt der Compiler gefüttert. Von Makros ist da also schon nix mehr zu sehen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1122914</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1122914</guid><dc:creator><![CDATA[Jester]]></dc:creator><pubDate>Wed, 23 Aug 2006 14:32:00 GMT</pubDate></item><item><title><![CDATA[Reply to Grammatik von C++ on Wed, 23 Aug 2006 15:02:11 GMT]]></title><description><![CDATA[<p>Headhunter schrieb:</p>
<blockquote>
<p>Da sonst keiner Rät:</p>
</blockquote>
<p>Ich finde es sinnlos. Hat LL/LR etwa in 8 Minuten meinen Link und alle dort verlinkten Artikel durchgelesen und entschieden, dass es dort nichts interessantes zu sehen gibt? Und dann kommt keine fundiertere Nachfrage als &quot;ich finde die Antworten nicht&quot;? Sehr motivierend <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f642.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--slightly_smiling_face"
      title=":)"
      alt="🙂"
    /></p>
<blockquote>
<ol>
<li>Pre-Prozessor und bedingte Makros - fiese Sache für Parsersachen</li>
</ol>
</blockquote>
<p>Nicht wirklich. Preprocessor-Direktiven sind nur schwierig für Utilities, die den Quelltext erhalten müssen, wie Dokumentationstools, Beautifier, Refactoring-Tools usw. Der Preprocessor selbst ist relativ leicht zu implementieren, danach arbeitet der Compiler auf einem &quot;sauberen&quot; Quelltext.</p>
<blockquote>
<ol start="2">
<li>namespaces &amp; using namespace - macht es schwer bis Unmöglich den korrekten Typ eines Objektes nur aus dem AST heraus zu lesen.</li>
</ol>
</blockquote>
<p>Ich sehe da keine zusätzliche Schwierigkeit gegenüber z.B. record-Membern in anderen Sprachen. Den Typ brauchst du bei der Syntaxanalyse aber auch gar nicht. Jedenfalls normalerweise, in C schon <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f609.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--winking_face"
      title=";)"
      alt="😉"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1122950</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1122950</guid><dc:creator><![CDATA[Bashar]]></dc:creator><pubDate>Wed, 23 Aug 2006 15:02:11 GMT</pubDate></item><item><title><![CDATA[Reply to Grammatik von C++ on Wed, 23 Aug 2006 15:48:49 GMT]]></title><description><![CDATA[<p>Hallo,</p>
<p>ich habe mir die Artikel nicht durchgelesen, weiß also nicht ob meine auf die Semantik bezogenen Kommentare überhaupt Sinn machen:</p>
<p>Makros:<br />
Wie willst du Makros a la &quot;#ifdef LINUX&quot; oder &quot;#ifndef GCC&quot; handeln?<br />
Wenn dann noch so Schweineieren wie &quot;#ifdef 5+4*2 &gt; 0&quot; auftauchen wirds schwer..</p>
<p>Namespaces sind mit using sehr mies (siehe nächster Code). Wenn man rausfinden möchte welche Funktion man beispielsweis aufruft, muss man immer wissen, in welchem Namespace man sich gerade befindet. Aber was sind record-Member ,Bashar?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1122996</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1122996</guid><dc:creator><![CDATA[Headhunter]]></dc:creator><pubDate>Wed, 23 Aug 2006 15:48:49 GMT</pubDate></item><item><title><![CDATA[Reply to Grammatik von C++ on Wed, 23 Aug 2006 16:08:19 GMT]]></title><description><![CDATA[<p>Headhunter schrieb:</p>
<blockquote>
<p>ich habe mir die Artikel nicht durchgelesen, weiß also nicht ob meine auf die Semantik bezogenen Kommentare überhaupt Sinn machen:</p>
<p>Makros:<br />
Wie willst du Makros a la &quot;#ifdef LINUX&quot; oder &quot;#ifndef GCC&quot; handeln?<br />
Wenn dann noch so Schweineieren wie &quot;#ifdef 5+4*2 &gt; 0&quot; auftauchen wirds schwer..</p>
</blockquote>
<p>Nein, das sieht der Compiler alles nicht mehr. Das macht der Präprozessor vorher schon alles platt.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1123015</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1123015</guid><dc:creator><![CDATA[Jester]]></dc:creator><pubDate>Wed, 23 Aug 2006 16:08:19 GMT</pubDate></item><item><title><![CDATA[Reply to Grammatik von C++ on Wed, 23 Aug 2006 16:08:49 GMT]]></title><description><![CDATA[<p>Headhunter schrieb:</p>
<blockquote>
<p>Makros:<br />
Wie willst du Makros a la &quot;#ifdef LINUX&quot; oder &quot;#ifndef GCC&quot; handeln?<br />
Wenn dann noch so Schweineieren wie &quot;#ifdef 5+4*2 &gt; 0&quot; auftauchen wirds schwer..</p>
</blockquote>
<p>Ich seh da ueberhaupt kein Problem. Das zu parsen ist einfach, und in einer map kann ich auch ganz einfach nachschauen, ob da ein Symbol vorkommt. Und das Auswerten arithmetischer und sonstiger Ausdrücke sollte IMHO einen Compilerentwickler nicht vor unüberwindliche Hindernisse stellen.</p>
<blockquote>
<p>Namespaces sind mit using sehr mies (siehe nächster Code). Wenn man rausfinden möchte welche Funktion man beispielsweis aufruft, muss man immer wissen, in welchem Namespace man sich gerade befindet.</p>
</blockquote>
<p>Ja das sollte man wissen. Aber was hat das mit C zu tun, du musst auch in Pascal wissen, in welcher Prozedur du gerade bist.</p>
<blockquote>
<p>Aber was sind record-Member ,Bashar?</p>
</blockquote>
<p>struct-Elemente, nur (ansatzweise hoffentlich) programmiersprachenunabhaengig gesprochen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1123016</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1123016</guid><dc:creator><![CDATA[Bashar]]></dc:creator><pubDate>Wed, 23 Aug 2006 16:08:49 GMT</pubDate></item></channel></rss>