Hi��
I'm trying to understand what are the idioms in Smacc when converting from
ANTLR
######### the case of * ########################
Function = ���(��� (',' Arguments )* ���)���
�� �� ��should be transformed into��
Function
: <name> "(" 'leftParen' _ArgumentsOption ��")" 'rightParen' {{}}
;
_ArgumentsOption
:
| Arguments��
;
Arguments
: Expression 'argument'
| Arguments "," Expression 'argument'
;
Here since there is a recursion in Arguments��
the instance variable containing a list of argument will be added to the FunctionNode
Pay attention that Expression 'argument' should not have a {{}} nor its parent rule.
######### the case of + ########################
Function = ���(��� ��Arguments + ���)���
�� �� ��should be transformed into��
Function
: <name> "(" 'leftParen' _ArgumentsOption ��")" 'rightParen' {{}}
;
_ArgumentsOption
: Arguments��
;
Arguments
: Expression 'argument'
| Arguments "," Expression 'argument'
;
######### the case of ? ########################
Function = ���(��� ��Arguments+ ���)���
�� �� ��should be transformed into��
Function
: <name> "(" 'leftParen' _ArgumentsOption ��")" 'rightParen' {{}}
;
_ArgumentsOption
:
| Arguments��
;
Arguments
: Expression 'argument'��
;
Is there a more compact way to express?
Thierry do you have example of *, + , ? in the grammar?
Stef