A plea for help from Erlang gurus

Taavi Talvik taavi@REDACTED
Thu Dec 18 12:35:55 CET 2003


I have system, which tries to classify events based on
their properties. And I am trying to simplify writing
some special code for acting on property lists.

I would like to write modules/rules in fashion of:

Arg = [{key,value}, {key, value}, ...]

%
% Add {importance,'not so important'} when event is at night
%
important_event(Arg@REDACTED="linkDown") when Arg@REDACTED > 0 and
					        Arg@REDACTED < 8 ->
	Arg@REDACTED = 'not so important event',
	Arg;

%
% Add {importance,'very important'} to property list
% when there is {event_type, "linkDown"} in passed in property list
%
important_event(Arg@REDACTED="linkDown") ->
	Arg@REDACTED = 'very important event',
	Arg.

This is basicly to extend pattern matching and guard tests
to property list(assocative arrays) and add easy way to access
those properties.

What is best way to proceed:

	extend erl_scan and erl_parse
	generate extended parse tree

	analyze parse tree with help of syntax_tools
	find "array accesses"
	replace them with access functions or case statements
	in pattern matching and test guards

	output new code..

Any pointers to papers, code examples doing something similiar,
ideas how erlang 'guru' will handle above are very much appreciated.

What is reasonable way to start with this?

best regards,
taavi

PS. I have never done anything like this before except classical
exercise to write simple calculator with lex and yacc.





More information about the erlang-questions mailing list