========================================================================
|
|
pointer declarations vs multiplications
|
|
========================================================================
|
|
|
|
int main() {
|
|
// declare a function pointer
|
|
A * b(int a);
|
|
|
|
// evaluate an expression
|
|
c * d(5);
|
|
}
|
|
|
|
---
|
|
|
|
(translation_unit (function_definition
|
|
(identifier)
|
|
(function_declarator (identifier))
|
|
(compound_statement
|
|
(comment)
|
|
(declaration
|
|
(identifier)
|
|
(pointer_declarator (function_declarator
|
|
(identifier)
|
|
(parameter_type_list (parameter_declaration (identifier) (identifier))))))
|
|
(comment)
|
|
(expression_statement (math_expression
|
|
(identifier)
|
|
(call_expression (identifier) (number_literal)))))))
|
|
|
|
========================================================================
|
|
casts vs multiplications
|
|
========================================================================
|
|
|
|
/*
|
|
* ambiguities
|
|
*/
|
|
|
|
int main() {
|
|
// cast
|
|
a((B *)c);
|
|
|
|
// parenthesized product
|
|
d((e * f));
|
|
}
|
|
|
|
---
|
|
|
|
(translation_unit
|
|
(comment)
|
|
(function_definition
|
|
(identifier)
|
|
(function_declarator (identifier))
|
|
(compound_statement
|
|
(comment)
|
|
(expression_statement (call_expression
|
|
(identifier)
|
|
(cast_expression (type_name (identifier) (abstract_pointer_declarator)) (identifier))))
|
|
(comment)
|
|
(expression_statement (call_expression
|
|
(identifier)
|
|
(math_expression (identifier) (identifier)))))))
|
|
|
|
========================================================================
|
|
function-like type macros vs function calls
|
|
========================================================================
|
|
|
|
// this is a macro
|
|
GIT_INLINE(int) x = 5;
|
|
|
|
---
|
|
|
|
(translation_unit
|
|
(comment)
|
|
(declaration
|
|
(macro_type_specifier (identifier) (identifier))
|
|
(init_declarator (identifier) (number_literal))))
|
|
|
|
========================================================================
|
|
function calls vs parenthesized declarators vs macro types
|
|
========================================================================
|
|
|
|
int main() {
|
|
/*
|
|
* Could be either:
|
|
* - function call
|
|
* - declaration w/ parenthesized declarator
|
|
* - declaration w/ macro type, no declarator
|
|
*/
|
|
ABC(d);
|
|
|
|
/*
|
|
* Normal declaration
|
|
*/
|
|
efg hij;
|
|
}
|
|
|
|
---
|
|
|
|
(translation_unit
|
|
(function_definition
|
|
(identifier)
|
|
(function_declarator (identifier))
|
|
(compound_statement
|
|
(comment)
|
|
(declaration (identifier) (identifier))
|
|
(comment)
|
|
(declaration (identifier) (identifier)))))
|
|
|
|
========================================================================
|
|
Comments after for loops with ambiguities
|
|
========================================================================
|
|
|
|
int main() {
|
|
for (a *b = c; d; e) {
|
|
aff;
|
|
}
|
|
|
|
// a-comment
|
|
|
|
g;
|
|
}
|
|
|
|
---
|
|
|
|
(translation_unit (function_definition
|
|
(identifier)
|
|
(function_declarator (identifier))
|
|
(compound_statement
|
|
(for_statement
|
|
(declaration (identifier) (init_declarator
|
|
(pointer_declarator (identifier))
|
|
(identifier)))
|
|
(identifier)
|
|
(identifier)
|
|
(compound_statement
|
|
(expression_statement (identifier))))
|
|
(comment)
|
|
(expression_statement (identifier)))))
|