Hi john

I'm learning smacc as a challenge :) I read a review the tutorial that we
extracted form your doc.

I have the following expression

FunctionTypeName = 'function' TypeNameList ( 'internal' | 'external' |
'constant' | 'payable' )* ( 'returns' TypeNameList )?

and I started to handle the 'internal'....

Now my grammar does not succeed to parse
 (self parser parseFunctionTypeNameOptions: 'internal payable')

Attempt one: did not work
===================
FunctionTypeNameOptions
: {{}}
|  FunctionTypeNameOptions "internal" 'option' {{}}
|  FunctionTypeNameOptions "external" 'option' {{}}
|  FunctionTypeNameOptions "constant" 'option' {{}}
|  FunctionTypeNameOptions "payable" 'option' {{}}


Attempt two: did not work
===================
FunctionTypeNameOptions
:
| FunctTypeNameOptions
;
FunctTypeNameOptions
:  FunctTypeNameOptions "internal" 'option' {{}}
|  FunctTypeNameOptions "external" 'option' {{}}
|  FunctTypeNameOptions "constant" 'option' {{}}
|  FunctTypeNameOptions "payable" 'option' {{}}
;

Attempt three: did not work
=====================

FunctionTypeNameOptions
:
| FunctTypeNameOptions
;

FunctTypeNameOptions
: FunctTypeNameOption 'option'
| FunctTypeNameOptions FunctTypeNameOption 'option'
;
FunctTypeNameOption
:  "internal" 'option' {{}}
|  "external" 'option' {{}}
|  "constant" 'option' {{}}
|  "payable" 'option' {{}}
;



I studied the JavaParser and I do not get why my version does not work

modifiers_opt
:
| modifiers
;
modifiers
: modifier 'modifier'
| modifiers modifier 'modifier'
;
modifier
: "public" 'token' {{Modifier}}
| "protected" 'token' {{Modifier}}
| "private" 'token' {{Modifier}}
| "static" 'token' {{Modifier}}
;


Thanks in advance. I could have try to do it in petitParser but I want to
have a real experience with Smacc.

Stef

Reply via email to