Node Generator/Constructor Call

AdditiveExpr :=

| 'generate' TypeName_t '(' ArgumentExprList ')'

| 'generate' Identifier_t '(' ArgumentExprList ')'

| 'generate' TypeName_t '(' ArgumentExprList ',' ')'

| 'generate' Identifier_t '(' ArgumentExprList ',' ')'

| 'generate' TypeName_t '(' ')'

| 'generate' Identifier_t '(' ')'

| 'generate' TypeName_t

| 'generate' Identifier_t

| 'generate' '<' ShiftExpr_c '>' TypeName_t '(' ArgumentExprList ')'

| 'generate' '<' ShiftExpr_c '>' Identifier_t '(' ArgumentExprList ')'

| 'generate' '<' ShiftExpr_c '>' TypeName_t '(' ArgumentExprList ',' ')'

| 'generate' '<' ShiftExpr_c '>' Identifier_t '(' ArgumentExprList ',' ')'

| 'generate' '<' ShiftExpr_c '>' TypeName_t '(' ')'

| 'generate' '<' ShiftExpr_c '>' Identifier_t '(' ')'

| 'generate' '<' ShiftExpr_c '>' TypeName_t

| 'generate' '<' ShiftExpr_c '>' Identifier_t

| 'construct' TypeName_t '(' ArgumentExprList ')'

| 'construct' Identifier_t '(' ArgumentExprList ')'

| 'construct' TypeName_t '(' ArgumentExprList ',' ')'

| 'construct' Identifier_t '(' ArgumentExprList ',' ')'

| 'construct' TypeName_t '(' ')'

| 'construct' Identifier_t '(' ')'

| 'construct' TypeName_t

| 'construct' Identifier_t

These are bridging productions from the nonterminal AdditiveExpr in C, which is to match expressions with precedence equal or higher than additions. The productions with the 'generate' keyword are for calls to node generators while those with the 'construct' keyword are for calls to node constructors. We allow arguments to be followed by a trailing ',' (following AbleC convensions) or to be empty (could even omit the parentheses in this case). Arguments have different meanings for generators and constructors. For node generator calls, there the keyword 'generate' can optionally be followed with a part wrapped in '<' and '>' specifying the probability to actually generate a node (as opposed to fill it with a null pointer), which serves the purpose of a maybe semantics. For additional discussions about generate versus construct, please refer to this. Also note that all productions here are for generator/constructor calls at the node level, as opposed to their counterparts at the item level. For additional discussions about item (wrapper) versus node, please refer to this.

  • Identifier_t is a terminal in C that matches any valid identifier, which is the nonterminal name or rule name in the generator version, and is the rule name only in the constructor version.

  • TypeName_t is a terminal in C that matches any valid type names, which serve the same purpose as identifier here. This verbose implementation may be a temporary solution due to lack of robust type system at the moment, therefore may be changed later.

    • ArgumentExprList is a nonterminal in C for a list of expressions to pass as arguments. For generators, the parameters are declared along with nonterminal types, regardless of the generator is called with nonterminal name or rule name; for constructors, the parameters are the children of the rule. Inside the scope of arguments for node constructors, any node constructor can omit the 'construct' keyword.