The Interpreter design pattern providesan elegant and natural way of implementing systemsbased on term-rewriting in a OO fashion. The ideais simply associating each term of a language, eitherterminal or non-terminal, with a correspondingclass provided with a suitable simplify() method.Reducing a term to a normal form is thus performedthrough a series of recursive calls to such a method.The main weakness of this approach is that it does nottake into account similarities existing among differentdomains, thus enforcing programmers to pollutegeneric and domain-specific rules. The resulting codeif often wordy, hard to maintain, non-reusable. In thispaper we adapt the Interpreter pattern so that a cleanseparation between generic (common to differentdomains) and domain-specific rules is possible. Thenew pattern significantly helps design even complexrewriting systems. A running example which refersto a generic Logical domain is used throughout thepaper. An application to High Level Petri nets analysisis sketched. Without any loss of generality we refer toJava as representative of a large class of languages.
An extension of the interpreter pattern to define domain-parametric rewriting systems / L. Capra, V. Stile - In: SYNASC 2013 : 15th International symposium on symbolic and numeric algorithms for scientific computing : 23-26 september 2013, Timisoara, Romania : proceedings / [a cura di] N. Björner, V. Negru, T. Ida, T. Jebelean, D. Petcu, S. Watt, D. Zaharie. - Los Alamitos : IEEE Computer Society, 2014. - ISBN 9781479930364. - pp. 185-192 (( Intervento presentato al 15. convegno International Symposium on Symbolic and Numeric Algorithms for Scientific Computing tenutosi a Timisoara nel 2013 [10.1109/SYNASC.2013.32].
An extension of the interpreter pattern to define domain-parametric rewriting systems
L. CapraPrimo
;
2014
Abstract
The Interpreter design pattern providesan elegant and natural way of implementing systemsbased on term-rewriting in a OO fashion. The ideais simply associating each term of a language, eitherterminal or non-terminal, with a correspondingclass provided with a suitable simplify() method.Reducing a term to a normal form is thus performedthrough a series of recursive calls to such a method.The main weakness of this approach is that it does nottake into account similarities existing among differentdomains, thus enforcing programmers to pollutegeneric and domain-specific rules. The resulting codeif often wordy, hard to maintain, non-reusable. In thispaper we adapt the Interpreter pattern so that a cleanseparation between generic (common to differentdomains) and domain-specific rules is possible. Thenew pattern significantly helps design even complexrewriting systems. A running example which refersto a generic Logical domain is used throughout thepaper. An application to High Level Petri nets analysisis sketched. Without any loss of generality we refer toJava as representative of a large class of languages.Pubblicazioni consigliate
I documenti in IRIS sono protetti da copyright e tutti i diritti sono riservati, salvo diversa indicazione.