2012/12/3 José Luis Millán <jmi...@aliax.net>:
> What the parser does is filling an initial empty JavaScript object as theWhat about adding action with "return data;" inside to rules from
> input passes through the difrerent rules. The parser returns such data
> object instead of the 'result' array.
>
> The parser is briefly modified (you can see in the above link _README.md
> file_) so it does not throw an exceptiion if fails (This is because I handle
> the parsing errors in an upper layer) and it returns the filled object
> instead of the 'result' array.
which you start parsing? It seems to me that it would be cleaner than
modifying the generated parser.
In general I think it's better to build the return value as you walk
up the grammar during parsing and avoid a global variable. Is there
any specific reason why you chose to go with it?
--
David Majda
Entropy fighter
http://majda.cz/
--
José Luis Millán
2012/12/10 José Luis Millán <jmi...@aliax.net>:
> 2012/12/10 David Majda <da...@majda.cz>You get all the benefits associated with getting rid of a global
>> If I were doing this, I'd probably return simple objects from the
>> rules. For example, instead of
>>
>> ... { data.scheme = uri_scheme; }
>>
>> I'd do
>>
>> ... { return { scheme: uri_scheme }; }
>>
>> and merge/compose these objects later as appropriate.
>
> This seems to be cleaner, yes. Could you please tell me the benefits of
> doing that way? I guess there are some that I can see right now.
variable. See any text about good programming practices for a list.
Note that your SIP grammar is relatively simple and flat in structure,
which means the benefits may not manifest that much.