[antlr-interest] C++ Grammars
ludwig.maes at gmail.com
Fri Mar 9 15:47:07 PST 2012
By the way, the errors I get when performing "check grammar" in antlrworks
(I created an empty rule for alignment_expression)
[00:45:29] Checking Grammar cpp.g...
[00:45:30] java.lang.StringIndexOutOfBoundsException: String index out
of range: 7
On 10 March 2012 00:38, Ludwig Maes <ludwig.maes at gmail.com> wrote:
> Yes, I have
> I found 2 lineages: the one from sun and the much more recent one.
> The last one has actions in C++, and the mixture of grammar and
> actions is still quite confusing for me beyond basic examples...
> (pretty new to both formal language grammars and parsing and antlr)
> I have converted the xml from http://savannah.nongnu.org/projects/hcb/
> which is also prettyfied on http://www.nongnu.org/hcb/
> and seems to stem from http://www.open-std.org/jtc1/sc22/open/n2356/
> (this is very useful for me in the complementary sense, but I am not
> that acquainted with how compilers work)
> also for example there are no rules for comments in the grammar above,
> this text explains the comment skipping in words, as being during the
> preprocessing phase,... but the grammar contains preprocessor rules,
> so Im not completely satisfied (its not clear to me when exactly the
> rules for comments are used in perspective with the specific
> preprocessing rules... or rather why some preprocessing rules are
> present and others are not)
> I converted the xml to antlr grammar notation a few hours ago (mostly
> by hand/ text editor replace all commands, I did not have the heart to
> write an xml parser that would deal with ">" 's within content etc). I
> turned the hyphens into underscores, and resolved the simpler left
> recursions... theres still some problems though (right now every rule
> is lowercase parser rule, Im still a bit confused on the 2x2 double
> dichotomy of terminals/nonterminals and lexer/parser rules and perhaps
> literals/nonliterals); then theres an undefined rule in the xml:
> alignment-expression (or alignment_expression in the .g); a few more
> complex left recursions; and errors when I try to check the grammar
> (im using the antlrworks IDE). Right now I have not yet added any
> Some of the rules are described as a sentence instead of a grammar
> rule, as per the source.
> I should probably add a GPLv2+ header as the xml was under such
> license, I have no experience with licensing stuff so if anyone knows
> how to properly include the header that would be welcome.
> I have 1 strange error and 6 warnings in the IDE, any help would be appreciated!
> See cpp.g in attachment
> Friendly regards
> On 9 March 2012 21:37, David Wigg <wiggjd at bcs.org.uk> wrote:
>> In response to this message, has Ludwig looked at the C++ grammars
>> already on the antlr website?
>> Message: 1
>> Date: Fri, 9 Mar 2012 04:10:16 +0100
>> From: Ludwig Maes <ludwig.maes at gmail.com>
>> Subject: [antlr-interest] found a c++ grammar xml, convert to antlr
>> David Wigg
>> List: http://www.antlr.org/mailman/listinfo/antlr-interest
>> Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address
More information about the antlr-interest