From: Baptiste L. <gai...@fr...> - 2003-01-07 08:45:36
|
----- Original Message ----- From: "Andre Baresel" <and...@gm...> To: "Baptiste Lepilleur" <gai...@fr...>; "CppTool Mailing List" <Cpp...@li...> Sent: Friday, December 27, 2002 9:13 PM Subject: Re: [Cpptool-develop] Expression parsing > Baptiste Lepilleur wrote: > [...] > Well I was stepping down the EBNF of the C++ syntax which can be found > e.g. in the MSDN. > Expressions start with expression-list. > expression-list-elements are assignment-expressions. (Can be easily > detected by comma and balanced braces) > assignment-expression can be: > conditional-expression "a ? 1 : 0 " > throw-expression "throw <whatever>" > [term] assignment-operator [term] ...Can > be detected by searching for assignment-operators (a list!) and balanced > braces Beware of EBNF naming in the standard. They often put name in their rule that as little to see with the actual content. The above rule should probably be named something like 'expression-with-same-priority-as-assignment'. > >I would extend the ExpressionMutator to detect the token '=' and check that > >the expression starts with the tokens 'identifier, assign-op', and in that > >case mutate to a locale-variable-assignement-expression and do the required > >processing for that kind of node. > > > As I did - but I added also the detection of surrounding expression list > since with this we can also handle > the following example and all expression that use the expression list > operator ',' : > > a = 0, b = 10; I doubt this can be done correctly because of template: namer<string , comon_naming_traits>( firstName, lastName ) => there is no way to know if namer is a template or no. On the other hand, since we are only using this to detect assignation, I guess that we can live with this (I don't think assignation are possible in template parameters). Baptiste. > > -- Andre |