[erlang-patches] [jinterface] add erlang term parse/match/bind features

Dmitriy Kargapolov dmitriy.kargapolov@REDACTED
Tue Dec 30 21:56:34 CET 2014


This implements functionality similar to following C functions, which are part of erl_interface application:
- ETERM *erl_format(FormatStr, ...);
- int erl_match(ETERM *Pattern, ETERM *Term);

To acheve this new classes introduced:
* OtpErlangVar - variable placeholder;
* OtpErlangBind - variable values collection;
* OtpErlangParser - "erl_format" parser implementation;
* OtpErlangPattern - pattern abstraction with match/bind functions;

Classes representing composite objects OtpErlangList, OtpErlangTuple, OtpErlangMap and new OtpErlangVar implement interface OtpErlangVarrier defining match and bind functions for these objects.

Class OtpErlangMap reworked to be based on HashMap instead of two separate lists keeping keys and values. This is close to native semantics of maps and makes easier implementing basic map manipulations.

It addition to OtpErlangBind custom user's class may be used as receiver of matched variables values. Java reflection is used to prepare variable value setters during the parse stage. Java doc has more details and examples. Test cases implemented.

git fetch https://github.com/x0id/otp.git jinterface_pattern_matching

Thanks.








More information about the erlang-patches mailing list